Repository navigation
feat(task-steps): prompt steps keep each turn's atif/1 copy as its trajectory when the run prescribes it, and judges grade it - #854
Conversation
|
On hold until Claude Code serves atif/1 (Y5, FD-6079). No shipped agent has an ATIF adapter yet, so today a run that prescribes atif/1 falls back to native on every turn, and the switch this PR makes can't be exercised end to end. Once Y5 lands, this gets a parity test on tasks whose judges read the agent's trajectory ( |
|
A note for when this PR resumes after Y5 (#872), found while reviewing #872. Judge prompts would carry Claude Code's tool definitions. #872 fills
Proposed fix in this PR: drop Until then, this would show up in the planned parity test (Y4-12) as a cost difference and possibly a score difference between the native and atif/1 arms. |
… run prescribes it A run that prescribes atif/1 reads each solver turn's copy inline once the turn ends, off the turn's path, and stores it as <trajectory_id>.json in the run's folder for the agent, with its aux log, turn context and media; each turn's record says how it checked (valid, invalid, newer, unavailable), and a restart's next document is linked from the session's earlier one. Refs FD-6078. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… invalid, and media are checked against the profile The session names a new document only once the earlier one links to it, so a later turn retries a link that failed. A copy whose shape can't be walked is stored and recorded invalid by the validator's findings, rather than unavailable. A held media file whose profile sha256 or size disagrees with its name or the stored file is media-bytes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…he store A staged call whose answer is lost or refused still moves the objects the agent wrote into the store, as an upload through a grant does, so the atif/1 media pull finds a file the agent has already let go of. Names the atif/1 record's reason limit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…othing Only a call that may have reached the agent, its answer lost or refused, has staged writes to collect; one that couldn't connect fails at once rather than after collection's retries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tif/1 records, a shared prompt-step rig The validator takes files stored beside a document as StoredMedia and the reader exports media_refs, so the worker no longer re-walks a document's media or re-implements media-bytes. AtifCopies fills each turn's record itself; the atif_copies metadata and a record's status are typed; an agent's error code is read once (extension_error_code), so one the SDK wouldn't send isn't kept as a reason; invoke_transfer's send is its own function; prompt-step tests share prompt_agent_rig and tst/util/images. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
validate stops at a document whose schema ATIF's models reject, as a newer one's; validate_media gives the media-bytes findings alone for any document media_refs can walk, and the worker checks a copy's media with it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ative the fallback When the run prescribes atif/1 to an agent that offers it, each turn's copy fills the trajectory fields labelled atif/1 and no native read is made; a turn whose copy can't be had has its native trajectory read at once in its place (Y4-9, Y4-10). The per-turn record's native_format becomes format, and its atif record names the turn's task. always_on prescribes native only until it reads atif/1 copies (Y4-11), and the snapshot series keeps an atif/1 url out of its native rows. agentenv_protocol.atif.task_document cuts a turn out of a conversation's document as a document of its own. Judges' atif/1 readers come next. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…r label The rubric judges (direct and agent), their DEFAULT compaction, SCREENSHOT frames and per-criterion evidence, grade_up_to_turn and env_outcome's trajectory read each turn by its label: an atif/1 turn as its own A2A task cut out of the conversation's document, found by its id or, in a copy without the profile, by the step it reached, its media read from the document's folder and checked against their names; any other turn as native, byte for byte. A copy the turn can't be found in is graded as stored. Staging hashes media as they stream and keeps no bytes; frames are typed by their bytes; a sub-agent's screenshots count. env_outcome's verify may ask for each turn's label. The judge-input pin adds 14 atif/1 cases, its native ones unchanged. agentenv_protocol.atif.tasks_document cuts tasks found without ids. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ng, nested sub-agents count, and a screenshot keeps its type The judges' ATIF walkers skip what isn't a step, a result or a call, so an invalid copy graded as stored is read rather than failing the verifier, and staging finds no media in a shape it can't walk. A sub-agent reference resolves among its parent's own children before those around it, so a grandchild's calls and screenshots reach the judge. A screenshot's type read from its bytes reaches per-criterion frames (TrajectoryAction.screenshot_media_type), so GIF and WebP aren't sent as PNG. Names the adhoc run id's length, and tests a pinned image in a run that prescribes atif/1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… their schemas, as a native turn does Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
a5a2fb7 to
e0756a7
Compare
…eference where it sits A reference names a sub-agent embedded in its own trajectory, else the nearest one around where that trajectory sits. The cut followed references from the root's sub-agents' own steps only, so a reference from deeper in a kept one was dropped, and it read every reference against the root's array, keeping one a nearer sub-agent shadows. The judges' walkers resolved a sub-agent's references in the scope of whoever started it. The validator's resolver moves into the reader, and the cut and the walkers both follow it; a copy whose cut fails is read as stored. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ing, so it stops no judge's walk The walkers now build every trajectory's scope up front, so an invalid copy graded as stored with such an id anywhere, in a sub-agent nothing references too, raised where the lazy walk never looked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ith its calls, results, answer and screenshots Each recorded copy's turns, cut out as the judges cut them, give every tool call and result (a sub-agent's included), the final answer, and each screenshot as a frame whose bytes match its name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…judge's walk 6954cdb indexed a sub-agent's id once it passed the Hashable check, and a missing one, read as None, passed it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… its native trajectory read in its place Its judges would grade the turn without those files, screenshots among them, while the native trajectory still holds them. The record keeps the copy's status, rules and url; the turn's url and label are native's. When native can't be read either, the copy stays the turn's trajectory. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s events, so they aren't read as the main agent's The compaction placed a sub-agent's events after the result that started it with nothing to tell them apart. Found by a real run: a model judge read a sub-agent's Bash call as the main agent's, where the native turn's parent_tool_use_id told the same judge otherwise. Each of a sub-agent's events now names it as `subagent`, and the result that started it lists it in `starts_subagents`; a turn without sub-agents compacts as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Y4 PR 2 of 3 for FD-6078. When a run prescribes
atif/1(Y16, #849) to an agent that offers it, each prompt-step turn'satif/1copy is the turn's trajectory. It fills the trajectory fields readers already use, labelledatif/1, and the run's judges grade it. The requested format is best effort: a turn whose copy can't be had gets its native trajectory read in its place. A run that prescribes nothing is unchanged, byte for byte. Refs FD-6078, which stays open for PR 3 (always_on and the live follow).What changes
The trajectory (
task_step/snapshot_utils/atif_copies.py,prompt_agent.py)atif/1copy inline ({task_id, format}) and stores it, then the media.target_agent_per_turn_trajectory_object_urlsis the copy's document, andagent_trajectory_object_urlis the last turn's.target_agent_per_turn_trajectoriesis{format: "atif/1", atif: AtifRecord}.unavailablegets its native trajectory read at once in the same job, while the agent still holds it, labelled native. If that read fails too, the turn has no url, as a failed native read leaves it today.media-bytes) would have its judges grade the turn without those files, screenshots among them. Its native trajectory, which holds them, is read in its place the same way. The record keeps the copy's status, rules and url. If native can't be read either, the copy stays the turn's trajectory.atif/1stays native on each turn's path, as today: every shipped agent but Claude Code, which serves it since feat(agents): Claude Code serves atif/1, built live from its stream-json and session transcript #872. Its records sayunavailable,format_not_offered.atif: None.invalidornewercopy with all its media is still the turn's trajectory and is graded as stored.Storage, unchanged from the earlier review rounds
<trajectory_id>.jsonper conversation in the run's folder ({prefix}atif/instance_id=<id>/<agent>/, recorded inmetadata["atif_copies"]), overwritten each turn, so a conversation's turns share one url.turns/<message id>/.media/.continued_trajectory_ref.Per-turn records (
task_step/context.py)TurnTrajectory.native_formatis nowformat: the label of what the turn's url holds. A record stored withnative_format(from feat(task-steps): prompt steps read each turn's native trajectory by name and record its format #843, merged today) loads with it as its format.AtifRecordgainstask_id, the turn's A2A task in the document.Judges read each turn by its label (
verifiers/judge_utils/atif_turns.py,rubrics_verifier.py,env_outcome_verifier.py)atif/1turn is read as its own A2A task cut out of the conversation's document (agentenv_protocol.atif.task_document), a document ATIF's models load: steps numbered from 1, the root's sub-agents it reaches kept (and those a kept one reaches, from any depth inside it),final_metricsdropped. A reference resolves as the validator resolves it: by where it sits, in its own trajectory's sub-agents, else the nearest around it, and the judges' walkers follow the same rule. Each document is read once per judge. In a copy without the profile, which is valid ATIF with no task ids, the turn is the task ending at its record'sthrough_step. A copy neither finds it in is graded as stored.media/<64 hex>.<ext>, each checked against its name. A missing or mismatched file is logged and skipped.turn_NN.jsonper turn andmedia/beside it, plus a note on what the files are.===== Turn i =====markers.compact_otel_trajectory's event shapes. A sub-agent's events name it (subagent), as does the result that started it (starts_subagents), so a judge tells them from the main agent's, as a native Claude Code turn'sparent_tool_use_idlets it.grade_up_to_turncuts the records with the urls, so no later turn leaks.agent.tool_definitions(Claude Code since feat(agents): Claude Code serves atif/1, built live from its stream-json and session transcript #872), and a task with many MCP servers offers hundreds of tools: tens of thousands of tokens in every turn's view.trajectorygives anatif/1turn's view in the same list as today's native entries. A new opt-intrajectory_formatskeyword gives each turn's label.atif/1turn takes today's code, byte for byte.Also
task_document,tasks_document,media_refs,StoredMedia(a thirdmedia=form) andvalidate_media. The validator's reference resolver moves into the reader, where the cut uses it too. The worker's media check uses the protocol's.formats=()) until PR 3 makes it store and gradeatif/1copies (Y4-11).atif/1url out of its native rows.extension_error_codereads an agent's error code once and caps it.Decided with Edgar
atif/1to an agent whose card doesn't offer it recordsunavailable,format_not_offered.atif: Noneis kept for runs that don't prescribe it.atif/1read is inline, because the worker can't name<trajectory_id>.jsonbefore it reads the copy.atif/1copy, and its judges grade it. Before this, the plan kept native for judges until Y13's A/B regrade.Choices to review
[trajectories] formats, so setting it on a shared host changes every run there. The judge-input pin keeps native runs byte-identical and pins 14 newatif/1cases.format. The rename follows the field's new meaning: it labels what the url holds, which is no longer always native.atif/1to the same agent, always_on's conversations still build native only. Its judge reads PSI harness labels, which ATIF can't carry yet.Testing
test_prompt_agent_atif_copies.py, 28 tests): the copy as the trajectory with no native read; an agent that doesn't offeratif/1; a refused prescription falling back per turn; one turn's failed copy falling back while the others keep theirs; both reads failing; plus the storage, media, link, validation and safety cases from earlier rounds.judge_utils/test_atif_turns.py,test_rubrics_verifier_atif.py): per-label dispatch; cuts by id and by step; a copy graded as stored; media safety; staging that keeps no bytes; frames typed by their bytes; sub-agent screenshots; the direct, agent, compacted, screenshot and per-criterion judges;grade_up_to_turn; mixed responses; env_outcome's entries and labels.atif/1cases. Against the base, the golden diff only adds cases.task_document,tasks_document,media_refs,StoredMediaandvalidate_media. The protocol suite passes: 2,067 tests.task_step,a2a_agentand the protocol suite pass locally, 6,467 tests. The 4 failures are the known Mac-onlycomputer_exec_test.pyones.ruff check .passes.test_prompt_agent_live_trajectory_local.py's prescribed test checks that the turn's url is the stored copy and its labelatif/1, with the image stored beside it. Results from the test host are below.chaos_copies.py).unavailable. It also checks that an unprescribed run, or one with an agent that doesn't offeratif/1, reads native for every turn.task_step,a2a_agent,agentsand the protocol suite), 7,812 tests pass; the four failures are the known Mac-onlycomputer_exec_test.pyones. The chaos ran 10 minutes clean on the rebased branch: 4,987 seeds and 20,173 turns.atif/1, statusvalid, with 0 validator errors.test_claude_code_atif_recorded.py). Each of feat(agents): Claude Code serves atif/1, built live from its stream-json and session transcript #872's six recordings gives the judges every tool call and result, a sub-agent's included, the final answer, and each screenshot as a frame whose bytes match its name. The recorded turns are cut out as the judges cut them.referencefinding;unavailableor lacks media: it fails on 79851b0 and ran 2,494 seeds clean on the fix.atif/1, and each judge had a twin that a test-only hook, kept outside the repo, handed the same run's native trajectory, so any difference between a pair is the format's.desktopexample's computer-use task (screenshots);next-env-eventinbox week (4 turns woken by triggered emails, MCP tools);rubric_evidence;grade_up_to_turn; agent judges on the view and on its compaction; and anenv_outcomeverify that readstrajectoryandtrajectory_formats.parent_tool_use_idhad kept apart. The compaction now names a sub-agent's events (43b7571). On the fix, both sub-agent tasks' pairs agree on every row.transcript_from_raw) finds no actions in Claude Code's stream-json, which predates this PR.valid. Solver spend for these runs was about $1.50.task_step,agentsand the protocol suite, 7,553 passed; the four failures are the known Mac-only ones. At 6954cdb, the verifier and protocol suites passed, 3,163 tests; at 79851b0 the verifier suite passed, 1,072 tests, and the reference fuzz ran 25,189 more seeds clean.🤖 Generated with Claude Code


Confidence Score: 5/5
The PR appears safe to merge; no new blocking issue was found.Summary
Prompt steps can store prescribed
atif/1copies as their trajectories, and judges read each turn by its recorded format.Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Prompt turn ends] --> B{Prescribed and offered ATIF?} B -- No --> C[Read native trajectory] B -- Yes --> D[Collect ATIF copy and media] D --> E{Copy available with media?} E -- Yes --> F[Store ATIF as turn trajectory] E -- No --> C C --> G[Record turn format] F --> G G --> H[Judge reads each turn by format] H --> I[Compacted child events name their agent]Reviews (27) · Last reviewed commit: "fix(verifiers): a judge's compacted atif..." · Reviewed by Greptile