feat: forward proposedSessionId in session/new via createSession hints#249
Open
henkterharmsel wants to merge 2 commits intoopenclaw:mainfrom
Open
feat: forward proposedSessionId in session/new via createSession hints#249henkterharmsel wants to merge 2 commits intoopenclaw:mainfrom
henkterharmsel wants to merge 2 commits intoopenclaw:mainfrom
Conversation
…n hints createSession(cwd, hints?) now accepts an optional hints object. If hints.proposedSessionId is set, it is forwarded in the _meta field of the session/new ACP request, allowing the agent (claude-agent-acp) to use it as the session ID instead of generating a random UUID. This enables ACP callers to create sessions with predictable, deterministic file names — a prerequisite for reliable session resume. Backward-compatible: omitting hints produces the same behavior as before.
Two related fixes for reliable ACP session resume:
1. proposedSessionId in createSession calls: all createSession call sites
now pass the session UUID (extracted from the session key via .split(':').pop())
as proposedSessionId. This gives Claude Code sessions a predictable, stable
file name — required for resume to work.
2. Oneshot resume double-load fix: ensureSession previously started Claude,
loaded the session, then closed it. This wrote a 'closed' marker to the JSONL
file. connectAndLoadSession (phase 2) then failed because the JSONL was already
marked closed. For oneshot sessions with a resumeSessionId, ensureSession now
skips the start/load/close cycle entirely, saves a minimal record, and returns
early. Phase 2 handles the actual resume.
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.
What
Two related fixes for reliable ACP session resume in `acpx`:
1. `createSession(cwd, hints?)` — forward `proposedSessionId`
`createSession` now accepts an optional `hints` object. When `hints.proposedSessionId` is provided, it is included in the `_meta` field of the `session/new` ACP request.
All internal `createSession` call sites in the runtime engine (`manager.ts` and `reconnect.ts`) now derive the session UUID from the ACP session key (`agent:claude:acp:` → `.split(':').pop()`) and pass it as `proposedSessionId`. This gives Claude Code sessions a stable, predictable file name — required for reliable resume.
2. Oneshot resume double-load fix
`ensureSession` (phase 1) previously started Claude, loaded the session, then shut it down via `client.close()`. This wrote a `closed` marker to the JSONL file. `connectAndLoadSession` (phase 2) then failed because the JSONL was already closed.
For oneshot sessions with a `resumeSessionId`, `ensureSession` now skips the start/load/close cycle entirely, constructs a minimal session record, and returns early. Phase 2 performs the actual resume.
Why
Without these fixes, resuming a completed oneshot session in OpenClaw always returns "Internal error". New sessions work fine; it is specifically resume that fails.
Root causes:
Backward Compatibility
Both changes are additive. Existing behavior is preserved for non-oneshot modes and sessions without a `resumeSessionId`. Passing `proposedSessionId` is opt-in.
Dependencies
This PR is part of a two-repo fix for ACP session resume. Merge order:
Note: an openclaw PR is not required. OpenClaw already passes the correct `resumeSessionId` and `sessionKey` parameters to `ensureSession` — all fixes are encapsulated in `acpx`.
Each PR is backward-compatible with the previous version of its dependency.
Testing
AI Assistance 🤖
Developed with AI assistance (Claude Code). Logic derived from locally-applied patches confirmed working. Author (Henk ter Harmsel) has reviewed and understands all changes.