Skip to content

deliver: retry a steer the runtime refuses because the turn just ended - #58

Merged
xxchan merged 1 commit into
mainfrom
lookout/deliver-late-steer
Oct 2, 2026
Merged

xxchan merged 1 commit into
mainfrom
lookout/deliver-late-steer

Conversation

@xxchan

@xxchan xxchan commented Oct 2, 2026

Copy link
Copy Markdown
Member

Found in a daily inspection (#inspection).

Problem

docs/spec/conversation.md says Session.deliver retries a steer that is refused because the turn just ended. deliver.ts only retried on the adapter gate's no_active_turn. A steer that passes the gate and reaches the runtime after the turn ended is refused by the runtime itself:

  • live, codex-cli 0.158.0 app-server: turn/steer with the expectedTurnId of a completed turn answers {"error":{"code":-32600,"message":"no active turn to steer"}};
  • the codex adapter maps every turn/steer RPC error to runtime_refused (steerPlan in runtimes/codex/session.ts, as documented in docs/runtimes/codex.md).

So on codex, deliver(input) during the last moments of a turn returned { landed: "rejected", code: "runtime_refused" } with the session already idle, instead of prompting a new turn. A subagent report delivered as the parent's turn ends is the typical case.

Fix

deliver also retries when the status shows the steered turn is over (idle, or a different turn since the steer was sent). No contract shape changes; the spec sentence now names this case.

Not done here, for review to decide: mapping codex's "no active turn to steer" to no_active_turn in the adapter. That would make the typed code honest for every consumer, but it means matching an error message, and docs/runtimes/codex.md currently documents every RPC error as runtime_refused.

Evidence

  • New test in tests/codex/codex-session-stream.test.ts: the fake app-server writes turn/completed and then that error in reply to the steer. It fails on main (landed: "rejected") and passes here.
  • Adversarial check: codex (via oar run codex) was given only the claim and the evidence above and asked to refute it; verdict NOT REFUTED (the gate is read before the RPC, and the reply is processed in wire order).
  • pnpm run check: 461 tests passed, sea trial mock 18/18.

🤖 Generated with Claude Code

`Session.deliver` retried a steer only when the adapter's own gate answered
`no_active_turn`. Past the gate the runtime can refuse in its own words: a
codex `turn/steer` that reaches the app-server after the turn completed is
answered `{"code":-32600,"message":"no active turn to steer"}` (probed live
on codex-cli 0.158.0), which the codex adapter records as `runtime_refused`.
`deliver` then returned `rejected` while the session was already idle,
although the spec says the steer-vs-turn-end race is retried.

`deliver` now also retries when the session's status shows the turn it
steered into is over (idle, or a different turn). The regression test
scripts that ordering on the fake codex app-server and fails without the fix.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@xxchan
xxchan merged commit af146cd into main Oct 2, 2026
12 checks passed
@xxchan
xxchan deleted the lookout/deliver-late-steer branch October 2, 2026 10:55
@xxchan xxchan mentioned this pull request Oct 2, 2026
xxchan added a commit that referenced this pull request Oct 2, 2026
Patch release with two fixes merged today:

- #58 `Session.deliver` prompts a new turn when the runtime itself
refuses a steer because the turn just ended (codex answers `no active
turn to steer` after the adapter's gate passed); before, `deliver`
returned `rejected: runtime_refused` with the session already idle.
Found by the daily inspection.
- #59 Installation probes and the codex app-server keep native failure
diagnostics: exit code, signal, timeout or spawn error, and the last 8
KiB of stderr in the thrown error's message and cause (record shapes
unchanged); a failed spawn no longer leaves an unhandled rejection that
could end the host. Windows codex CI forwards stderr. Refs #57.

Version bump only in this PR.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: exe.dev user <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
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