Skip to content

fix(runtime)!: reject ignored resume options and bound disposal - #469

Merged
stamp-build[bot] merged 5 commits into
mainfrom
agent/otter/runtime-contract-fixes
Oct 23, 2026
Merged

stamp-build[bot] merged 5 commits into
mainfrom
agent/otter/runtime-contract-fixes

Conversation

@stamp-build

@stamp-build stamp-build Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

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


Explicit resume options could be silently ignored, a stuck Pi abort could prevent disposal, Cursor loading changed the host environment, and Pi Durable missing conversations had no typed error. This PR fixes those four contract violations in separate commits.

Breaking changes:

  • Claude 2.1.309 ignores both explicit system-prompt options on resume. OAR now refuses them with UnsupportedOptionError before starting any process, including empty or repeated values. On resume, omit both options to keep saved instructions; start a new conversation to change them. Codex 0.164 applies replacement systemPrompt but ignores appendSystemPrompt, so only the latter is refused on resume. OAR does not inspect history files to guess whether two prompts match.
  • Cursor SDK loading no longer sets process.env. Hosts with non-hoisted pnpm, bundled or single-executable layouts that relied on OAR's previous setup must configure absolute CURSOR_TREE_SITTER_VENDOR_DIR (the platform package vendor directory) and CURSOR_RIPGREP_PATH (its bin/rg or bin/rg.exe) at host startup. The pure exported cursorNativeEnvironment() helper retains SDK-relative platform-package discovery, returns these absolute paths (or null), and never changes the environment. Hosts can explicitly apply its result at startup. SDK 1.0.40 has no per-agent alternative. cursor.md documents the native missing-module, parser-degradation and ripgrep errors and the validation boundaries.

Pi disposal now bounds abort and extension shutdown together to ten seconds, then releases the session. A late abort cannot invoke shutdown hooks on a disposed context. This does not forcibly stop arbitrary JavaScript or fabricate a turn outcome. Pi Durable maps a successful Harness.conversation lookup returning undefined to SessionNotFoundError; invalid ids and storage failures retain their ordinary errors, and no replacement conversation is created.

Validation: native Claude 2.1.309 and Codex 0.164 provider-request probes, four native resume regressions, before-process refusal tests, stuck-abort and late-abort regressions, Cursor environment preservation, and real in-memory Pi Durable missing/storage-error controls. The new failures were observed on the preceding implementation before fixing them. Full check, build and all six behavior backends passed on current main, including Qwen and interrupt delivery. Pi's native shutdown-hook regression also passed. No real-account or model-quota use in this work.

Consumer migration was confirmed by the maintainer on October 23. No release is included. Final approval is requested only after CI passes on the final head based on current main.

The preceding head had a Linux Qwen shared-HOME extension-lock failure despite fixture warmup. That unrelated native limitation is being investigated separately with its original logs preserved; local successful runs are not evidence that the race is fixed.

@stamp-build
stamp-build Bot force-pushed the agent/otter/runtime-contract-fixes branch from 0ad13ec to fab5a17 Compare October 23, 2026 22:52
@stamp-build
stamp-build Bot merged commit 8a2a3a7 into main Oct 23, 2026
21 checks passed
@stamp-build
stamp-build Bot deleted the agent/otter/runtime-contract-fixes branch October 23, 2026 22:59
@stamp-build stamp-build Bot mentioned this pull request Oct 26, 2026
stamp-build Bot added a commit that referenced this pull request Oct 26, 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_48e1b9abd98c4e88cea55ad400f97394"><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 -->

## Breaking changes

### Resume no longer accepts prompts the runtime ignores (#469)
Measured on Claude 2.1.309 and Codex 0.164.0: when resuming, Claude
ignores `systemPrompt` and `appendSystemPrompt`, and Codex ignores
`appendSystemPrompt` (a replacement `systemPrompt` does take effect on
Codex). OAR used to send them anyway, so the prompt was silently
dropped. These cases now fail with `UnsupportedOptionError` before any
process starts, for any explicit value, including the same text the
session was created with and `""`.

**Host note:** on resume, omit the refused options; the session keeps
the prompt it was created with. To change it, open a new session, or
deliver the change as input. Codex resume still accepts `systemPrompt`.

### Cursor: OAR no longer changes `process.env` (#469)
OAR used to set `CURSOR_TREE_SITTER_VENDOR_DIR` and
`CURSOR_RIPGREP_PATH` in the host's process environment before loading
the Cursor SDK. It no longer does. The new `cursorNativeEnvironment()`
returns those two absolute paths (or null) without changing anything.

