Repository navigation
feat(core): record session placement and shared process release - #533
Merged
Merged
Conversation
stamp-build
Bot
force-pushed
the
agent/otter/shared-process-core
branch
from
October 29, 2026 18:43
9e9aab8 to
9a3f73f
Compare
stamp-build
Bot
force-pushed
the
agent/otter/shared-process-core
branch
from
October 29, 2026 19:05
9a3f73f to
8730c54
Compare
Merged
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_83606fe51f359eef92339f9fe662aa5c"><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: session placement and the shared runtime process core. No built-in runtime uses shared placement yet; every built-in runtime keeps one process per session or runs in process, as before. This release changes the start of the record stream and several public types. ## Breaking changes ### Record streams start with `open` / `opened` (#533) For built-in runtimes (except the community Morph adapter) and `scriptedRuntime`, every successful open, including `resume`, begins the stream at seq 0 with an OAR request `{ kind: "open", placement }` (the requested placement) and at seq 1 with its response `{ kind: "opened", placement }` (the actual placement). These are OAR lifecycle records, not native frames; native initialization frames follow in their original order, so native frames' seq numbers shift by 2. Hosts must not assume the first record is a native frame or a prompt. `events()` omits `open`, `opened` and `cleanup`. Logs written by earlier versions have no opening records; folds do not invent placement or extra records for them. Custom runtimes built with `defineRuntime` without placement options record no opening pair, report `Session.placement` as `null`, and refuse explicit `shared` and `isolated`. To declare placement, pass `RuntimePlacementOptions` as `defineRuntime(definition, options)` and record the pair with `kernel.opened(context)` from `@botiverse/oar/kernel`. Morph declares no placement (`null`, no opening pair) because it can reuse one Console across sessions. ### TypeScript (#533) Exhaustive switches and custom kernels need updates: - Request body `open`; response bodies `opened`, `cleanup` and `released`; a `released` event; `ViewNotice` gains `{ cause: "released", reason }`. - `RejectionCode` gains `session_released`. - `UnsupportedOptionError.option` widens to `keyof SessionOptions | "placement"`. - `Runtime` gains `placement` and `withPlacement()`; `Session` gains `placement`; `defineRuntime` takes an optional second argument and its return type changed. - `SessionKernel` (`/kernel`) gains a required `opened()`, and `unreachable()` can return `session_released`. - Additive: `StartSession` gains an optional third `context` parameter; idle `AgentStatus` gains `released?: true`; `SessionResources` gains `scope?`. ## New ### Session placement (#533) `Runtime.placement` is the host's request: `auto` (the default instances), `shared` or `isolated`. `runtime.withPlacement(request)` returns a new runtime instance; shared sessions from that instance use its own process pool. Each opened session reports its actual placement: `shared`, `isolated` or `in_process`. - Under `auto`, Antigravity, Claude, CodeBuddy, Codex, Grok, Kimi, OpenCode, Qoder, Qwen and Pi RPC are `isolated`; Cursor, Pi in process and Pi Durable are `in_process`. `auto` shares only where a runtime version has passed OAR's evidence gate on that platform ([design](https://github.com/botiverse/oar/blob/main/docs/design/system.md#shared-runtime-processes)); none has yet. - Explicit `shared` is refused when a session opens (not when `withPlacement` is called) with `UnsupportedOptionError` on `placement` where sharing is not supported; in-process runtimes also refuse explicit `isolated`. - A pool joins sessions only when the executable, arguments, process cwd, environment (including inherited values) and home/configuration directories match. Session-level model, effort and MCP split a pool unless the runtime's protocol has been shown to isolate them. - New exported types from the root entry: `PlacementRequest`, `SessionPlacement`, `SessionOpenContext`, `SessionCleanup`, `SessionRelease`, `RuntimePlacementOptions`. The pool helpers are internal. ### Release and cleanup records (#533) In a shared process, OAR cannot kill a stuck turn without killing other sessions. When an accepted abort reaches its fallback, OAR records `released`: OAR stopped controlling the session, and the record states that the native turn and any work started after cleanup may continue. A release ends the waiting turn as `aborted` after that turn's accepted abort or dispose request (as an exit does), otherwise as `failed`. Later controls are rejected with `session_released`, or `disposed` once the host has requested dispose; an actual process exit still answers `runtime_exited`. Late native frames are still recorded and cannot reopen the turn. A `cleanup` response records whether per-session native cleanup completed or failed; neither result proves the work stopped. Shared dispose records `released` (or the process exit when the last session closes). A shared process exit ends every session in it, each with its own exit record; OAR never restarts a shared process silently. `resources()` on a shared session reports the whole process with `scope: "shared_process"`. A failed pool-backed close records `rejected`, `dispose()` throws, and it can be retried; built-in runtimes' `dispose` is unchanged. These behaviors apply only to shared placement, which no built-in runtime uses yet; OAR's internal pooled mock runtimes exercise them in both placements. ### CLI (#533) `oar run --json` and `--record` voyage files now include the `open` and `opened` records first. The progress renderer can print `[session released; native work may continue]`, which the CLI's default runtime instances cannot produce today. ## CI - The Windows Pi RPC vendor job records per-case start/end events, redacted Pi stderr tails and the combined Vitest output; an external monitor stops the test command after 3 minutes on one case or 10 minutes overall (exit 124). All of it is in an always-uploaded artifact (#535). Co-authored-by: Cindy <[email protected]> Co-authored-by: Claude Opus 5.5 <[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.
Hosts need to choose process isolation and see what an opened session actually uses. Runtime instances now accept
auto,sharedorisolatedthroughwithPlacement; opening records preserve the request and actual placement. A version/platform gate decides at open, automatic requests fall back to isolation, and unsupported explicit requests raiseUnsupportedOptionError. This phase adds the contract and internal pooling support without enabling native runtime sharing.An internal pool manages configuration identity, concurrent opens, lease disposal and process shutdown. Shared abort fallback releases OAR control and records bounded cleanup while preserving native evidence and peer sessions. Completed disposal detaches the session's process listener. A failed last-owner stop retains ownership for retry, and a failed cleanup report cannot poison later attempts. Interrupt delivery reports
session_released; subagents settle once and retain late native frames only as evidence. Resources identify measurements that cover a shared process.Compatibility: supported built-in adapters now begin each session stream, including resumed sessions, with an
openrequest at sequence 0 andopenedresponse at sequence 1 before native initialization. Hosts inspecting the first record must handle this pair. Public request/response, control-event, rejection-code and display-notice unions gain members;defineRuntimesupplies the runtime placement methods. Legacy custom adapters keep their existing automatic behavior. Morph is an explicit exception until its Console ownership can be represented accurately: it reports no opening placement, returnsSession.placement === null, and refuses explicit shared or isolated requests. Pool and lifecycle helpers remain internal. Old log interpretation is preserved.Tests cover configuration boundaries, concurrent opens and disposal, stop/cleanup failures and retries, removable exit observers, correlated abort responses, late native completion and real exit after release, credential redaction, interrupt/subagent consumers, and placement forwarding through OpenCode and CodeBuddy wrappers. Real-runtime sharing eligibility remains separate work.
Validation: full
CI=1 pnpm run checkpassed (2,485 tests plus the 18-case mock suite). An explicit run of the Claude workflow and community Morph session suites passed all 15 tests, including exact opening-record order and unknown Morph placement. Both mock placements and the existing native behavior suites were exercised. An initial concurrent validation run encountered native startup failures; the isolated CodeBuddy rerun passed all 16 applicable cases. OpenCode 1.19.5 encountered SQLite startup failures on both this branch and the control without this change; those failures are retained in the validation record. With the existing CI concurrency of two, the final OpenCode run passed all 17 applicable cases. Package builds passed.The documentation also links the existing OpenCode cold-start report to the maintainer's comment on upstream issue 53879. Raft task #101; planned for 0.78, after 0.77.