fix(server): port Claude phantom-turn and Codex queued-follow-up fixes from t3code nightly - #130
Conversation
Port of upstream pingdotgg/t3code#5710. A Claude SDK result arriving with no local turn state (the resume handshake system/init + result(num_turns:0), a late result for a locally-completed turn, or a stream failure with no turn in flight) emitted a turn.completed carrying no turnId. Ingestion could not attribute it, and whenever the projection had no active turn — a pending turn start included — it flipped the session lifecycle for a turn that never ran. Keep the token-usage emission, drop the untargeted lifecycle event, and log claude.turn.result-without-active-turn as a field-measurable tripwire. Ingestion now accepts a no-active-turn completion only when it names its turn. Closes neokod's documented SDK no-turn-id residual.
Port of upstream pingdotgg/t3code#5762. Codex accepts a follow-up while the current turn is still running; the turn/start response carries the queued turn id, but turn/interrupt only accepts the id that is active now. sendTurn unconditionally overwrote activeTurnId with the queued id, so a stop request targeted the wrong turn and Codex rejected the interrupt. Keep the existing active id until turn-lifecycle notifications advance it (updateSession gains a functional-updater form to read the current session).
|
Warning Review limit reached
Next review available in: 51 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…r-fixes # Conflicts: # apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.test.ts
Summary
Ports two clean upstream
fix(server)bug fixes from the latest t3code nightly into neokod. Both bugs were confirmed present in neokod (the affected code was byte-identical to upstream's pre-fix state), and both ports are localized.2c6e4c0ef, ports fix(server): stop Claude resume handshakes from completing turns that never ran pingdotgg/t3code#5710): a Claude SDKresultwith no local turn state emitted aturn.completedcarrying noturnId, which ingestion couldn't attribute — and whenever the projection had no active turn (a pending turn start included) it flipped the session lifecycle for a turn that never ran. Now the token-usage emission is kept, the untargeted lifecycle event is dropped, and aclaude.turn.result-without-active-turnlog keeps the trigger measurable; ingestion accepts a no-active-turn completion only when it names its turn. This closes neokod's own documented "SDK no-turn-id residual" from the earlier stop-settles-turn work.d6a20b0b1, ports fix(server): stop Codex threads with queued follow-ups pingdotgg/t3code#5762): Codex accepts a follow-up while the current turn is still running;sendTurnoverwroteactiveTurnIdwith the queued turn's id, so a stop request targeted the wrong turn and Codex rejected the interrupt. Now the active id is kept until turn-lifecycle notifications advance it.Base
Based on
main, independent of the #122→#127 stack. The buggy lines are not touched by the #112 work (verified against the stack tip), so this merges cleanly regardless of stack ordering.Verification
ClaudeAdapter.test.ts,ProviderRuntimeIngestion.test.ts,CodexSessionRuntime.test.ts— 137 tests passed. No test asserted the old (buggy) behavior.reaper.started, no Service-not-found).Follow-up
Upstream shipped regression tests alongside each fix (an ingestion-test dispatch-helper refactor for #5710, a Codex collab integration test for #5762). Those weren't ported here to keep the change surgical; they're worth porting as a follow-up if we want the regressions pinned locally.
Related upstream review
Two more nightly server fixes were assessed and filed as issues rather than ported here: #128 (reaper kills background subagents — needs adaptation to neokod's
workerCountsignal, sequenced after the stack) and #129 (PR-status rate-limit backoff). Two others (#5774 settle, #5788 OOMPolicy) were found not applicable to neokod.🤖 Generated with Claude Code