Skip to content

feat(episode): record episodes in the run index - #457

Open
polakamtejas wants to merge 7 commits into
mainfrom
feat/episode-run-index
Open

polakamtejas wants to merge 7 commits into
mainfrom
feat/episode-run-index

Conversation

@polakamtejas

@polakamtejas polakamtejas commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

What

An episode now records itself in the run index, as a runner records the runs it accepts:

  • Before Task.run: a RunRecord with runner episode, status RUNNING, the task, its version and the instance id. It's written before the first await, so start() still returns with the run listed.
  • After teardown: mark_terminal with COMPLETED, FAILED and the error, or CANCELED and the abandon reason.
  • EpisodeSpec.start(run_group_id=...): files the run in that run group (overrides.metadata.run_group_id), the key the explorer groups a task's runs by. Without it, each run is its own group.

Why

The explorer's run lists read only the run index (agent_env.runner.store). An episode called Task.run directly, so its runs never appeared there: training episodes were reachable only by instance id. That holds for every trainer that plays through the Episode API, the OpenEnv-based helpers included. With a run group, a trainer can show a group of rollouts together, with their mean score.

The terminal status is written after teardown, as the cancelled record already is. A scored episode still answers result(teardown=False) at once (#393), and its run turns COMPLETED once its teardown is done.

Known limit

An episode in a trainer process that dies stays RUNNING in the index. LocalRunner marks its own interrupted runs failed on restart, and nothing does that for episodes yet.

Tests

  • New: run_test.py::test_an_episode_is_in_the_run_index_running_then_ended_in_the_group_it_was_started_in. It checks running with its group, then completed, cancelled with the reason, and failed with the error.
  • Affected suites: tst/unit/task, runner, explorer, openenv and training pass, 532 of 532, on five runs. One run right after uv sync had a single failure that didn't recur, likely a timing flake; the log didn't keep which test.
  • End to end: Tinker training on a local bundle wrote its episodes here with run groups, and the explorer's task page listed them grouped by training step. The Tinker PR stacked on this one uses run_group_id.

🤖 Generated with Claude Code

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge.

Summary

Episodes now appear in the explorer’s run history, and the PR adds a Tinker training adapter that files rollouts by training step.

  • Episode runs appear in the run index with their ending status.
  • Tinker trains on bundle tasks through grouped episode rollouts.
  • The explorer explains when another process owns a run.

No new actionable issues found. polakamtejas accepted using scores from non-fatal failed steps for training, matching OpenEnv, and deferred any shared policy change. The earlier finding was withdrawn.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Tinker rollout or Episode caller] --> B[Start episode with optional run group]
  B --> C[Write RUNNING record]
  C --> D[Run task and play agent turns]
  D --> E[Release proxies and tear down]
  E --> F[Write final run status]
  C --> G[Explorer run history]
  F --> G
Loading

Reviews (8) · Last reviewed commit: "Merge branch 'main' into feat/episode-ru..." · Reviewed by Greptile

Comment thread src/agent_env/task/episode/run.py Resolved
Comment thread src/agent_env/task/episode/run.py Resolved
Comment thread src/agent_env/task/episode/run.py Resolved
@polakamtejas
polakamtejas force-pushed the feat/episode-run-index branch from 172e5f1 to 728000f Compare November 6, 2026 16:32
Comment thread src/agent_env/task/episode/run.py Resolved
polakamtejas and others added 3 commits November 10, 2026 22:42
An episode called Task.run directly, so the run index never saw it and the explorer's run lists, which read only the
index, never showed it: training episodes were reachable only by instance id. An episode now records itself as a
runner records the runs it accepts (runner `episode`): RUNNING before Task.run, then COMPLETED, FAILED with the error,
or CANCELED with the abandon reason once its teardown is done. `EpisodeSpec.start(run_group_id=...)` files it in a
run group, so a trainer can show a group of rollouts together.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…g it from the explorer, and keep a failed record write from leaking

- An episode's run index status now follows `run_outcome`, the rule every runner uses: a step that fails without
  failing the task fails the run, rather than leaving it COMPLETED. Abandoned or cancelled stays CANCELED.
- The explorer's cancel route refuses, with 409 and where to stop it, a run another runner records: the configured
  runner can't cancel an episode a trainer plays, so asking it silently did nothing. The UI shows the reason.
- The run record is written inside the try whose finally takes the episode out of `_live`, so a write that fails is
  the run's error and leaves nothing behind.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The explorer reads a run's seed from `overrides.metadata.seed`, so an episode's run group listed `seed: null` for a
seeded episode.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@polakamtejas
polakamtejas force-pushed the feat/episode-run-index branch from e3a40ec to 167a782 Compare November 11, 2026 03:46
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread src/agent_env/training/tinker.py Resolved
Keeps both sides in the two conflicts: main's clock-test and egress-test with the Tinker tier's tinker-test in
the Makefile's .PHONY, and the TINKER capability beside main's `stat -c %f:%s` note in tst/util/capabilities.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread src/agent_env/training/tinker.py Resolved
polakamtejas and others added 2 commits November 17, 2026 11:33
…left over

EpisodeDataset rounded a pass's batches down, so with 10 tasks and groups_per_batch=3 one task went unplayed each
pass. A pass now rounds up, its last batch the tasks left over, as the cookbook's own RL datasets end a pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@polakamtejas
polakamtejas enabled auto-merge (squash) November 18, 2026 17:46

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant