Cause (case 2: 41 messages told to a new Claude Code at 02:40:00, minutes
after the last reply at 02:37:13, no stop log). Claude Code 2.1.290 asks
its prompt suggestion after each turn: the conversation so far, with the
turn's system prompt, tools and thinking, and one more user message,
"[SUGGESTION MODE: ...", with no system message after it. That request
goes on from the turn's reply, so resume handed it the conversation's
run, and ended kept the run waiting at the suggestion's reply. The user's
real next turn didn't follow the suggestion, found no run under its key,
and was told the whole conversation in a new run (88k tokens written to
the cache again). Nothing was logged because nothing ended.
Fix. ended keeps, beside the run's new key, the key it went on from
(behindKey) and the turn's uuid (behindTurn). resume, finding no run
under a turn's key, takes one whose behindKey is that key, rewinds it to
behindTurn (rewind_conversation, as letGo does), marks it rewound so it
isn't shelved, and tells it only the turn's messages. A run that can't be
rewound is let go and the turn told whole to a new run, as before.
Logging. A turn after a reply that starts a new run logs "claude: no run
waits for this turn: <why>" (whyNoRun): it went on with a turn this one
doesn't follow, waits under another key (model, settings, system prompt
or tools differ), waits at an earlier turn, is busy, ended (how long ago
and why: abortFor's reason, or how Claude Code exited), or no run here
had the conversation. "tool results no run waiting" now adds "the run
that made the calls ended Xs ago: <why>" (whyCallsLost).
Case 1 (499 mid-reply, then "tool results no run waiting" and 17 messages
told) is not fixed. The run that answered had been started anew for that
turn, so letGo has no earlier user message to rewind to, and its results
were already handed to it over MCP. Keeping its cache would mean rewinding
to Claude Code's own tool_result message and telling the results again as
text, or interrupting instead of ending the run; neither can be checked
without the reporter's request shapes, and a fork that took the lead's
calls (claimResume) looks the same from here. The new log line says which
run ended and why, so the next report can tell.
Tests (claude_side_question_test.go), with 2.1.290's request shapes
(billing line with changing cch, 1h cache_control, adaptive thinking,
output_config effort, context_management, system messages, signed
thinking sent back):
- TestClaudeSideQuestionKeepsTheConversationsRun: turn, turn, suggestion,
real turn go to one Claude Code (turn 4), rewound to the suggestion's
uuid, told only the new message; twice. Red with the take-back disabled
("went to another Claude Code: pid ... turn 1").
- TestClaudeSideQuestionNotRewound: a run refusing the rewind is let go,
the turn goes to a new run, 1 run left. Red with the fix disabled (2 runs).
- TestClaudeNoRunSaysWhy (gone / another key) and
TestClaudeToolResultsNoRunSaysWhy: red with the log line, or the
lostCalls record, removed by hand.
Run:
- the new tests -race -count=5: ok
- real e2e: the real 2.1.290 client in -p --prompt-suggestions against
the bridge, whose Claude Code was the real 2.1.290 too, both against a
local mock of Anthropic: one bridge run for the whole session, "taken
back from the side question" logged after each suggestion, 0 runs told
the whole conversation; the real turn's request to the mock went on
from the reply before the suggestion, without it.
- gofmt -l .: clean; go vet ./..., GOOS=linux go vet -tags nogui ./...,
GOOS=windows go vet ./...: ok
- set -o pipefail; go test -tags nogui ./... at load average ~45-53:
every package ok but agent, gateway, library, plugin and provider, which
hit go test's 10m default. Rerun with -timeout 40m -p 2: agent, library,
plugin ok; gateway red only in TestOTelWaterfallIncludesUnbilledFallback
and TestOTelWaterfallFailureAndCancellation (#1794, already filed: they
read only the first OTel export; -count=10 alone passes); provider red
only in TestCopilotSecretToolUsername (#1627, already filed; red 1 of 5
alone under load, then 5 of 5 green). Neither touches this change.
- the new tests with the bridge's neighbours (LetGo, TurnGivenUpOn,
ToolResultsGivenUpOn, Idle, EndedRunSaysWhy, ForksAnswering) -race
-count=5: ok
Not tried: the real Claude subscription upstream, the interactive TUI
(the -p flag turns on the same suggestion), other side requests
(extract_memories, away_summary, /btw), case 1's actual requests.