Skip to content

fix: a multi-turn step's trajectory readers offer every turn, not only the last - #979

Merged
sarah-chitty-1 merged 6 commits into
mainfrom
sarahchitty/always-on-per-wake-trajectories
Dec 3, 2026
Merged

sarah-chitty-1 merged 6 commits into
mainfrom
sarahchitty/always-on-per-wake-trajectories

Conversation

@sarah-chitty-1

@sarah-chitty-1 sarah-chitty-1 commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

What was broken

Two kinds of step run several turns and store one trajectory per turn in target_agent_per_turn_trajectory_object_urls:

  • an always_on step, one per wake;
  • a multi-turn prompt_agent step, one per turn, e.g. a user-sim conversation.

agent_trajectory_object_url holds only the last turn's. The explorer's download bar and the agent-env task run output read only that field, so the earlier turns could not be downloaded from either.

What changes

One rule for every reader. PromptResponse.distinct_trajectory_object_urls() and the UI's runTrajectoryUrls() hold it, one place each: every turn's URL in turn order, with the turn it belongs to. Turns that stored none are skipped. A URL that several turns stored is listed once, at the last of them: an atif/1 document is rewritten each turn, so it holds the last turn's copy. Then the response URL comes last, with no turn, if the per-turn list lacks it.

Explorer download bar. One entry per prompt response.

  • A response with one trajectory keeps today's label, tooltip and behavior.
  • A response with several distinct turn trajectories gets a button that downloads its last available trajectory, labelled "Trajectory (turn n of n)" (or " (turn n of n)" beside other steps). A chevron next to it opens a turn picker that lists every turn as "turn k of n". The button and the picker label each file by the same turn.
  • An always_on step's turns are labelled by wake: "wake k of n", and a nudge turn "nudge after wake k". Its per-turn list holds each nudge beside the wakes, so turn k is not always wake k. Each turn's record (TurnTrajectory) now names its wake and marks a nudge (wake, nudge). The picker counts wakes. Runs recorded before this, and other steps, keep "turn k of n".
  • When the bar collapses into its dropdown, such a response is one row, with its turns in a submenu. The dropdown's button counts files, not responses.
  • A Claude Code atif/1 run, whose turns share one document, still shows one button.

The picker uses the explorer's existing Radix Themes DropdownMenu. No new UI library.

Explorer trajectory viewer. It already showed every turn, but showed a document once per turn that stored it, so an atif/1 run of N turns rendered the same conversation N times. It now shows each distinct trajectory once (trajectorySections). A shared document's section keeps the trigger strip of every turn that stored it. A response URL that the per-turn list lacks now gets a section too. Each section names its turn as the bar does: an always_on run's by wake ("wake k of n", "nudge after wake k"), other steps' "turn k of n" (they read "Turn k/n" before). A response with one section names no turn.

CLI. agent-env task run keeps its agent_trajectory_object_url line. When a response has more than one trajectory, it also lists each one in turn order with its turn, e.g. - turn 3 of 3: s3://…, and on an always_on step its wake, e.g. - turn 2 of 3 (nudge after wake 1): s3://….

What is not affected

No grader or score changes. Every verifier that scores already reads the per-turn list or no trajectory.

