Repository navigation
feat(task-steps): prompt steps store each turn's atif/1 copy when the run prescribes it - #854
Open
earakely-scale wants to merge 3 commits into
Open
earakely-scale wants to merge 3 commits into
earakely-scale wants to merge 3 commits into
Conversation
… 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>
earakely-scale
marked this pull request as ready for review
November 20, 2026 23:03
… 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>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Y4 PR 2 of 3 for FD-6078. When the run prescribes
atif/1(Y16, #849), a prompt step stores each solver turn'satif/1copy beside its native one, with its aux log, turn context and media, checks it, and records how it checked. Judges keep reading native. Refs FD-6078, which stays open for PR 3 (always_on and the live follow).What changes
task_step/snapshot_utils/atif_copies.py,AtifCopies). Once a turn ends, a prompt step whose run prescribesatif/1reads that task'satif/1document, and it does so only then.{task_id, format: "atif/1"}), with the 600 s transfer timeout (Y4-8). The answer carries the document, the aux log and the turn context.<trajectory_id>.jsonin the run's folder for the agent,{prefix}atif/instance_id=<id>/<agent>/, and overwrites it each turn (Y4-2). That folder is recorded inmetadata["atif_copies"]. A run with no instance id gets oneadhoc-<uuid12>for all its agents (Y3-2).turns/<message id>/aux.jsonandturn_context.json, named by the id the native copy is stored under.media/once per step.missingorfailedfor, or whose push answer was lost, is looked up in the store before it counts as missing. A repeat pull asks only for what the store lacks.media-bytesalso flags a profile whose sha256 isn't the file's name, or whose size isn't the stored file's.a2a_agent/object_transfer.py,invoke_transfer). A staged call that fails after it's sent, its answer lost or refused, still pulls what the agent wrote before the staging is released. An upload through a grant already reaches the store whether or not its answer arrives.pullskips what the agent didn't write, and a failure there is logged so the call's own error is the one raised. Without this, a media push whose answer was lost on the staging route would lose files the agent had already let go of.AtifRecordintask_step/context.py). Each turn'starget_agent_per_turn_trajectoriesentry now fillsatifwith{url, through_step, status, rules, reason, validator_version, adapter_version, aux_url, turn_context_url}.valid: the producer's check, plus media, found nothing.invalid: the copy is kept,ruleslists the rule ids it broke, andreasongives the first. A media file still missing after the pull counts undermedia-bytes. A document whose shape can't be walked (saysteps: [null]) is stored too, recorded with the validator's rules, its media and session left alone.newer: the schema or profile version is newer than the worker's, so it's checked only as a reader would, with those rules.unavailable:reasonsays why. It's the agent's error code when it gives one (format_not_prescribedfor a conversation started unprescribed, per PF-4). Otherwise it'shttp_<status>,timeout,unreachable,no_document,invalid_trajectory_id, or the error's class.atifisNoneonly when the run doesn't prescribeatif/1. Prescribed to an agent whose card doesn't offer it, a turn's record isunavailablewithformat_not_offered(Y4-7), so one turn's record shows whether the run asked and whether it got it.continued_trajectory_refon the session's earlier stored document to<new id>.json. The agent that wrote the earlier one may be gone. The session names the new document only once that's done, so a link that fails is made by a later turn.unavailablerecord, with a warning.[trajectories]bullet and the config template's comment cover the stored copies.Choices to review
trajectory_idbefore it reads, and a grant to a guessed name could overwrite the earlier document a restart leaves. Native reads keep the objects form.[A-Za-z0-9][A-Za-z0-9._-]{0,127}. Anything else isunavailable,invalid_trajectory_id, and nothing is written.media-bytescheck is that the folder holds each file, not that it re-hashes them. Stored copies still validate with--media, as the tests check.formatsgets today's native request (Y4-6), and itsatifrecord isunavailable,format_not_offered(Y4-7). In a run that doesn't prescribe, it'sNone, as before.unavailable,format_not_prescribed. The next step prescribes again, and its copies link from the earlier document. Keeping the prescription across a restart, as the turn counts are kept, would be an SDK change for later.invoke_transferfor every staged call, not only the media push. A failed snapshot save or trajectory get on the staging route now leaves in the store what the agent had written, as the same call through a grant already does.metadata["trajectory_formats"]entry (prescribedbesidebuilt: None) and its warning say the run asked and the agent can't build it.validator_versionis the installedagentenv-framework-protocolversion.adapter_versionis the copy's ownextra.agentenv.adapter.version.Testing
Unit tests, new in
tst/unit/task_step/test_prompt_agent_atif_copies.py: 20 tests. A prompt step runs against an in-process SDK agent whose adapter puts a screenshot in each turn, and whose uploads land in a granting local store. They cover:format_not_offered;format_not_prescribedafter a failed prescription;invalidwith its rules;newer, by schema and by profile version;media-byteswhen the card lists no media push;atif/1read is still held;invalid;And in
staging_test.py: a staged trajectory get whose answer is lost still leaves the agent's object in the store, in both staging variants. Each of the last four fails on the code before the fix.Planted bugs. Each of these fails at least one test:
Noneinstead offormat_not_offered;The judge-input pin. Its "with records" form now also stores an
atif/1copy in the run's folder, fills each turn'satifrecord and recordsatif_copies. All 18 cases still match the golden file.Existing tests. The prescribe test now expects the step's own
atif/1read. Locally the related unit folders pass (task_step,a2a_agent,openenv,task,config: 5,280 tests). The 4 failures are the known Mac-onlycomputer_exec_test.pyones.ruff check .passes.Integration.
test_prompt_agent_live_trajectory_local.py's format test now sends the deployed echo agent an image with its prompt. It checks that the turn's record isvalid, that the stored document is the one served, that the turn context is stored, and that the image's file sits in the folder and validates. No new test, so CI time doesn't grow. On an amd64 test host the file's 5 tests pass, at 80fc681 (73 s) and again at e76cb71 (61 s).Chaos (
chaos_copies.py): real prompt steps against an in-process agent.atif/1or native only, with or without the media push, and is sometimes restarted between steps.newercopies' media and links.🤖 Generated with Claude Code


Confidence Score: 5/5
The PR appears safe to merge, with the earlier non-blocking gap for agents without a trajectory extension still present.Summary
Prescribed prompt steps save each turn's
atif/1copy, media, and check results beside the native trajectory.atif/1copy when the run prescribes it.atif/1copies include and check the media their documents name.Diagram
%%{init: {'theme': 'neutral'}}%% flowchart LR A[Solver turn ends] --> B[Store native trajectory] B --> C[Ask user for next message] B --> D[Queue ATIF copy] D --> E[Read document and collect media] E --> F[Check and store turn record] F --> G[Wait before saving prompt response]Reviews (4) · Last reviewed commit: "fix(a2a-agent): what an agent staged bef..." · Reviewed by Greptile