Skip to content

feat(claude-code): report a snapshot save's file count and phase durations - #711

Draft
andrewpark-scaleai wants to merge 3 commits into
andrew-park/rel-snapshot-save-telemetryfrom
andrew-park/rel-claude-code-snapshot-save-stats
Draft

andrewpark-scaleai wants to merge 3 commits into
andrew-park/rel-snapshot-save-telemetryfrom
andrew-park/rel-claude-code-snapshot-save-stats

Conversation

@andrewpark-scaleai

Copy link
Copy Markdown
Contributor

Stacked on #697 (base is that branch, not main). Waits for the protocol release that contains #697. Do not mark ready before that release is on PyPI.

Why

The goal is that every failure of an agent run leaves enough in the logs to debug it. #697 adds an optional stats field to the snapshot save response and makes agent-env log it. This PR makes the claude-code agent fill it, so a slow save says whether archiving or uploading took the time.

What

  • save_snapshot times the archive and upload phases and returns stats: file_count, archive_seconds, upload_seconds. Its own log line names both durations.

Why this is a separate PR

The claude-code image installs agentenv-framework-protocol from PyPI at or above the floor in its requirements.txt, not from this tree. CONTRIBUTING.md and AGENTS.md say an agent's floor rises only once the protocol it names is published. The agent validates its answer against its installed protocol, and the published one (0.1.556 and earlier) has no stats field and rejects it, so this code cannot run in the image until a release carries #697. Shipping it with #697 broke the claude-code image build. I kept it out of #697 rather than adding a shim that would exist only to straddle one release.

Before marking ready: raise the floor in src/agent_env/agents/agents/claude-code/requirements.txt to the first published release that contains #697, and update tst/unit/agents/claude_code/test_image_contract.py to match. Until then the floor stays at >=0.1.351, and this PR's claude-code snapshot integration tests are expected to fail.

How to verify

uv run --extra dev pytest tst/unit/agents/claude_code/test_workspace_snapshot.py tst/unit/agents/claude_code/test_object_transfer.py tst/unit/agents/claude_code/test_card_contract.py tst/unit/agents/claude_code/test_image_contract.py -q

Result: 40 passed. test_save_trims_an_incomplete_tail_takes_no_lock_and_uploads_the_bundle pins the stats the agent returns, and test_a_snapshot_saves_and_loads_through_grants pins that the answer carries them.

Ubuntu and others added 3 commits November 16, 2026 18:00
…s in agent-env's logs

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
… logs each save

ObjectSnapshotSaveResponse gains an optional stats field: the archived file count and
the seconds the agent spent archiving and uploading. capture_workspace logs
snapshot_save_completed with the workspace archive's size and those stats, or
snapshot_save_timeout with how long it waited. An agent that sends no stats still
logs its size, with the stats fields empty.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…tions

The save response's stats carry the archived file count and the seconds the agent
spent archiving and uploading, so agent-env logs them, and the agent's own log line
names both durations.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant