Skip to content

fix(codex): await app-server exit when opening fails - #502

Merged
stamp-build[bot] merged 1 commit into
mainfrom
agent/otter/codex-startup-cleanup
Oct 28, 2026
Merged

stamp-build[bot] merged 1 commit into
mainfrom
agent/otter/codex-startup-cleanup

Conversation

@stamp-build

@stamp-build stamp-build Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

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


Codex could reject an open while its app-server was still running. In particular, an initialization refusal after the same home had already initialized successfully escaped the cold-home coordinator's cleanup. Thread start/resume, missing thread id and naming failures could also return before exit.

The session opener now owns cleanup until it returns a Session: every failure kills the app-server, awaits its exit and rethrows the original error. Existing error types, redaction and successful-session behavior stay intact. Distributed preflight/open cleanup is folded into that boundary.

Nine real-child regressions cover initialization, start, resume, missing id, tool preflight, configuration RPC, model readback, resumed effort update and naming. Each warms the same home first. A POSIX shutdown barrier distinguishes requesting termination from observing exit; Windows asserts the child is already gone when open rejects. Five of these regressions fail before the fix, and all nine pass afterward.

Origin: deepseek-harness's OAR 0.67.0 patch, startup-cleanup tests and their fake app-server exposed the issue and inspired the exit barrier.

Validation:

  • Full CI=1 pnpm run check: 2,216 unit tests passed; mock behavior suite clean.
  • Codex 0.164.0 against a local scripted provider: shared behavior suite clean (16 passed, 3 skipped), 48 vendor tests passed.
  • Build passed. No real account or provider calls.
  • First native vendor run accidentally selected PATH's Codex 0.162.0: 47 passed, one saved-service-tier assertion failed. The original failure is retained locally; the version-specific behavior is already documented in the October 23 report. The 0.164.0 run above uses an explicit binary and unchanged assertions.

Sibling audit was source inspection, not fault injection of every runtime. ACP, Claude, Qwen, Qoder and Pi RPC already wait for their process in their expected initialization/readback failure paths. Cursor and Pi SDK run in-process; Pi Durable stops its own stream without shutting down the host-owned harness. No equivalent change was needed in those paths.

stamp-build Bot added a commit that referenced this pull request Oct 28, 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_572e1e5c4d8dbe1e6bc5dc9c8b82219d"><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 -->

Codex 0.165.0 reports a provider's unknown-model error with the explicit
`modelNotFound` enum. OAR did not recognize it and returned `unknown`.
Map that enum to `model_unavailable`, without inventing the HTTP status
that Codex no longer reports. The existing transport variants and their
status fields remain covered.

The native vendor test now saves one trace per Codex failure case,
including opening, every record and the final outcome, and disposes a
session after a failed assertion. This is also the evidence needed for
the first Windows 0.165.0 unknown-model case in PR #502, which reached
the unchanged 120-second test deadline without a retained case trace.
That Windows failure's cause is not yet established; CI on this PR will
preserve the missing evidence. No adapter timeout or synthetic turn
completion is added.

Validation: full `CI=1 pnpm run check` (2,208 unit tests and 19 mock
behavior cases), build, and all 48 Codex 0.165.0 native vendor tests
passed on Linux. Before the mapping, the same native unknown-model case
returned `unknown`; its error and failed `turn/completed` both carried
`modelNotFound`. The older HTTP 404 representation remains covered by
the unit table.

Separate prerequisite for #502, as requested by Cindy. Its startup
cleanup is not included here.

Co-authored-by: Otter <[email protected]>
@stamp-build
stamp-build Bot force-pushed the agent/otter/codex-startup-cleanup branch from 40cedd1 to 06f2f01 Compare October 28, 2026 07:23
@stamp-build
stamp-build Bot merged commit 1e8ae0e into main Oct 28, 2026
51 of 53 checks passed
@stamp-build
stamp-build Bot deleted the agent/otter/codex-startup-cleanup branch October 28, 2026 10:37
@stamp-build stamp-build Bot mentioned this pull request Oct 29, 2026
stamp-build Bot added a commit that referenced this pull request Oct 29, 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_b7f19bc105fc79567d3816dade60a274"><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

### Claude: permission launch arguments are checked (#513)
`launchArgs` may now carry `--permission-mode` (see New). Two arguments
that could only make a session wait for an answer nobody sends are
refused before launch with `UnsupportedOptionError("launchArgs")`:
`--permission-prompt-tool` (OAR has no interface for answering
permission requests), and `--permission-prompts` with any value other
than `none`. Combining `--permission-mode` with
`--dangerously-skip-permissions` is refused too, as is a
`--permission-mode` without a value or with a value other than the four
below (for example `bypassPermissions`: omit the mode to keep the
bypass).

### TypeScript: new union members
Exhaustive `switch` statements over these types need a new case:
- `LoginUnsupportedReason` gains `browser_suppression_unavailable`
(#504).
- `RefusableSessionOption` gains `goals`; `ControlAction` and
`RequestBody` gain `goal_set`, `goal_read` and `goal_clear`;
`RuntimeEventBody` gains `goal_changed` (#516).

## Behavior changes

### `orient()` for Qwen and Kimi (#504, #505)
- Qwen's `authStatus` is `localOnly`, so it now runs at local depth.
When Qwen's credentials live only in project settings, a workspace
`.env` or `--openai-api-key`, it reports `logged_out`, and at `models`
depth `orient` then skips the catalog (`skipped` / `logged_out`) where
0.75.0 read it. Call `qwenRuntime.listModels()` directly for a specific
workspace.
- Kimi's `auth` is now `skipped` / `depth` at local depth instead of
`unsupported`. At account and models depth `orient` starts `kimi acp`
for the status check (up to 20 s by default) and skips account usage and
models when Kimi reports logged out.

### Codex `goal_changed` without opting in (#516)
OAR projects Codex's own `thread/goal/updated` and `thread/goal/cleared`
notifications whatever `SessionOptions.goals` is. A user whose Codex
configuration already enables goals produces `goal_changed` events in
sessions that did not set `goals: true`; such sessions still have no
`goal` member. Handle unknown event kinds without throwing.

### Login status contract (#504)
`authStatus` never starts a login and never returns a secret, but a
native status query may now contact its service or start a short-lived
process (Kimi's ACP check); it was previously described as read only and
cheap. `oar login --status` covers Kimi and Qwen too.

### New dependencies (#505)
`@botiverse/oar` now depends on `dotenv` and `strip-json-comments`
(loaded only by Qwen's status reader).

## New

### Kimi login, status and logout (#504)
`kimiRuntime.login` relays Kimi's native device code (`kimi login`, with
`KimiLoginOptions.region`: `"mainland-cn"` or `"global"`; omitted, Kimi
resolves the region itself). `openBrowser: false` places a private no-op
browser helper first on the login child's PATH and removes it
afterwards; where that cannot be guaranteed the login returns
`unsupported` / `browser_suppression_unavailable` before launch.
`authStatus` checks readiness through ACP `authenticate` without
creating a session (cached credentials, not proof of remote validity;
not declared `localOnly`). `logout` uses ACP `logout` and re-reads the
status. Login and logout need Kimi 2.3.3 or later; older builds, or a
build without ACP logout, answer `unsupported` / `version_unsupported`.
Native side effects: a failed or cancelled Kimi login can still change
stored credentials (re-read `authStatus`; OAR does not roll back), and a
successful login writes Kimi's managed model configuration.

### Qwen: login status and provider configuration (#505, #507)
- `qwenRuntime.authStatus` is a local-only, presence-only reader over
the session environment, user and system settings, user `.env` files,
and Google ADC or legacy Qwen OAuth file existence. Any configured
source answers `unknown` with the source kind (never a value); none
answers `logged_out` with setup guidance and a note that project
settings, a workspace `.env` or launch arguments may still supply
credentials. `AuthStatus` `logged_out` gains an optional `detail`.
- `createQwenProviderAuth(installation, { cwd?, env?, timeoutMs? })` is
async and resolves a `QwenProviderAuth` with `listProviders()` and
`connect({ providerId, apiKey?, baseUrl?, protocol?, wireApi?,
modelIds?, scope? })` over Qwen's own ACP methods `qwen/providers/list`
and `qwen/providers/connect`, which in Qwen 0.26.2 apply the same
install plan as its `/auth` command. A non-positive `timeoutMs` throws
`RangeError`; failures throw `QwenProviderAuthError` (`kind`, `method`,
`code`). New exports: `createQwenProviderAuth`, `QwenProviderAuthError`
and the types `QwenProvider`, `QwenProviderAuth`,
`QwenProviderAuthOptions`, `QwenProviderAuthErrorKind`,
`QwenProviderConnectOptions`, `QwenProviderConnectResult`. The key
travels only on ACP stdin; errors keep the ACP code and drop native
text. `existingConfig` is Qwen's settings-file metadata (no environment,
`.env` or `security.auth.apiKey`; depends on `cwd`), not login status.
Success means the configuration was written, not that the provider
accepts the key; a timeout leaves the write outcome unknown and is never
retried. There is no OAuth (Qwen's free tier ended on 2026-04-15) and no
logout.

### Claude: noninteractive permission modes (#513)
`launchArgs: ["--permission-mode", "dontAsk"]` (also `default`,
`acceptEdits`, `plan`) makes OAR omit its default bypass and add
`--permission-prompts none`, so requests needing approval are denied
locally instead of waiting. Without a mode, the default bypass is
unchanged. **On resume, give the mode again**: OAR does not store
`launchArgs`, and omitting it restores the bypass. The
`--permission-mode=plan` form works too. Claude's own `system/init`
frame reports the mode in effect; in `plan` mode, Bash decisions consult
a model classifier, and no mode is an OS sandbox.

### Codex: native goals, opt-in (#516)
`SessionOptions.goals: true` enables Codex's goal feature for the
session. It adds model-visible goal tools, so OAR never enables it by
default; OAR confirms it through `config/read` and rejects the open with
an `Error` when Codex does not. The session then has `goal`: `set({
objective, status?, tokenBudget? })`, `read()` and `clear()` are
recorded controls, and `goal_changed { goal: GoalSnapshot | null }`
comes only from Codex's own replies (recorded as frames) and
`thread/goal/updated` / `thread/goal/cleared`. An active goal can make
Codex start turns by itself; a completed turn never completes a goal,
and OAR runs no continuation loop. Other runtimes refuse `goals: true`
(`false` is accepted). Give it again on resume. New exports:
`GoalControl`, `AdapterGoalControl`, `GoalSnapshot`, `GoalSetOptions`,
`GoalStatus`, `KnownGoalStatus`; custom runtimes built on the kernel may
supply `goal`.

## Fixes
- Codex: any failure before a session is returned now stops the
app-server and waits for it to exit before rejecting, also on an already
initialized home (#502).
- Codex 0.165.0 reports an unknown model as `codexErrorInfo:
"modelNotFound"`; it maps to `model_unavailable` without inventing an
HTTP status (#503).

## Docs
- What `abort` stops: it ends the turn, not necessarily the processes
the turn started. Codex keeps commands across turns on purpose and
Grok's terminals outlive a cancel; `dispose()` stops them where OAR owns
the process (not a borrowed Pi Durable harness) (#514).
- Research: Claude permission modes (#506), native goals (#511),
per-session process resources and shared-session lifecycles (#512),
Antigravity steering and `agy` CLI versus ACP (#517, OAR stays on ACP).
- Pi in process and over RPC needs `systemPrompt` and
`appendSystemPrompt` again on resume (Pi stores neither); Pi Durable
keeps its saved append instructions (#507).
- The package README lists who has login, status and logout now (#521).
- Runtime version checks for October 28, including Cursor SDK 1.2.0
verified compatible (the peer stays `@cursor/sdk` 1.1.0) and resuming a
1.0.40 agent under 1.1.0 (#508).

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

0 participants