Repository navigation
fix(executable): force-kill after one grace period in closeLineProcess - #1097
Merged
Merged
Conversation
stamp-build Bot
added a commit
that referenced
this pull request
Nov 21, 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>opened from existing branch <code>agent/cindy/release-0.127.0</code> @ <code>b15d311f509d</code>, which the agent did not push</sup><br><sup><a href="https://stamp.build/review?receipt=prc_73c76ce0b5c49eb86a194fb0d706127f"><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 --> ## OAR 0.127.0 ### Behavior changes hosts should know - **Pi is an optional dependency of `@botiverse/oar`** (#1098). A default install still includes `@earendil-works/pi-ai` and `@earendil-works/pi-coding-agent`, so nothing changes unless you opt out. `npm install --omit=optional` (or `pnpm install --no-optional`) leaves both out; note that these flags drop every optional dependency in the tree, not only Pi's. Pi stays in `defaultRuntimes` either way. `@botiverse/oar-cli` keeps both packages as direct dependencies. - Without the packages, `installation()` reports `unsupported` with code `dependency_missing` in a normal Node host for every Pi mode. In-process Pi SDK used to report `not_found` here, so hosts that branch on `not_found` should handle the new code. - Pi RPC with an explicit `command` now also checks the host packages, because the host process needs them for session lookup, project-package checks and context-overflow detection. Its command check runs first, so a missing or too-old `pi` still reports `not_found` or `version_unsupported`. Default Pi RPC in a single-file or Electron host still reports `unsupported_host` first. - The declarations of every entry point except `@botiverse/oar/pi-durable` no longer import Pi, so TypeScript hosts with `skipLibCheck: false` compile without it. `pi-durable` still needs `@earendil-works/pi-ai`. - **Ending a process through stdin EOF takes one kill grace, not two** (#1097). When OAR closes stdin to end an idle Claude or Codex session, Codex's login process after a completed login, or a Qoder or Qwen session or model list, and the process is still alive after the kill grace (10 s by default, `OAR_KILL_GRACE_MS`), OAR now force-ends the process tree at once. Before, it sent SIGTERM and waited a second grace, so this could take up to 20 s. Processes that already ended after one grace are unchanged: Claude and Codex model, inventory and account queries, DSH, Factory and Pi RPC. A session with an active turn is still stopped at once. - **Explicit context overflow is `input_too_large` on more paths** (#1093). The generic error-text rules now check for an explicit overflow first ("This model's maximum context length is N tokens. However, ...", "Your input exceeds the context window of this model", "Prompt is too long", with an optional `Internal error: ` prefix) and keep the original reason. A specific native category or provider code still takes precedence. - OpenCode 2.2.7 and 2.3.2 report an overflow and other invalid requests with the same JSON-RPC code (`-32603`) and native name (`provider.invalid-request`); an explicit overflow there is now `input_too_large`. On OpenCode, a rejected summary request still reports `kind: "failed"` with `failure: "provider"`. - The same rules cover the ACP fallback (every ACP runtime), Cursor, Factory, Grok, Pi in-process, Pi Durable and Morph, Claude's generic invalid-request fallback, and `invalid_request_error` provider bodies on Pi and Codex. An Anthropic-style "prompt is too long" body that used to be `invalid_request` is now `input_too_large`. - The runtime matrix gains "Recovery after automatic compaction fails": after a measured failed automatic compaction, Claude, Pi, DSH, OpenCode v2 and threshold-triggered Codex returned to `idle` and completed the next prompt on the same session. The failed turn stays readable from `turn_ended.outcome` and `status().value.lastTurnOutcome`. ### New - **Codex MCP startup per server** (#1092). From Codex 0.169.0 (executable installs, stable versions), `sessionCapabilities(installation).mcpStartup` is `{ kind: "per_server", firstModelRequest: "may_start_pending" }`: Codex can send the first model request while an MCP server is still listing tools, and that tool is then missing from turn one. A missing declaration means unknown. - Native startup reports that carry a thread ID become `mcp_server_startup` events with the server name and `pending`, `ready`, `failed` or `cancelled` (native `starting` is `pending`). This is a new `RuntimeEventBody` variant, so code that switches exhaustively on event kinds needs a case for it. - `mcpStartupOf(records, sessionId)` (from `@botiverse/oar` and `@botiverse/oar/observe`, with type `McpStartupStatus`) returns the latest state per server for the root agent. - A host that needs a server on turn one can subscribe with `session.events(observer, { cursor: { sessionId: session.id, afterSeq: -1 } })`, which replays startup reports, and wait for its `ready` before the first input. A server that never reports stays unknown, so set your own time limit. ### Tests and CI - The release workflow's dispatch, tag-push and `release_only` paths all require the commit to be the merge commit of exactly one merged `chore: release vX.Y.Z` pull request (#1095, #1096). `ci.yml` cancels superseded runs per ref (#1091). Tests check a fixture process's identity before cleanup (#1089), and DSH's `lastInput` and `requestsForTurn` share one trailing synthetic-context check (#1090). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Cindy <[email protected]> Co-authored-by: xxchan <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes EOF shutdown taking up to twice
killGraceMs()(20 s default) instead of one grace period (10 s default), matching the documented contract across runtimes.forceStop()toprocessShutdown(packages/oar/src/shared/executable/process-shutdown.ts): cancels any pending gracefulescalationtimer, prevents a concurrentclose()from re-arming one, awaits the memoized pre-EOF descendant capture (prepare()), and runsforce()directly (SIGKILLto the process group and tracked descendants on POSIX;taskkill /T /Fon Windows whenkillTreeis set) without sending SIGTERM or arming a secondkillGraceMs()timer.forceKill(): voidtoLineProcess(packages/oar/src/shared/executable/process.ts), wired it inspawnLineProcess, forwarded it inqoderDaemonSession(packages/oar/src/runtimes/qoder/daemon.ts), and implemented it inFakeLineProcess(tests/fixtures/fake-line-process.ts).closeLineProcess(packages/oar/src/shared/executable/close.ts) to callchild.forceKill()when itskillGraceMs()EOF wait expires, so everycloseLineProcesscaller collapses to one grace period in one place.tests/close-line-process-grace.test.tsverifying:closeLineProcessacross directLineProcess,shutdown: "stdin", andqoderDaemonSessionwaits oneOAR_KILL_GRACE_MS, sends noSIGTERMafter EOF expires, and force-ends the process strictly under2 * graceMs.cleanup.status === "observed").child.kill()during the EOF wait does not extend escalation past the original EOF deadline.Call-site audit (EOF,
markNativeStop,killGraceMs, andLineProcessimplementations)closeLineProcess(packages/oar/src/shared/executable/close.ts): changed to callchild.forceKill()afterkillGraceMs(). Automatically covers every caller:packages/oar/src/runtimes/claude/session.ts(idle session dispose)packages/oar/src/runtimes/codex/app-server-client.ts(idle session dispose, pluscodex/account-request.ts,codex/inventory.ts,codex/list-models.ts)packages/oar/src/runtimes/qoder/session.ts&list-models.ts(worker and daemon sessions)packages/oar/src/runtimes/qwen/session.ts&list-models.tsLineProcessimplementations (all 3 in repo):packages/oar/src/shared/executable/process.ts(spawnLineProcess): changed (forceKill: () => { shutdown.forceStop(); }).packages/oar/src/runtimes/qoder/daemon.ts(qoderDaemonSession): changed (forceKill: () => { child.forceKill(); }).tests/fixtures/fake-line-process.ts(ScriptedLineProcess): changed (forceKill()implemented).spawnLineProcess(..., { shutdown: "stdin" })callers usingchild.kill()directly (claude/account-usage.ts,claude/inventory.ts,claude/list-models.ts,dsh/launch.ts,factory/account.ts,factory/client.ts,pi/rpc/open.ts): unchanged;processShutdown.stop()already ends stdin without SIGTERM and arms a singlekillGraceMs()beforeforce().packages/oar/src/runtimes/kimi/web-shutdown.ts: unchanged; sends HTTPPOST /api/v1/shutdownwith a 2 s timeout (KIMI_WEB_SHUTDOWN_GRACE_MS) and intentionally falls back to gracefulchild.kill()if the HTTP endpoint fails (e.g., 404 on startup).packages/oar/src/shared/acp/session.ts&shared-session.ts: unchanged;session/cancelandsession/closeend the ACP session rather than closing stdin, thenruntime.kill()stops the process in one grace.packages/oar/src/shared/executable/node-script.ts(Cursor subprocess): unchanged; uses IPCask()rather than stdin EOF, and its two-stageaskthenshutdown.stop()behavior is explicitly documented innode-script.tsanddocs/runtimes/cursor.md.Verification
CI=1 pnpm run checkpassed locally:pnpm run typecheck: passed across all workspace packages andapps/pi-durable.pnpm run lint(oxlint --type-aware --deny-warnings): passed with 0 errors and 0 warnings.pnpm run test: 598 passed, 152 skipped (5663 passed, 715 skipped), including all 5 new tests intests/close-line-process-grace.test.ts.pnpm run sea-trial(mock): 19 passed, 1 skipped, 0 failed.