Repository navigation
Replay forks under a live session's system prompt and tools - #6582
Merged
Merged
Conversation
The fork eval's replay sent `claude -p`'s headless prefix: the Agent SDK identity line, a 4,300-character system prompt and 11 tools. A live fork resends an interactive session's: Claude Code's CLI identity line, about 17,600 characters and the session's tools. Claude Code records a conversation's prefix as a `prompt_snapshot` and resends a recorded one verbatim on resume (`--system-prompt-snapshot`, on by default in 2.1.329), so the replay now copies the last snapshot of the newest interactive session on the machine into the case's transcript, after the first prompt, and pins it in the run's samples directory so every arm resends the same one. Captured `/v1/messages` bodies show the interactive identity line, the session's system prompt and its tools, then the case's turns and the prompt. `--exclude-dynamic-system-prompt-sections` goes: under a snapshot it changed nothing in the request. Max picked "the exact request on my login". The option proposed Promptfoo's `anthropic:messages` with the token from Claude Code's keychain entry; Claude Code's own resend gives the same request without another client handling the token. Measured 2026-11-19, on `source-edited` under the line fork prompt before #6477, 12 runs per cell, counting forks that hand the page-source read to the session (live forks on three journey sessions' conversations: 29 of 60): - headless prefix, date after the prompt (the replay before): 1 of 12 - headless prefix, date at the session's start: 3 of 12 - live prefix, date after the prompt (the replay now): 7 of 12 - live prefix, date at the session's start: 4 of 12 The prefix decides it: live 11 of 24 against headless 4 of 24 (Fisher p = 0.06), and with the earlier headless runs (7 of 22) headless 11 of 46 against live forks' 29 of 60 (p = 0.015), live 11 of 24 against them (p = 1.0). Where the date line sits makes no difference (7 of 24 against 8 of 24). Today's date stays after the prompt. With it at the session's start, all 35 fork cases with their judges scored 32 of 35: ask-step-done and ask-follow-up read the cases' 3 November dates as stale. With it after the prompt, 34 of 35, against 35 of 35 for the replay before, run beside it. The one failure is ask-question's judge, on the form of the ask's text (the question not on a line of its own, or prose going through each option). Over that run and six more of the case on each replay, the live prefix's asks failed it 6 times of 8 and the headless replay's 2 of 7 (p = 0.13), so the live prefix may change how the turn-end fork words an ask. The live prefix raises a case's input from 24,600 to 39,900 tokens, mostly cache reads; the 35 cases cost $3.16 at list prices against $2.89. Fixes a hook line that directly follows another record without a message: it now takes its event from the nearest record with one. Codex reviewed the change. Tests: the fork replay smoke tests.
leaf-agent
approved these changes
Nov 20, 2026
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 fork eval's replay now sends the request a live fork sends, apart from one date line: Claude Code's interactive identity line, system prompt and tools, then the case's turns and the fork's prompt. Before,
claude -psent its headless prefix (the Agent SDK identity line, a 4,300-character system prompt, 11 tools). Claude Code records a conversation's prefix as aprompt_snapshotand resends it verbatim on resume, so the replay copies the last snapshot of the newest interactive session on the machine into the case's transcript and pins it for the run, so every arm resends the same one.On
source-editedunder the line fork prompt before #6477, the one judgment where the replay and live forks disagreed, the live prefix hands the page-source read to the session 11 times of 24 against live forks' 29 of 60; the headless replay did 11 of 46 (p = 0.015 against live forks). Where today's date sits doesn't change it, and at the session's start it made two turn-end cases read their own dates as stale, so it stays after the prompt.To weigh: all 35 fork cases with judges pass 34 of 35 against 35 of 35 before. The miss is ask-question's judge on the form of the ask's text, which the live prefix failed 6 of 8 times against 2 of 7 (p = 0.13). The prefix comes from the user's own newest session, so a background job's prompt and a foreground session's differ between runs; each sample records which session it used. A case costs about 10% more.
Max picked sending the live fork's request on his login; Claude Code sends it, so no other client reads the login's token. Codex reviewed it. Tests: the fork replay smoke tests.