fix(claude): between-turn status and resume handshake no longer touch the turn lifecycle - #265
Merged
Merged
Conversation
… the turn lifecycle
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Baseline: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
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.
Problem
Two Claude Code SDK messages that are not part of any turn were being projected as turn lifecycle, and both were traced from the nightly database and provider logs on 2026-09-04:
system/statusbetween turns. When a background task finishes, the CLI re-invokes the model and reportsstatus: requestingbefore any assistant output. The adapter mapped that tosession.state.changed: runningwith no turn id, so the projected session sat inrunningwith no active turn, sometimes for hours. The sidebar showed "Working" for an idle thread, and until fix(server): steer a turn only when one is actually running #264 the next message was admitted as a steer into nothing.system/initplusresult(num_turns: 0). When that landed after the user's first prompt was already in flight, the adapter completed the user's turn after two seconds with no output. The actual answer then arrived as a synthetic turn. In the incident the visible turn showed nothing and the real work ran hidden.Fix
case "status"emits a lifecycle event only while a turn is open. Between turns it is the CLI's own request cycle, and the assistant output that follows opens its own synthetic turn.handleResultMessageignores a zero-turn success result when the open turn has produced no items, no assistant text, and has no tool in flight. A real turn always makes at least one request, so that shape can only be the handshake. Failed or non-empty results complete as before. A log line (claude.turn.handshake-result-inside-turn) keeps the trigger measurable.Upstream has identical code on both paths, so this is Pylon getting ahead rather than catching up. Upstream's #9135 (SDK 0.3.260, terminal-reason failure handling) is unrelated and still worth adopting through the upstream batch.
Verification
vp test runonClaudeAdapter.test.ts: 85 passed.vp run -F t3 typecheck: clean.vp fmt --checkandvp linton the touched files: clean.Companion PRs: #264 (decider no longer steers unadmitted turns) and the follow-up that admits provider-initiated turns in ingestion.
Model: Claude Fable 5.1. Harness: Pylon (Claude Code provider).
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.