Repository navigation
feat(a2a-agent): an atif/1 copy's media files wait on the agent's disk until the worker pulls them - #834
Merged
Conversation
…k until the worker pulls them An agent that serves atif/1 spools each media file its copies name to its disk, one file per sha256, instead of holding the bytes in memory, with a PNG, JPEG, GIF or WebP image's width and height read from its header when the adapter gives none. The trajectory extension gains a media call, listed on such an agent's card: given a context and an exact-object write grant per media/<sha256>.<ext> path, it uploads each file the context holds, 8 at a time, checking each upload against its name, and answers what it uploaded, the paths it holds no file for and the uploads that failed. An uploaded file leaves the disk, as do a context's files when it is evicted or restored over, and the rest when the server stops. atif.media_file and check_media take a part path only as media/<sha256>.<ext> and only with the bytes that name, and the scrub never takes a media file's name in a grant's URL for its token. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…k what they send - The media call is served by the SDK alone (`OperationDefinition.sdk_only`): an agent that serves its own trajectory reads keeps it, and binding it is refused. - Each spool hold has its own number, so an upload that outlives its context's copy releases only the hold it began with. - A spooled file is hashed before its upload; one that no longer matches its name is reported failed and never reaches the store. - A WebP header too short for its size fields gives no size. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…he copy goes on A write that failed, on a full disk say, raised in the copy's guard and stopped the context's atif/1 copy for good, naming the adapter. The spool now logs it and keeps no file, so a push reports that path missing, as the validator's media rule does, and later files still spool. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…dia name and file hash are written once - MediaSpool.push uploads a context's files and builds the answer, so hold numbers stay inside the spool; the framework's media handler only calls it. - atif.reader.MEDIA_NAME is the one media file-name pattern; MEDIA_PATH and the scrub use it. - transfers.sha256_file is the one file hash, used by the spool and the browser's downloads; website_browser keeps exporting HASH_CHUNK_BYTES. - Two comments that repeated a docstring are gone; the media tests read the spool through a helper and its folder property, and a test covers the upload's own checksum. 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.
Y3 for FD-6077: an
atif/1copy's media files wait on the agent's disk until the worker pulls them at each turn's end. This is the SDK half only (Y3-8). The run's folder, the pull helper and theatif/1fetch that calls it land with Y4 (FD-6078), so each piece lands with its caller. Closes FD-6077.What changes
a2a_agent/_media_spool.py). An agent that servesatif/1writes each media file its copies name (media/<sha256>.<ext>) to its disk, one file per sha256, instead of keeping the bytes in memory for the context's life.missing, and the copy goes on.atif/_image_size.py). A PNG, JPEG, GIF or WebP image's width and height are read from its header when the adapter gives none (Y3-6).agentextra still has no Pillow.mediacall on the trajectory extension (POST /ext/trajectory/media). It is listed on the card only of an agent that servesatif/1; old agents and native-only agents never get it.{context_id, objects: {path: write grant}}and uploads each file that context holds under its exact-object grant, 8 at a time, checking each upload against the file's name. The spool does the uploading (MediaSpool.push), so its hold numbers stay inside it, and the framework's handler only calls it.objects(what it uploaded),missing(paths the context holds no file for) andfailed(uploads that failed, with why). Neither of the last two stops the rest.media/<64 hex>.<ext>paths are accepted.OperationDefinition.sdk_only). An agent that serves its own trajectory reads keeps it, and binding it is refused.failedand never reaches the store.atif.media_filetakes a part path only asmedia/<sha256>.<ext>in the document's own folder, never another path or a URL.atif.check_mediarefuses bytes that don't match their name. The validator now shares the same pattern..../media/<sha256>.png). The scrub then redacted every copy's media paths. A media file's name is never taken for a token now. Chaos found this as soon as it pushed media.atif.reader.MEDIA_NAMEis the one media file-name pattern (MEDIA_PATHand the scrub use it), andtransfers.sha256_fileis the one file hash (the spool and the browser's downloads use it;website_browserstill exportsHASH_CHUNK_BYTES).Choices to review
TMPDIR, so where/tmpis a memory filesystem the files sit in memory.missingorfailedfor a file already stored. FD-6078 now requires its pull helper to check the store first.get. It used to run on every trajectory call, and the media call carries no format.Testing
tests/test_a2a_atif_media.py(28 tests):TRAJECTORY_V1.getstill starts and servesmedia, and bindingmediais refused;atif/1listsmedia;Removing the spool, the header sizes, the release, the drop on eviction, the
sdk_onlyrefusal or its exemption from the override rule, the hold numbers, the pre-upload hash, the WebP length guard or the spool's write guard fails them.Integration: a new test in
test_prompt_agent_live_trajectory_local.py.atif/1copy's media path.mediacall.Serving chaos (the Y2b harness): after every task's final read it pushes the copy's new media and checks:
60 s locally at c7b8dc8: 4,095 seeds, and at 9243aaf: 4,929 seeds, no failures. 20 min on an x86 test host at c7b8dc8: 83,560 seeds, 313,159 tasks, 4.09M reads, 31,214 restarts and 31,152 restores, no failures.
On the test host at c7b8dc8, the live-trajectory integration tests pass (5/5, the media push among them). 2343d57 only names a constant. At 2500a2d (the spool's write guard), the same integration tests pass (5/5), and 5 min of chaos ran 21,229 seeds, 79,963 tasks and 1.05M reads with no failures.
All 2,035 protocol tests pass, and
ruff check .passes. Fourtst/unit/task_step/computer_exec_test.pytests fail on macOS only, because BSDbase64has other flags. They don't involve this change, and CI runs them on Linux.🤖 Generated with Claude Code


Confidence Score: 5/5
The changes since the previous review appear safe to merge.Summary
Adds disk-backed media storage and an SDK upload endpoint for agents serving
atif/1. The latest changes move uploads intoMediaSpooland share file hashing and media-name checks.No new actionable issues found. The earlier findings remain fixed.
Reviews (9) · Last reviewed commit: "refactor(a2a_agent): the spool pushes it..." · Reviewed by Greptile