Ocuna

All field notes

Engineering

A Dream-RSI workflow with Ocura OSS

Ocuna Research

· 8 min read · Updated

A raccoon examines overlapping drawings of a branching search tree, with one recorded route traced in ochre.

Keep track of what changed

A training run returns a lower validation loss. To decide what to do next, you need more than that number: which checkpoint it resumed, how long it trained, and what changed since the last attempt.

In our Dream-RSI example, one agent proposes learning-rate schedules. A second agent rewrites a policy: the rule that decides which training attempt to try next. Ocura OSS records their commands and results, along with how the runs relate to one another. The example handles the training, checkpoints, and agent calls.

The walkthrough below uses Ocura OSS 0.7.0. The results at the end come from our September 22, 2026 pilot on 0.4.0. That pilot completed the whole loop, but the lower losses weren't enough to show that policy revision helped. The saved history let us work out why.

Try a policy against saved results

As attempts finish, their history forms a tree of choices and results. In this Dream-RSI adaptation, we use that tree to try alternative policies. A policy chooses a branch, and replay returns the recorded result if one exists. We can compare policies this way without asking an agent for another candidate or launching another training job.

We adapted the approach in section 3 of the paper to a small nanoGPT model trained on Tiny Shakespeare. The discovery agent writes learning_rate(step, total_steps) functions within fixed limits. The policy agent revises choose(observation), which chooses the next attempt. A proposed policy competes with the current policy on the saved history; the winner then guides a new training search.

Replay can't answer a question the saved runs never tested. If a policy asks to continue a branch beyond the recorded work, there's no result to return. Doing that in a live run needs a new agent call and training attempt. That gap matters when the score also counts the cost of attempts.

Record each attempt

The controller runs both agent requests and training jobs as commands, so it can record them through the same run() call. To continue an earlier attempt, it passes that attempt's branch point and a reason for the change. This helper returns the new execution and its verified output. The complete controller also records request hashes and enforces time and call limits.

Check execution.record.outcome before using the output: a failed command can still write to stdout. Its stderr can help explain the failure. If Ocura reports a storage error, keep the execution IDs and inspect what happened before trying again; the command may already have run.

from ocura_oss import Store, run

def record_attempt(root, command, parent):
    execution = run(
        command,
        root=root,
        source_branch_point_id=parent.branch_point.id,
        reason="refine candidate",
    )
    store = Store(root)
    stdout = store.read_verified_log(run_id=execution.record.id)
    stderr = store.read_verified_log(
        run_id=execution.record.id, stream="stderr"
    )
    return execution, stdout, stderr

Resume the training state

Continuing a training run takes more than its place in the history. It needs the model parameters, AdamW optimizer state, update counter, CPU random state, and batch-generator state. The example saves these together in a checkpoint and checks its hash before loading it.

The CPU test stops and resumes training, then compares it with an uninterrupted run across the same schedule change. The model, optimizer, and random states must match exactly in that runtime. Other checks reject damaged checkpoints and confirm that evaluating a checkpoint doesn't change the saved file.

During the search, agents see validation results. The test split stays out of the process until the policy and checkpoints have been chosen. That prevents test results from influencing those choices.

Try it locally

Start in an activated Python 3.12 virtual environment, which supports the CPU training dependencies used here. Clone the examples catalog, select the revision below, and install the released package. By default, these tests use small stand-ins for the agents and training jobs. They check how the parts fit together without remote calls or model training.

To try real training, follow the setup guide to install CPU PyTorch and prepare the exact nanoGPT and Tiny Shakespeare inputs used by the example. The separate Dream replay walkthrough uses fixed training recipes, so you can try collection, replay, and a new training run without an agent account.

git clone --branch examples/0.7 --single-branch https://github.com/Protention/ocura-oss.git ocura-oss-examples
cd ocura-oss-examples
git checkout 7249891621c5f2d613b395b1acd2e001322209e4
python -m pip install ocura-oss==0.7.0
python -m unittest discover -s tests -p "test_dream_rsi_*.py" -v

Add live agents

Once .tmp-tests/dream-inputs is prepared, you can try the live loop with a signed-in Codex CLI that supports the flags listed in the guide. Replace MODEL with a model available to your account. This small smoke run uses two training updates per attempt, up to seven agent calls, and an eight-minute controller time budget. Much of that time can go to startup, agent responses, or waiting for the host to have capacity.

Use a directory that doesn't exist yet. If the run stops, keep its files so you can inspect them; the example doesn't resume or retry automatically. This is a quick integration check. Two updates per attempt won't tell you whether a policy improves training.

For 0.7.0, we've run the local tests and real CPU training and replay checks. We haven't repeated the live-agent pilot. Those results are from September.

python examples/dream_rsi/experiment.py run --root .tmp-tests/dream-rsi-smoke --prepared .tmp-tests/dream-inputs --profile smoke --model MODEL --effort low --seed 101 --rounds 2 --attempts 2 --updates 2 --policy-revisions 1 --max-agent-calls 7 --max-seconds 480
python examples/dream_rsi/experiment.py report --root .tmp-tests/dream-rsi-smoke

Read the result after the run

The report verifies the records and reads the saved output. It checks the experiment settings, checkpoint hashes, and policy choices, including whether the policy chosen during replay was actually used in the next search. You can rebuild this report without calling an agent or importing PyTorch.

Keep the whole experiment directory, including requests and checkpoints. If you move a finished run, follow the guide's archive instructions and provide the original root so the report can find the saved checkpoints.

This helped during development when agents timed out or a busy machine delayed work. We could see what had finished before each stop, separate those problems from training failures, and account for the failed attempts when adding up the costs.

What the September pilot showed

In the September pilot, the first policy revision won the replay comparison and guided new training runs. A second revision tied, so the first stayed in use. The loop finished in just under eight minutes, after 17 agent calls and 15 training attempts.

The chosen policy reached lower test loss on both new seeds. Looking at the records showed that it spent all 48 available updates continuing one branch. The fixed control spent 32 updates on a branch and 16 on a restart. Training one branch longer could explain the lower losses; the experiment didn't establish a benefit from revising the policy.

The replay score needed a closer look too. Its 0.01 improvement came from requesting a continuation missing from the saved tree. That revealed no better training result, but left one fewer recorded attempt to count against the cost term. In a live run, the agent still had to generate and train that continuation. The higher replay score wasn't evidence of saved computation.

Including the six development runs and diagnostics, we recorded 54 agent calls and 43 completed training attempts. Seven earlier calls had no usage report, so the total token counts are incomplete. The published files summarize the measurements but omit the raw ledgers, checkpoints, and agent responses. They aren't enough to independently reconstruct that historical run.

What we would test next

The records helped us explain what the promising numbers meant. We could rebuild the report and follow each policy choice into later training runs. That showed where the extra training went and why the replay score rose.

To find out whether policy revision helps, the next study should include simpler live controls, such as greedy selection and always continuing the same branch. It also needs more test seeds and enough training for the allocation choices to matter. The current example provides the code and setup for running those comparisons and keeping the evidence needed to assess them.

Read next

Double Hackathon Weekend

Good experiments leave a trail

All field notes