Skip to content

Save each checkpoint's own stdout and stderr after a crash or retry - #37

Open
robo-carver wants to merge 2 commits into
SprocketLab:mainfrom
robo-carver:claude-code-stdout-keeps-stream
Open

robo-carver wants to merge 2 commits into
SprocketLab:mainfrom
robo-carver:claude-code-stdout-keeps-stream

Conversation

@robo-carver

@robo-carver robo-carver commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

Fixes #36.

_write_artifacts() writes stdout.jsonl and stderr.log from final_result, which only a finished _run() sets and nothing clears. When _run() raises mid-stream, the checkpoint saves the previous checkpoint's output and the lines that caused the crash are lost. A retry also replaces the output of the attempt it retried. Details are in the issue.

Two commits. The first adds TestStreamTranscriptArtifacts and fails on main, 2 of 2. The second records each stdout line as _run() parses it and writes stdout.jsonl from those lines, so a crash leaves its partial stream and a retry appends to the attempt before it. It collects each finished process's stderr the same way, so stderr.log keeps every attempt too. That was the last use of final_result, so the field is gone. A crashed checkpoint writes no stderr.log where it used to write another checkpoint's. 24 lines in agent.py.

One behavior change. A process that prints nothing to stdout or stderr now writes no file for that stream, where main writes an empty one. Nothing in src/ reads either file.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LneU62tU8gzRdn2GCE8arW

@robo-carver
robo-carver force-pushed the claude-code-stdout-keeps-stream branch 3 times, most recently from f69f506 to 813c66f Compare September 19, 2026 01:27
@robo-carver
robo-carver marked this pull request as ready for review September 19, 2026 01:36
@robo-carver
robo-carver force-pushed the claude-code-stdout-keeps-stream branch from 813c66f to 9e0f522 Compare September 19, 2026 01:39
@robo-carver robo-carver changed the title Keep a crashed checkpoint's own stream in stdout.jsonl Save each checkpoint's own stdout and stderr after a crash or retry Sep 19, 2026
robo-carver and others added 2 commits September 18, 2026 18:40
Two cases. A checkpoint whose _run() raises mid-stream should save the
lines it streamed before the crash, and no stderr.log. A process that times
out and is retried should save both attempts' stdout and stderr in order.

Both fail until the next commit. The crashed checkpoint saves the previous
checkpoint's stdout, and the retry saves only its own attempt.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LneU62tU8gzRdn2GCE8arW
_write_artifacts() wrote stdout.jsonl and stderr.log from final_result,
which only a finished _run() sets and nothing clears. When _run() raised
mid-stream, the checkpoint saved the previous checkpoint's stdout and
stderr, and the lines that caused the crash were lost. A retry also
replaced the output of the attempt it retried.

Record each stdout line as _run() parses it and write stdout.jsonl from
those lines. A crash now leaves its partial stream, and a retry appends to
the attempt before it. Collect each finished process's stderr the same way.
That was final_result's last use, so remove it, and run() clears both
lists. A crashed checkpoint writes no stderr.log instead of another
checkpoint's. A process that printed nothing to a stream writes no file
for it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LneU62tU8gzRdn2GCE8arW
@robo-carver
robo-carver force-pushed the claude-code-stdout-keeps-stream branch from 9e0f522 to 3d2ac94 Compare September 19, 2026 01:41
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.

bug: ClaudeCodeAgent saves the previous checkpoint's stdout.jsonl when a checkpoint crashes

1 participant