Skip to content

fix(kimi): refuse a resume in another directory instead of running in the old one - #101

Merged
xxchan merged 1 commit into
mainfrom
fix/kimi-resume-cwd
Oct 3, 2026
Merged

xxchan merged 1 commit into
mainfrom
fix/kimi-resume-cwd

Conversation

@xxchan

@xxchan xxchan commented Oct 3, 2026

Copy link
Copy Markdown
Member

Measured, per runtime, whether a conversation opened in directory A can be resumed by id in directory B (experiments/resume-other-cwd.ts, new page docs/runtimes/resume-cwd.md): claude and codex keep the conversation and run in B; cursor, pi and grok refuse at open; kimi 2.1.1 resumed and silently kept running in A (its shell ran cd <A> && pwd), since its ACP handlers ignore cwd.

Fix: a new ACP profile flag resumeKeepsSessionCwd, set for kimi. Before resuming, OAR reads the session's own directory from session/list (paged) and refuses a resume that names another directory, naming both. Unit tests with the fake ACP agent (refused elsewhere, opens in its own directory, unchecked without the flag); live: kimi's B resume is now refused, and live-contract kimi --only basic,resume passes.

Context: Ferry is adding "change a session's working directory" (resume natively where supported, handoff otherwise); this makes "try resume in B, fall back on refusal" safe on every runtime.

pnpm run typecheck, pnpm run lint, npx vitest run pass.

🤖 Generated with Claude Code

… the old one

Measured which runtimes resume a conversation in another working directory
(experiments/resume-other-cwd.ts, docs/runtimes/resume-cwd.md): claude and
codex do; cursor, pi and grok refuse at open; kimi 2.1.1 resumed and kept
running in the session's original directory (its shell ran `cd <A> && pwd`),
because its ACP handlers ignore `cwd`.

A host asked for directory B and got A without a word. The kimi profile now
sets `resumeKeepsSessionCwd`: before resuming, OAR reads the session's own
directory from `session/list` and refuses a resume that names another one,
naming both. Verified live: the B resume is refused; resuming in A still
passes the live `resume` scenario.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@xxchan
xxchan merged commit 5061485 into main Oct 3, 2026
12 checks passed
@xxchan
xxchan deleted the fix/kimi-resume-cwd branch October 3, 2026 12:56
@xxchan xxchan mentioned this pull request Oct 3, 2026
xxchan added a commit that referenced this pull request Oct 3, 2026
Patch release: #101 refuses a kimi resume that names another directory
(kimi resumed and kept running in the session's original directory),
with the cross-runtime measurement in docs/runtimes/resume-cwd.md.
Version bump only.

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

Co-authored-by: exe.dev user <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
stamp-build Bot added a commit that referenced this pull request Oct 29, 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_8f5888ed89d7bdb917b7154754b6d3a8"><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 -->

Hosts need to choose process isolation and see what an opened session
actually uses. Runtime instances now accept `auto`, `shared` or
`isolated` through `withPlacement`; 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 raise
`UnsupportedOptionError`. 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 `open` request at sequence 0
and `opened` response 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; `defineRuntime` supplies 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, returns
`Session.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 check` passed (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.

---------

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

1 participant