Tests

  • bar-downloads.smoke.ts: a single trajectory (unchanged), an always_on run of several wakes, a 20-turn prompt_agent conversation beside a single-turn step, and atif shared turns. The multi-turn cases fail both on the first commit (one button per turn) and on main (last turn only). For [A, B, A], the button and the picker both call A "turn 3 of 3". The file count covers a picker's turns.
  • trajectory-url.smoke.ts: runTrajectoryUrls for always_on wakes, a multi-turn prompt_agent run, atif shared turns, [A, B, A], and a single trajectory. trajectorySections for shared turns, [A, B, A], and a URL the list lacks. sectionTurnLabel, the viewer's name for a section, for an always_on run with a nudge, a step with no wake records, and a one-section response (fails on the previous head, which said "Turn k/n").
  • Wake labels: bar-downloads.smoke.ts and trajectory-url.smoke.ts cover an always_on run with a nudge (turn 2 is "nudge after wake 1", not wake 2), a run whose last turn is a nudge, and a record with no wake. test_always_on_trajectory_formats.py checks each turn's wake and nudge through a stored round trip.
  • Python: distinct_trajectory_object_urls() cases, [A, B, A] included. The task run output for always_on and multi-turn prompt_agent steps names each URL's turn, skips a turn that stored none, labels a nudge, and lists a shared document at its last turn. These tests fail on the previous head.
  • Rendered the viewer locally on a real always_on run, psi-ts-rw-fender-bender-9lwjdrec (31 wakes, no nudges). The instance came from the run's stored always_on timeline, since the hub tools don't return the per-turn lists. The run predates the wake field, so for the wake labels each turn's record was rebuilt from the timeline (turn k is wake k when there are no nudges). Result: 31 sections, one per distinct trajectory, labelled "wake 1 of 31" … "wake 31 of 31", and a loaded wake read from S3. Without the records the same run reads "turn k of 31" and the bar reads "Trajectory (turn 31 of 31)".
  • Ran: all explorer smokes (15 ran, 2 skipped for missing fixtures, 0 failed), strict tsc --noEmit, eslint on the changed files (no new warnings), tst/unit/cli with the trajectory and judge-batch unit tests (526 passed), and ruff check.

Follow-up

The hub has the same gap: get_run_status and get_task_run return only the last turn's trajectory URL.

🤖 Generated with Claude Code

Confidence Score: 5/5RetriggerView in Greptile

The PR appears safe to merge; no new actionable issues were found.

Summary

The latest changes make the viewer and download bar use the same turn labels.

  • Task-run output lists every distinct trajectory with its turn.
  • The explorer download bar lets people choose a trajectory from any turn.
  • The trajectory viewer shows each distinct document once and keeps its turn details.

Both earlier, unnumbered findings are fixed: the documentation says “last available,” and the main download selects the response’s URL for [A, B, A].

Reviews (9) · Last reviewed commit: "fix(explorer): the trajectory viewer lab..." · Reviewed by Greptile

…ly the last

An always_on step's prompt response already records each wake's trajectory, in wake order, under
target_agent_per_turn_trajectory_s3_uris / _object_urls. agent_trajectory_s3_uri is the last wake
alone (on a 7-wake run, 15 of its 353 tool calls). Every verifier that scores reads the per-turn
list or no trajectory, so no score came from one wake. Two readers here did read only the last:

- `agent-env task run` printed only agent_trajectory_object_url. It now lists every turn's url
  too, when there is more than one, and keeps the existing line.
- The explorer's download bar offered only the last turn of each prompt response. It now gives
  one entry per turn, labelled by turn, reading turns that share an atif/1 document once.

PromptResponse.trajectory_object_urls() and the UI's runTrajectoryUrls() name the rule once: each
turn's url in order, without gaps or repeats, then the last url if the list lacks it. It is the
same rule agentenvhub-sdk's trajectory_validation already applies. A test pins that an always_on
run's stored prompt response carries every wake under both stored keys.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sarah-chitty-1
sarah-chitty-1 requested a review from a team as a code owner December 1, 2026 18:39
Comment thread src/agent_env/task_step/context.py Resolved
…or a multi-turn step

Two kinds of step store one trajectory per turn in target_agent_per_turn_trajectory_object_urls: an always_on
step, one per wake, and a multi-turn prompt_agent step, one per turn (a user-sim conversation). The previous
commit made the download bar offer every turn, but as one button per turn, so a 20-turn conversation put 20
buttons in the bar.

The bar now has one entry per prompt response:
- A response with one trajectory keeps its label, tooltip and button exactly as before.
- A response whose turns stored several distinct trajectories gets a button that downloads its last turn,
  labelled "Trajectory (turn n of n)" (or "<step> (turn n of n)"), and a chevron that opens a turn picker
  listing every turn as "turn k of n". In the collapsed dropdown it is one row with the turns in a submenu.
- A Claude Code atif/1 run, whose turns share one document, still gets one plain button.

Both use the explorer's existing Radix Themes DropdownMenu. The collapse threshold now counts responses.

