Repository navigation
feat(session): extend native manual compaction controls - #614
Merged
Merged
Conversation
added 4 commits
November 2, 2026 23:57
This was referenced Nov 3, 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.
Hosts can call the existing optional
Session.compact()on Grok, Qoder, Cursor and OpenCode v2 sessions. Completion requires native compaction evidence; a successful ordinary prompt is insufficient. Busy sessions refuse the control, caller cancellation only stops waiting, and queued input waits until native termination. OpenCode v1 has nocompactmember; Pi Durable remains deferred to its native API migration.The result and input gate now distinguish a known native end from lost observation. OpenCode errors are retained as frames; a reply without matching compaction evidence and Grok's null reply return
unconfirmedand release the gate. Only Grok's structuredcompact_failed/compact_cancellederrors report failed / aborted compaction; other RPC errors are typed refusals with no invented end. Grok and OpenCode admit the control after SDK dispatch.Native terminal records release the manual-operation reservation and folded status together. Admission also respects held input, with the queue exception below. Grok/OpenCode RPC answers and Qoder's exact command terminal carry
FrameBody.responseTo; their compact requests carrysettledBy: "native_response". Earlier compaction/turn events remain in place. NativecompactionIdand directly correlatedcompaction_ended.requestIdpreserve their distinct meanings. Checkpoint consumers must retain the complete exportedStatusState, including native correlation and adapter queue ownership.ACP queue acceptance adds
queued: "adapter"; draining records a new prompt withcarriesreferencing the original input identity, and that prompt's single response. This also applies to ordinary queues on Kimi, Grok, OpenCode, Antigravity and CodeBuddy. Hosts counting requests or grouping by kind must usecarriesto avoid treating the extra prompt as another user input. When inputId is absent, the queue request identity links dispatch within the same stream, so the view still renders one input. Foreign session, agent and resumed-stream carries are refused. No native queue event is fabricated, and the original queue request receives one response. Status remains running between native completion and dispatch/withdrawal, so a new prompt cannot overtake held inputs. Existing queue and interrupt tests now assert these explicit records and retained ownership.Cursor retains the existing root envelope
sessionIdand task/agentPath attribution. Nativeagent_idstays in the payload; native run ids becomespanIdon both stream and callback frames, including callbacks emitted beforesend()returns, retaining their ingress timestamp. An immediate rejection handler prevents host-level unhandled rejection when abort overlaps summary startup. SDK 1.2.0summarize()has nolocal.forceoption: an offline real-store probe confirms a restored active run is refused without starting an executor or making a fetch call. No account probe was repeated.A separate ordinary-turn fix covers Claude, Qoder, Qwen, Codex, Cursor and the shared ACP driver (Kimi, Grok, OpenCode, Antigravity and CodeBuddy): internal ownership releases before publishing the terminal frame. With no held input, a synchronous turn_ended observer can send the next prompt, and old cleanup cannot clear it. Held input retains FIFO priority over new prompts and queued input. Parameterized Claude/Qoder/Qwen regressions call both controls from synchronous terminal observers; the queue cases finish all three turns and verify A, B, C dispatch order. Removing the queue hold guard fails all three runtime cases. Cursor controls preserve its existing order. Native payloads and relative frame order remain unchanged, as do existing replay snapshots.
A documented exception remains for OAR-held queues on Claude, Qoder, Qwen and Cursor: status can show idle while prompt returns busy. Their explicit queue ownership/dispatch records and refusal handling are tracked separately in Raft task 161, after this PR. This does not weaken same-record admission without held input.
Report, selected native evidence, reproduction scripts and release-note draft describe exact versions and limits. The retained Cursor account experiment is manual only; its available usage is documented and it is excluded from CI.
Validation of the latest queue guard: the focused three-file run passes all 34 tests; the new observer-queue cases fail on the preceding head for Claude, Qoder and Qwen.
CI=1 pnpm run checkpassed (3,141 tests, 18 mock behavior checks), and all 14 behavior backends passed. The preceding revision passed build, clean packed-host installation and full vendor suites for Claude (80), Qoder (12) and Qwen (18). Earlier review validation also passed Codex (62), Grok (20), OpenCode v1 (10), 16 Pi SDK/RPC 1.5.0 compaction controls and six OpenCode v2 2.2.5 controls; those native compaction paths are unchanged in this revision. Fourteen review mutations were caught; two additional before/after regressions cover startup-refusal reentry and buffered callback timestamps. The latest regressions also fail before the no-ID carry fix, stream-json FIFO guard and ACP terminal release ordering. Cursor FIFO and no-queue reentry controls pass. Existing replay snapshots are unchanged.Local native evidence is Linux x64. Existing CI retains its OpenCode v1 pin; the six new v2 controls are tested separately with 2.2.5. Five unrelated MCP cases in the broader v1 vendor suite also fail on unchanged base when run against v2, so this PR does not claim whole-suite v2 support. No workflows or dependency pins change.