Repository navigation
feat(protocol): the SDK serves atif/1 from an agent's ATIF adapter - #807
Merged
Merged
Conversation
enable(TRAJECTORY_V1, native=..., atif=Adapter) adds atif/1 to the card's formats. The SDK keeps one document per A2A context, fed every event the agent appends and every aux record its code feeds, and serves atif/1 task, context, cursor and final reads, context reads an agent binds included. A task read is the document as it stood when the task ended, with its aux log and turn context; cursor pages carry the header and the sub-agents their steps reference. An adapter that raises stops its context's copy, not the turn. Part of FD-6076 (Y2b-1, -3, -5, -6, -7). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… far as each is served A sub-agent can gain steps after its spawning call's result, so a page carrying only the sub-agents its own steps reference could leave a reader with an early copy forever. A page now carries the sub-agents of every task its steps belong to; the page that serves a task's last step, which closes only as the task ends, carries them whole. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nned agents accept it TrajectoryWriteObjects gained optional aux and turn_context grants; dumped with their None values, they reached agents on an older protocol, whose request model forbids unknown fields, and every objects-form trajectory read got HTTP 400. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
earakely-scale
marked this pull request as ready for review
November 19, 2026 07:07
…sor header keeps final_metrics An aux handler that changed the record it was handed changed the served aux log, so replay could build another document: the log keeps its own copy, and a task's inbound content is a tuple. A cost reported for a whole task is on no step, so a cursor page's header now keeps final_metrics once no task is open, and pages rebuild the document whole. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d in the atif/1 copy - ServedTurn and AuxEntry (atif/served.py) are the shapes an atif/1 final read serves as turn_context and aux; RecordedTask.from_served validates them. - The copy maps steps and sub-agents to tasks through the builder (step_tasks, subagent_tasks), not by reading rendered profiles back. - One _guarded() context manager stops the copy on an adapter error. - _inbound and _final replace one function with an answer flag. - TrajectoryLog takes the adapter's spec; the appended-and-returned refusal no longer rides on aux bookkeeping. - The atif read path splits into _atif_events and _atif_document, and TaskTrajectories names its results (AtifTaskRead, AtifCursor). - The serving tests' toy agent plays named scenarios from a table. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
wire() left out every None, so a diagnostic DataPart whose data is null lost its required field and replay refused the turn. It now leaves out only optional fields at their default. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… are tested An agent that follows the env's clock runs its programs on the universe's time, while its A2A server stays on real time, so the SDK's own steps (each task's user step and final response) were stamped on another clock than the adapter's. They now take the time the agent's programs read: session_time() in the protocol's computer clock reads the follower's clock file, and a test pins it against clockpage.py's writer. Two messages sent at once in one context are now tested: the first is closed in the copy before the context's lock lets the second start, which an await added before the seal would break. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
The first of Y2b's three PRs for FD-6076: the agent SDK serves
atif/1beside an agent's native trajectory, built live from an ATIF adapter the agent names. Part of FD-6076. The turn index's persistence (Y2b-2) and scrubbing (Y2b-4) follow in their own PRs.What changes
enable(TRAJECTORY_V1, native=..., atif=MyAdapter)names an@atif_adapterclass for the native format. An adapter for another format, or one with nonative, is refused atenable. The card'sformatslistsatif/1beside the native format;defaultstays native.request.trajectory.aux(name, record)feeds the adapter's aux files: records that aren't in the native log, such as a hook's notes.framework.trajectory_appended_and_returned(Y2b-3). Agents without an adapter keep today's rule.session_idis the A2A context id, and a freshtrajectory_idnames each document.structured_output, are written as their compact JSON text. Other DataParts in the final response go in the last step's newdataprofile field.atif/1are served by the SDK, including context reads an agent binds to its own handler (Claude Code and Codex bind them). Every answer namesformat,schema_versionandprofile_version.aux, the task's aux log, andturn_context, its TurnContext and how it ended (Y2b-5, Y2b-7). The objects form takesauxandturn_contextas optional grants; other reads refuse them.step_id, each page with the document'sheaderand thesubagentsof its tasks.atif_unavailable; native reads are unaffected.agentenv_protocol.atif:ServedTurnandAuxEntry(atif/served.py) are the shapes the final read serves asturn_contextandaux.RecordedTask.from_servedvalidates them, soreplayrebuilds the served document offline.AdapterRun.document(through=k)gives the document as task k left it.dataanderrorare written atend_task.Choices to review
computer.clock.session_time()), so they match the adapter's steps. A test pins the reader againstclockpage.py's writer. Decided with Edgar in review.atif_unavailable. Each read of it names the adapter and its error. It stays stopped: an instance that starts partway rebuilds nothing (Decision 18).media/<sha256>.<ext>, sha256 and size. The SDK holds them in memory, and no read serves them. Y3 (FD-6077) delivers them: a disk-spooled cache, a push under a per-turn grant, and a media read the worker pulls through. Its grant channel and folder layout are still open there. Greptile flagged this; no bundled agent declares an adapter before then.atif/1before Y2b-4's PR lands.Testing
tests/test_a2a_atif_serving.py(24 tests) is a toy agent that offers native andatif/1. It covers:validate_live;tests/test_atif_builder.py(7 new tests, 13 cases):trajectory_id,document(through=), task data and error and their checks, the canceled spawn result, the served turn's round trip, and served shapes that break their models being refused.Integration: the echo agent (
tst/data/a2a_agent) now declares an ATIF adapter. The existing format test checks, against the agent deployed through agent-env:atif/1;atif/1task read validates, carries the turn context, and names the versions;These are assertions in an existing test, so CI time doesn't change.
Greptile's two P2s are fixed and covered by tests:
final_metrics, so a task-level cost survives the rebuild.All 1,956 protocol tests and the 1,261 agent and a2a_agent unit tests pass, and
ruff check .passes.Pinned agents still read:
TrajectoryWriteObjectsgained optional grants. agent-env now dumps a trajectory grant without itsNones (object_transfer.fetch_trajectory), because an agent on an older protocol refuses unknown fields.tst/unit/a2a_agent/object_transfer_test.pynow checks the grant names onlytrajectory. It fails without the fix.Chaos on an arm64 test host, 25 minutes, 7 workers (
chaos_serving.py, kept outside the repo). An agent app ran random turns: scripts of valid adapter ops and aux notes, ending in every way (completed, failed, raised, canceled, returned, appended and returned). A reader polled every read form at random moments, and 3% of turns carried a bad op. It checked:validate_liveagainst the final read;The run covered 149,626 seeds, 561,204 turns and 7,407,285 reads, with no failures. It found the sub-agent flaw described under Choices before the run, and caught two bugs I planted (a dropped aux log, an off-by-one cursor).
The integration test runs in CI's
integration-local, which passed. The arm64 host can't run the echo agent's amd64-only image.🤖 Generated with Claude Code


Confidence Score: 5/5
The reviewed changes appear safe to merge; no new blocking issue was found.Summary
The SDK serves
atif/1beside native trajectories, using one adapter per context and supporting task, context, cursor, and uploaded reads.Reviews (11) · Last reviewed commit: "fix(protocol): an atif/1 copy keeps one ..." · Reviewed by Greptile