Tests: the bar smoke covers a single trajectory (unchanged), an always_on run of several wakes, a 20-turn
prompt_agent conversation beside a single-turn step, and atif shared turns; the trajectory-url smoke and the
`task run` CLI tests add a multi-turn prompt_agent case. No grader or score reads any of this.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sarah-chitty-1 sarah-chitty-1 changed the title fix(always_on): readers of a run's trajectory read every wake, not only the last fix: a multi-turn step's trajectory readers offer every turn, not only the last Dec 1, 2026
…un list's last entry

The bar's main button took the last entry of runTrajectoryUrls. An atif/1 run whose
middle turn's copy failed stores per-turn [A, B, A]; the de-duplicated list is
[A, B], so the button downloaded B while agent_trajectory_object_url is A. It now
downloads the response's own url (trajectoryUrl), labelled by the last turn that
stored it, falling back to the list's last entry when the response has none. The
picker still lists every distinct trajectory. A url the per-turn list lacks is
labelled "last available", not "last turn".

agent_trajectory_object_url is the last available trajectory, not always the last
turn's: both writers (always_on, prompt_agent) take the last turn that stored one.
Say so in PromptResponse, trajectory_object_urls() and the explorer's helpers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sarah-chitty-1 and others added 3 commits December 2, 2026 11:36
… as a nudge

An always_on step's per-turn lists hold a wake's nudge turn beside the wakes, so the bar's "turn k
of n" counted nudges and turn k wasn't wake k. Each turn's record (TurnTrajectory) now names its
wake and marks a nudge (wake, nudge), kept through a stored round trip. The bar labels a wake "wake
k of n" and a nudge "nudge after wake k", and the picker counts wakes. Other steps' turns, and runs
recorded before this, keep "turn k of n".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… and shows a shared one once

Review findings on the multi-turn trajectory readers:

- `task run` listed a run's trajectories with no turn numbers. The list skips turns that stored
  none, so for [w1, None, w3] the second url read as turn 2. Each line now names its turn, "turn
  k of n", with the wake on an always_on step ("wake j" / "nudge after wake j"), and "last
  available" for a response url the per-turn list lacks.
- One file had two turn labels. For per-turn [A, B, A] the bar's button placed A at its last turn
  ("turn 3 of 3") while runTrajectoryUrls kept its first ("turn 1 of 3"). An atif/1 document is
  rewritten each turn, so it holds its last turn's copy: runTrajectoryUrls and core both list a
  url several turns stored once, at the last such turn, in turn order, and the button reads its
  label from that list.
- The collapsed bar's "Download any of N files" / "Download Trajectories (N)" counted responses,
  not files; barDownloadFileCount counts a turn picker's turns.
- The trajectory viewer fanned a response out per turn with no dedupe: an atif/1 run of N turns
  rendered its one document N times. It now builds its sections with trajectorySections, one per
  distinct trajectory, a shared document's section holding each of its turns' trigger strips, and
  shows a response url the per-turn list lacks. Within a step, sections keep response order, then
  turn order.

Also: PromptResponse.trajectory_object_urls() is distinct_trajectory_object_urls(), returning
(turn, url) pairs (every caller is in this PR); its field comments name prompt_agent as well as
always_on; the bar's menu item and turn list are one component each and its buttons share one
class string; the smokes compare with isDeepStrictEqual, not JSON.stringify.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…by wake, as the bar does

The viewer still labelled every section "Turn k/n". On an always_on run the per-turn list holds
each wake's nudge beside the wakes, so turn k need not be wake k, and the bar beside it already
said "wake k of n". turnLabel moves from bar-downloads to trajectory-url, and the viewer names a
section's turn through it (sectionTurnLabel): "wake k of n", "nudge after wake k", "turn k of n"
for a step or run whose records name no wake, "last available" for a url the per-turn list lacks,
and nothing for a response of one section. Other steps' sections now read "turn k of n" too,
the bar's wording.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sarah-chitty-1
sarah-chitty-1 merged commit 2d92092 into main Dec 3, 2026
35 of 36 checks passed
@sarah-chitty-1
sarah-chitty-1 deleted the sarahchitty/always-on-per-wake-trajectories branch December 3, 2026 03:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants