Repository navigation
feat(snapshot): report a save's file count and phase durations, and log each save - #697
Draft
andrewpark-scaleai wants to merge 2 commits into
Draft
andrewpark-scaleai wants to merge 2 commits into
andrewpark-scaleai wants to merge 2 commits into
Conversation
added 2 commits
November 15, 2026 07:57
…s in agent-env's logs
…og each save The save response gains optional stats. claude-code fills them, and capture_workspace logs snapshot_save_completed with them and the workspace archive's size, or snapshot_save_timeout with the wait.
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.
Why
The goal is that every failure of an agent run leaves enough in the logs to debug it, and that code heals what it can. When a
snapshot_agent_statesave is slow, agent-env's logs cannot say why. The agent logs its archive's file count and size, but that line stays in the sandbox. agent-env logs nothing about the save on success, and only the exception on a timeout. So a slow save cannot be told apart as "the workspace is big", "archiving is slow" or "the upload is slow" without reaching into a live sandbox.What changed
ObjectSnapshotSaveResponsegains an optionalstatsfield:file_count,archive_secondsandupload_seconds(SnapshotSaveStats). The claude-code agent fills it.capture_workspacelogsevent=snapshot_save_completedwithagent_name,context_id,elapsed_seconds,timeout_seconds,workspace_archive_bytes(from the uploaded object) and the three stats.event=snapshot_save_timeoutwith the elapsed time, the budget and the workspace grant's cap, then re-raises.Design decisions
statslogs them asnull. The card now listsstatsunder the response's optional fields.>=0.1.551). The agent's own handler validates its answer against the installed protocol, which rejects unknown fields. A release publishes the protocol before it builds the image, so a released image gets the field. If a release lands before this merges, raise the floor to that next release.Scope
stats. Other agents keep their current answers and lognullstats.Blast Radius
Adds two log lines per save and one optional response field. It changes the advertised snapshot/v1 card (an added optional field) and the claude-code image's protocol floor. No control flow changes.
Verification
PYTHONPATH=src:packages/agentenv-protocol/src:. .venv/bin/python -m pytest tst/unit/task_step/test_agent_state_capture.py tst/unit/agents/claude_code/test_workspace_snapshot.py -q: 42 passed. Without the source commit, 5 fail: nosnapshot_save_completedorsnapshot_save_timeoutrecord, and nostatsin the agent's answer or card.tst/unit/agents,tst/unit/a2a_agentand the snapshot step tests: 1336 passed and 2 card assertions failed, which now expectstats(44 passed in their files). Protocol package tests (packages/agentenv-protocol/tests): 1626 passed, 1 skipped.@event:snapshot_save_completedand@event:snapshot_save_timeout. Completed lines from claude-code agents should carry non-nullfile_count,archive_secondsandupload_seconds.