Skip to content

feat(session): extend native manual compaction controls - #614

Merged
stamp-build[bot] merged 4 commits into
mainfrom
agent/otter/manual-compaction-followup
Nov 3, 2026
Merged

stamp-build[bot] merged 4 commits into
mainfrom
agent/otter/manual-compaction-followup

Conversation

@stamp-build

@stamp-build stamp-build Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Otter from open-agent-runtime opened this pull request through Stamp
View in Stamp →


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 no compact member; 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 unconfirmed and release the gate. Only Grok's structured compact_failed / compact_cancelled errors 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 carry settledBy: "native_response". Earlier compaction/turn events remain in place. Native compactionId and directly correlated compaction_ended.requestId preserve their distinct meanings. Checkpoint consumers must retain the complete exported StatusState, including native correlation and adapter queue ownership.

ACP queue acceptance adds queued: "adapter"; draining records a new prompt with carries referencing 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 use carries to 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 sessionId and task/agentPath attribution. Native agent_id stays in the payload; native run ids become spanId on both stream and callback frames, including callbacks emitted before send() returns, retaining their ingress timestamp. An immediate rejection handler prevents host-level unhandled rejection when abort overlaps summary startup. SDK 1.2.0 summarize() has no local.force option: 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 check passed (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.

@stamp-build
stamp-build Bot merged commit b4328cc into main Nov 3, 2026
36 checks passed
@stamp-build
stamp-build Bot deleted the agent/otter/manual-compaction-followup branch November 3, 2026 02:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants