Skip to content

fix: interrupt native compaction turns on cancellation - #41

Merged
wibus-wee merged 2 commits into
mainfrom
fix/native-compaction-cancellation
Sep 13, 2026
Merged

wibus-wee merged 2 commits into
mainfrom
fix/native-compaction-cancellation

Conversation

@wibus-wee

@wibus-wee wibus-wee commented Sep 12, 2026 •

Copy link
Copy Markdown
Member

Problem / pressure

Stop during manual Codex /compact currently cancels the local ACP wait while the native compaction can continue. The empty thread/compact/start response was interpreted as an absent turn, although Codex 0.153.4 emits the ordinary turn lifecycle.

Summary

Capture the native id from turn/started, route Stop through turn/interrupt, and keep the ACP prompt occupied until matching native turn/completed or connection closure. Cancellation before the id arrives interrupts the turn on arrival without synthesizing local completion. Compact waiters resolve at the native notification boundary, so interrupt acknowledgements, local interruption fallbacks and item progress cannot release them. Native failure and interruption follow the existing command lifecycle.

Visual explanation

sequenceDiagram
  participant Host
  participant ACP as Codex adapter
  participant Native as Codex app-server
  Host->>ACP: prompt /compact
  ACP->>Native: thread/compact/start
  Host->>ACP: session/cancel (before native start)
  Native-->>ACP: turn/started (native id)
  ACP->>Native: turn/interrupt (native id)
  Native-->>ACP: interrupt acknowledgement
  Note over ACP: Prompt remains occupied
  Native-->>ACP: turn/completed (interrupted)
  ACP-->>Host: prompt result (cancelled)
Loading

Before / after

Before After
Stop could release ACP while native compaction continued. Stop interrupts the native turn and retains ownership while it drains.
Process exit could strand a compaction waiter. Connection closure rejects the pending command, including before its start acknowledgement.

Test plan

  • Adapter typecheck and all 617 enabled tests pass; 27 existing environment-gated tests remain skipped.
  • Stop and request-abort regressions explicitly release the interrupt ACK and drain async continuations before checking that the prompt is unresolved and another prompt is rejected. Only a real native terminal event permits reuse. Both pre-start cases failed before this correction.
  • A separate boundary regression proves synthetic interrupted completion cannot settle a compact waiter. Coverage also includes cancellation after start, all terminal statuses, early terminal events, start rejection, unrelated events, and connection closure before/after start and acknowledgement.
  • Real Codex 0.153.4 smoke: manual compaction completes normally; Stop before native start and Stop on compaction start both produce native interrupted followed by ACP cancelled.
  • Lody integration typechecks, lint and preceding workspace suites pass. The full root check remains blocked only by the uninstalled local Electron binary in the relay suite (103/104 Electron tests pass).

Related work

Review focus: after a pre-start cancellation's interrupt ACK, ownership must remain held until a matching native terminal event. Local interrupted completion must never resolve compact waiters. Historical records are not migrated. Lody #618 is unchanged by this follow-up.

@wibus-wee
wibus-wee marked this pull request as ready for review September 13, 2026 05:16
@wibus-wee
wibus-wee merged commit 6dd1f68 into main Sep 13, 2026
@wibus-wee
wibus-wee deleted the fix/native-compaction-cancellation branch September 13, 2026 05:16
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.

1 participant