Skip to content

fix(pi): recover rejected inputs and clear stale cancellation - #617

Merged
stamp-build[bot] merged 4 commits into
mainfrom
agent/otter/pi-turn-release
Nov 5, 2026
Merged

stamp-build[bot] merged 4 commits into
mainfrom
agent/otter/pi-turn-release

Conversation

@stamp-build

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

Copy link
Copy Markdown
Contributor

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


A Pi prompt refused before native start can leave held inputs stranded and retain cancellation intent for the next run. Recover that path by recording the refusal, clearing stale abort state and draining held work. SDK disposal during pending admission now reports disposed, late failures cannot settle a later extension run, and RPC clears a cancellation fallback rearmed while terminal statistics or observers finish, preventing a healthy child from being killed later.

Ordinary terminal publication keeps its existing order: publish turn_ended, then release the native run gate and drain. A synchronous SDK/RPC observer can therefore see idle while prompt is still busy; submit after the observer returns. The earlier synchronous-submission implementation is withdrawn, including its preflight admission helper, deferred dispatch, isStreaming checks and front requeue. The design decision documents why settlement-time extension scheduling makes that approach unsafe and what evidence would reopen it. Pi Durable product behavior is unchanged.

Extension-handled inputs, competing extension runs, missing queue ownership and a reentrant prompt from a pre-start refusal observer remain explicit limitations. Task #173 owns their separate record/ownership design. No completion is fabricated here, and this change does not claim to fix those existing gaps.

Validation on main 91c626a5:

  • Full check: 3,202 tests and 18 mock behavior cases passed. Build and clean packed consumption passed.
  • 21 focused regressions cover refusal draining, stale cancellation, disposal, late failures, terminal callback ordering and ordinary FIFO. Eight focused mutations are caught; the main product code fails eight of the retained independent regression cases.
  • Native Pi SDK/RPC 1.5.0 vendor suites passed (101/99 cases), Durable passed 26 cases, and all three Pi behavior backends passed. Missing-key refusal uses a local scripted provider and verifies recovery. Ordinary terminal observer prompt/queue controls preserve FIFO; Durable remains a separate control.
  • The supplied review probes for extension preparation failure, delayed extension input and competing observer prompts were compared with main in SDK and RPC. Their recorded facts match byte for byte after narrowing. Those diagnostics are retained locally, not installed as public tests; their existing limitations remain documented.

Task #162, intended for 0.87.2 with #626. No package version or release tag change. Windows/macOS results require this head's CI.

Rebased after #626; all four commit patches are unchanged.

@stamp-build
stamp-build Bot force-pushed the agent/otter/pi-turn-release branch from c6729c7 to 5c7998b Compare November 5, 2026 05:18
@stamp-build stamp-build Bot changed the title fix(pi): release settled turns before notifying observers fix(pi): settle native prompt admission and terminal controls Nov 5, 2026
@stamp-build
stamp-build Bot force-pushed the agent/otter/pi-turn-release branch from 5c7998b to 8375050 Compare November 5, 2026 06:28
@stamp-build stamp-build Bot changed the title fix(pi): settle native prompt admission and terminal controls fix(pi): recover rejected inputs and clear stale cancellation Nov 5, 2026
@stamp-build
stamp-build Bot force-pushed the agent/otter/pi-turn-release branch from d275519 to de8cdda Compare November 5, 2026 08:12
@stamp-build
stamp-build Bot merged commit f59e2cd into main Nov 5, 2026
37 checks passed
@stamp-build
stamp-build Bot deleted the agent/otter/pi-turn-release branch November 5, 2026 09:39
@stamp-build stamp-build Bot mentioned this pull request Nov 5, 2026
stamp-build Bot added a commit that referenced this pull request Nov 5, 2026
<!-- stamp:review:v1 -->
<sup><img src="https://api.raft.build/api/avatars/pixel/bXVn.svg" width="16" height="16" align="absmiddle" alt=""> <b>Cindy</b> from open-agent-runtime opened this pull request through Stamp</sup><br><sup><a href="https://stamp.build/review?receipt=prc_b6cea2eb70db20fefc1fe4212bbebdaf"><picture><source media="(prefers-color-scheme: dark)" srcset="https://stamp.build/assets/brand/stamp-glyph-dark.d907ffcadb44.svg"><img src="https://stamp.build/assets/brand/stamp-glyph-light.58a2c10ed108.svg" width="13" height="12" align="absmiddle" alt=""></picture> View in Stamp →</a></sup>

---
<!-- /stamp:review:v1 -->

Patch release: a host can use its own, newer Pi executable, Pi sessions recover from a refused prompt, and two Codex startup problems are fixed.

## Explicit Pi RPC commands (#626, fixes #621)
- `createPiRuntime({ execution: "subprocess", command })` now accepts stable Pi **1.4.0 or newer**, not only the exact version OAR bundles, so a user's upgrade of `pi` no longer stops a host from opening sessions.
- This is a compatibility floor, not a claim that every future release is tested. Native controls passed on explicit 1.4.0 and 1.5.0 on Linux x64; older explicit versions are unverified on macOS and Windows.
- A missing, unparsable or older version throws `RuntimeFailureError` with `failure: "invalid_request"`, naming the actual and required versions. It was a plain `Error` before.
- The default path without `command` still requires OAR's exact bundled Pi.

## Pi SDK and RPC recovery (#617)
- A prompt Pi refuses before starting no longer strands queued input: the refusal is recorded and the queue drains.
- A cancellation requested for a refused prompt no longer ends the next run.
- On RPC, an abort during the terminal statistics window no longer kills a healthy child about 10 seconds later.
- On SDK, disposing during pending admission now answers `disposed`, and a late failure cannot settle a later run started by an extension.

## Codex startup (#627)
- A refused thread name no longer fails the open. Older app-servers lack `thread/name/set`, so every start with a `name` failed on them. Codex's error is now recorded as a `thread/name/set/error` frame with no events; a lost connection still fails.
- The app-server now starts in `SessionOptions.cwd` rather than the host's directory, so stdio MCP servers and a relative `CODEX_HOME` resolve there.
- **Behaviour change:** a session directory that does not exist now fails the open with `Codex session directory does not exist`. Codex 0.163.0 accepted that open before.

## Documented limits
- Synchronous next prompt from a `turn_ended` observer stays unsupported on Pi SDK and RPC: status can read `idle` while `prompt` returns `busy`. Submit after the observer returns. The reasoning and what would reopen it are in `docs/design/decisions.md`.
- Extension-handled input can leave status provisionally `running` with no native run; the gate itself still accepts the next input.

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

Co-authored-by: Cindy <[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.

0 participants