**Host note:** with a non-hoisted layout (pnpm, a bundled entry), apply
it before loading the SDK, for example `Object.assign(process.env,
cursorNativeEnvironment() ?? {})`, or set the two paths yourself.
Without them the SDK's shell parsing degrades and its ripgrep lookups
can fail with `Ripgrep path not configured`.

### Cursor: `authStatus()` is `unknown` while `CURSOR_API_KEY` is set
(#477)
Cursor's status call describes only the SDK's stored login, but sessions
use `CURSOR_API_KEY` when it is set. `authStatus()` now returns
`unknown` in that case, with a detail saying so, instead of reporting
the stored login's state and identity. It neither reads nor validates
the environment key.

### Pi: no silent package installs, no persistent trust (#473)
Opening a Pi session no longer writes a trust grant into the user's Pi
`trust.json`; project trust lasts for that open only. When Pi's own
preflight reports that its configured package list (project or user)
would install or replace packages, opening now fails with
`RuntimeFailureError` code `project_packages_blocked` and lists those
packages, instead of installing them from the network inside the host
process. The same check makes Pi's `listModels` answer `unsupported` and
its inventories `query_failed`, with the blocked-package reason. The
rule is deliberately conservative, and it is the same for in-process and
subprocess (`execution: "subprocess"`, #465) sessions; subprocess
sessions also start Pi with `--offline` unless installation is allowed.
With `PI_OFFLINE` set, OAR emits an `OAR_PI_PACKAGE_MISSING` process
warning for each configured project package it cannot locate.

**Host note:** start the host with `PI_OFFLINE=1`, or create the runtime
with `createPiRuntime({ allowProjectPackageInstall: true })`.
`createPiRuntime({ projectTrusted: false })` opens without loading
project configuration or extensions, for directories you do not trust.

### Pi: an empty `systemPrompt` is refused (#488)
`systemPrompt: ""` used to open and silently got Pi's default prompt,
because Pi treats an empty custom prompt as absent. It now fails with
`UnsupportedOptionError`, in process and in a subprocess.
Whitespace-only prompts still replace the base prompt, and
`appendSystemPrompt: ""` is unaffected.

### TypeScript: `DeliverOptions` and `DeliverWhen` (#467)
`DeliverWhen` gained `"interrupt"`, and `DeliverOptions` is now a union
type alias rather than an interface. Code that passes a variable of type
`DeliverWhen` as `when` must also handle `maxWaitMs` for the interrupt
case, and an `interface ... extends DeliverOptions` must become an
intersection type.

## New

### Qwen Code runtime (#464)
`qwen` joins `defaultRuntimes`, driven through Qwen Code's native
stream-json control protocol (the interface its own SDKs use). Model
readback from each turn's init, effort only as Qwen reports it, explicit
full-auto approval mode, session MCP over the initialize request (never
on the command line), resume, system prompts. No steer (mid-turn input
is queued by OAR, so withdraw works), text-only input, `outputSchema`,
`serviceTier` and `name` refused. No login member, because Qwen removed
its native auth command: configure a provider through environment
variables such as `OPENAI_API_KEY`, `OPENAI_BASE_URL` and
`OPENAI_MODEL`. Usage after a resume is reported as unknown, because
Qwen reports cumulative totals with no session baseline. New entry point
`@botiverse/oar/runtimes/qwen`.

**Known native limit:** several Qwen sessions in the same home contend
for its extension-store lock; a first turn can wait or fail with
`Extension store is busy`. See the Qwen runtime docs.

### Qoder CLI runtime (#466)
`qoder` joins `defaultRuntimes`, driven through Qoder's native
stream-json control protocol. Installation through Qoder's own
installer, login through `qodercli login` (the link is handed to the
host; `openBrowser: false` supported), status through `qodercli status`,
model and effort readback (effort through `get_settings`), full-auto
permission mode, resume (new prompts on resume take effect), session MCP
and system prompts through private files, credits-exhausted errors
classified as billing. Account details from private responses never
enter records. Steer through native `priority: next` user messages
(joins at a tool boundary, or follows a text-only turn), with
`--replay-user-messages` echoing each input's id (#478). Session
`initialize` gets 60 seconds on every platform, because Qoder
initializes its built-in plugins on every open: measured 7 to 25 seconds
per session open (#476). Verified with the real `qodercli` binary and
its native fake-response reader; a real successful turn against Qoder's
service is still pending account credits. Any `qodercli` command,
including OAR's version probe, can unpack Qoder's native files under
`~/.qoder`. New entry point `@botiverse/oar/runtimes/qoder`.

Hosts using the default registry now also probe for `qwen` and
`qodercli`.

### Qwen installation (#470)
`install` and `installPlan` for Qwen use Qwen's official standalone
installer without editing shell profiles; the installation probe uses
`qwen --version`. On Windows, Qwen's and Qoder's `installPlan` return
the vendor's instructions instead of running an installer.

### Pi out of process (#465, #487)
`createPiRuntime({ execution: "subprocess" })` runs each Pi session in
its own process through Pi's native RPC mode, with the same bundled Pi
version (checked at every open). A single-executable host passes
`command` and `args` for its own Pi subcommand. Per-turn context usage
comes from Pi's `get_session_stats`. Session MCP configuration goes
through a private file, never the command line; provider keys travel
over a private pipe and never touch the command line or disk; system
prompts go through private files that OAR reads back before starting the
process (#487). Subprocess sessions refuse `launchArgs`. Pi's
`installation`, `listModels` and inventories still inspect the bundled
SDK. The in-process SDK remains the default. Resume in both modes also
finds sessions stored under the symlink-resolved working directory. The
design rationale is in docs/design/system.md, "Placement".

### Sessions without the user's own configuration (#475)
`SessionOptions.userConfiguration: "exclude"` opens a session that skips
user-level plugins, skills, commands, agents, MCP servers, hooks, memory
and settings, while keeping the user's existing login and native session
history. Host-provided options (MCP servers, prompts, directories) still
apply. Supported on Claude (native setting sources, strict MCP, memory
exclusion; login and token refresh verified, sessions resume across both
modes) and Cursor (the SDK reads no user configuration). On Claude,
`exclude` refuses `launchArgs` that set `--setting-sources`,
`--settings` or `--strict-mcp-config`, and refuses working directory and
home combinations whose symlink or junction resolution would load user
files as project files. Every other runtime refuses `exclude` with
`UnsupportedOptionError`: Codex and Kimi keep history in the same home
as configuration, and a separate home breaks resume or splits history.
The default, `include`, is unchanged.

### Orientation (#477)
`orient(registry, { depth, runtimes, include, timeoutMs, signal })`
reads installation, login status, provider metadata, account usage and
model lists in one bounded snapshot (60 seconds by default), without
opening a session or submitting a prompt. `include: ["customization"]`
adds user skill, command, MCP and tool counts. `usability(snapshot, {
minVersions })` from `@botiverse/oar/observe` turns that snapshot into a
per-runtime yes or no with a reason; version floors are the host's to
supply. CLI: `oar orient [runtime...] --depth --json --customization
--timeout`.

`local` (the default depth) runs only auth readers declared not to touch
the network, refresh credentials or run key commands
(`AuthStatusReader.localOnly`). Today that is Cursor; Claude, Codex and
Qoder login status is reported as skipped at `local` and read at
`account`. `account` can refresh native credentials and run a configured
`apiKeyHelper`; `models` can start native processes. See
docs/spec/orientation.md.

Supporting additions: `Runtime.providers` (Pi's stored provider
metadata), `ProviderAuthFacade.listProviders({ resolve: false })` to
read it without resolving credentials, and `LoginAccount.credential`
(`account` or `api_key`) and `metering` (`plan` or `usage`), filled in
by Claude, Codex and Cursor. Codex `authStatus` now also recognizes its
`API key configured` output.

### Interrupt delivery for runtimes without steer (#467)
`session.deliver(input, { when: "interrupt", maxWaitMs, merge })` steers
when the runtime can. Otherwise it waits for running root tools (up to
`maxWaitMs`), takes back every held input, aborts, waits for the
runtime's own turn end, and sends one merged prompt (default merge:
inputs joined by a blank line). The result lists `mergedInputIds`, or
returns every input in `undeliveredInputIds` on failure. The merged
prompt record lists the earlier inputs it delivers in `carries`;
conversation views show each input once in that turn. `prompt({ carries
})` is validated: every carried input must be a withdrawn input of the
same session and agent. While an interrupt batch is pending, other
`deliver()` calls on that session wait for it.

## Behavior changes
- Records a session appends from inside a record observer's callback are
now delivered to observers after the current record, in sequence order,
instead of immediately inside that callback (#467).

## Fixes
- Claude: system prompts are passed through private files (0600 on
POSIX) instead of the command line, so they are not visible in process
lists and are not limited by the Windows command-line length (#473).
- Claude `listModels` no longer starts the user's hooks or MCP servers;
claude.ai connectors also stay off during listing (#485, carrying #483
by Oscar-Williams; issue #480).
- Windows: stopping an executable probe, an ACP terminal or an owned
Morph console now ends the whole process tree (#486, carrying #459 by
Oscar-Williams; issue #352).
- Pi: `dispose()` always settles; native abort and extension shutdown
share a 10 second bound (#469).
- Pi Durable: a missing conversation is a `SessionNotFoundError`, like
other runtimes (#469).

## Internal
- The stream-json control protocol is now one shared core used by
Claude, Qwen and Qoder; Claude's records are unchanged frame for frame
(#463).
- CI runs 26 checks (new Qwen, Qoder and Pi RPC behavior backends on all
three platforms).

Co-authored-by: Cindy <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
stamp-build Bot added a commit that referenced this pull request Nov 2, 2026
<!-- stamp:review:v1 -->
<sup><img
src="https://cdn.slock.ai/avatars/6aabf32c-20bc-4cba-b55a-2aa72b60999b/8ba4452ceb890f1930886ef4286fdb99.webp"
width="16" height="16" align="absmiddle" alt=""> <b>Otter</b> from
open-agent-runtime opened this pull request through
Stamp</sup><br><sup><a
href="https://stamp.build/review?receipt=prc_1fa4dd995bda681621703ef81c293b8b"><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 -->

Claude and Codex resumed prompts were refused after observing only the
first resumed request. Native compaction changes that result: Claude's
replacement and append, and Codex's append, use the newly supplied value
after compaction. Omitting them instead drops the saved override at that
point. This change forwards those native options and removes the
incorrect refusals.

`Runtime.resumedSessionOptions` declares two independent facts per
option: when a different supplied value takes effect, and what omission
does. The optional map uses `SessionOptions` keys; absent entries mean
untested. Claude, Codex, Qwen, Pi SDK/RPC and Pi Durable have measured
declarations. Refusal declarations remain authoritative. OAR does not
compare prompt strings, inject instructions or add a compaction control.

All declared prompt options have native regressions for supplied and
omitted values before and after compaction. Claude uses `/compact`, Qwen
uses `/compress`, and Codex/Pi use native automatic compaction. Qwen
must report native completion with a smaller token count; Qwen/Pi must
also place a unique native summary in the next main request's history.
Sequential resumes track the current saved value. A registry-wide test
fixes the declaration inventory and prohibits overlap with refused
options.

Host migration: pass the current Claude/Codex prompts on every resume to
retain them after compaction. Codex replacement instructions survive
omission. Grok append-only sessions are the exception: omit append on
resume to retain the saved value; to change it, also supply replacement
instructions. A retained native Grok compaction probe supports that
exception. The spec, runtime pages, public JSDoc, root example and
decision reversing #469 are updated; the old dated report keeps its
original text with a correction. [Evidence and release-note
draft](https://github.com/botiverse/oar/blob/e052eb83297fd77e1c2481e0280ab6acbad62953/experiments/resume-prompts-2026-11-02.md).

Validation:
- Complete local check: 2,991 tests and 18 mock behaviors; build passed.
Packed public type consumption was verified for the unchanged exported
types.
- All 19 declaration-driven native controls passed; the full Durable
vendor file also passed.
- Eight original Claude/Codex mutation controls and eight added Qwen/Pi
runtime/dimension mutation runs failed their expected assertions.
Durable's incorrect `saved_until_compaction` declaration now fails after
compaction; Qwen/Pi's incorrect `saved` declaration expects the
preceding resume's new marker.
- Existing Claude/Codex/Grok behavior and vendor regressions passed.

Local native observations are Linux x64 against scripted providers.
Cross-platform validation is pending this revision's CI. Codex
declarations were exercised with local compaction; ChatGPT remote
compaction was only inspected in native source, not exercised.
Conditional Grok/OpenCode support and unmeasured Qoder/CodeBuddy
omission remain undeclared. Qwen's compaction-status attribution is a
separate task (#156).

Task #153. No version bump; release timing belongs to Cindy.

---------

Co-authored-by: Otter <[email protected]>
@stamp-build stamp-build Bot mentioned this pull request Nov 2, 2026
stamp-build Bot added a commit that referenced this pull request Nov 2, 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_5f43dcb5c3dc15f0f18ace9ca5bc3132"><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 -->

Minor release: Claude and Codex accept prompt options on resume again, so a resumed session keeps its prompt after native compaction. The new optional `Runtime.resumedSessionOptions` says, before a session opens, when a prompt supplied on resume takes effect and what omitting it does.

## Behavior changes for hosts

### Prompts on resume (#606)
- Claude now accepts `systemPrompt` and `appendSystemPrompt` on resume, and Codex accepts `appendSystemPrompt`. Since #469 these opens were refused with `UnsupportedOptionError`. OAR now forwards them to the native launch.
- A value different from the one the session saved takes effect at the next native compaction; until then the saved prompt stays in effect. Omitting the option keeps the saved prompt only until that compaction; after it, the session gets what a new session without that option would get (the runtime's built-in prompt plus the user's own configuration). Empty and repeated values are now forwarded too, where they used to be refused.
- **Pass the current prompts on every resume.** This holds for Claude and Codex as above, and also for Qwen and Pi (in-process and subprocess), which do not save prompts at all: there an omitted prompt is gone on the very next request.
- Why the change: #469 observed only the first resumed request, where the new value was ignored, and advised hosts to omit these options to keep the saved prompt. At compaction Claude drops its saved prompts and Codex its saved append, so a session resumed that way silently lost its prompt at its next compaction.
- Codex `systemPrompt` (replacement) is unchanged: it applies immediately on resume and keeps the saved value when omitted, including across compaction.
- New optional `Runtime.resumedSessionOptions`, keyed by `SessionOptions` names. Each entry has `provided` (`immediate` or `next_compaction`, for a value different from the saved one) and `omitted` (`saved`, `default` or `saved_until_compaction`). It is declared for Claude, Codex, Qwen, Pi (in-process and subprocess) and Pi Durable, measured on Claude 2.1.316, Codex 0.166.0, Qwen 0.26.5 and Pi 1.4.0. An absent entry means untested; it implies neither support nor refusal, and refusals stay in `refusedSessionOptions` and conditional `UnsupportedOptionError`s (for example Pi Durable still refuses changed settings while adopting an active run). `ResumedSessionOptions` and `ResumeOptionSemantics` are exported from the package root. The Codex entries were measured with local compaction; compaction under a ChatGPT login was checked in Codex source only.
- Grok: resuming with `appendSystemPrompt` but no `systemPrompt` is still `UnsupportedOptionError`, now with a migration hint, because Grok (1.0.70) never applies a changed append on resume, even after compaction. It is refused even when the text is unchanged, since OAR cannot compare it with the saved value. For an append-only Grok session, omit `appendSystemPrompt` on resume; the saved one stays in effect. To change it, supply `systemPrompt` as well. Match on `option`, not on the text.
- OAR does not compare prompt text, insert a prompt into the first input, or compact on its own.

### Qwen memory extraction (#605: docs and a regression, no behavior change)
- With Qwen 0.26.5 (observed on Linux with a scripted provider), each completed ordinary turn also makes a managed-memory extraction request after the main reply and before the native `result`. Its time and usage belong to that turn, and `promptAndWait` waits for it. Receiving all of the reply text does not mean the turn has ended: disposing before `turn_ended` interrupts the extraction like any active turn, so that turn has no native `result` or complete OAR usage, and a raw assistant frame may hold only the main request's partial usage. This is not a claim about every memory configuration or provider.

## Known issue
- Qwen's native compaction report (`Context compressed (old -> new)`) is projected as model text (`text_delta`), and Qwen sessions emit no compaction events. Qwen 0.26.5's stream-json output marks it no differently from model text, and a user's own `compress.toml` can replace `/compress` with an ordinary model turn, so OAR cannot tell them apart and does not guess. Do not treat that line as the model's answer. A request for Qwen to report compaction structurally is being drafted.

## Tests and CI
- Native regressions read each `resumedSessionOptions` declaration and verify supplied and omitted values before and after native compaction: Claude via `/compact`, Codex via native automatic compaction, Qwen via `/compress`, Pi and Pi Durable via native compaction. A registry test pins which runtimes declare entries and that no declared option is also refused (#606).
- Qwen and Pi resumed-prompt regressions (#605).
- Pi provider tests no longer depend on DeepSeek or Anthropic credentials in the host environment (#604).

🤖 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