Skip to content

fix: honor --model for reconnect prompts#211

Open
skywills wants to merge 7 commits intoopenclaw:mainfrom
nathapp-io:feat/model-per-prompt-rebase
Open

fix: honor --model for reconnect prompts#211
skywills wants to merge 7 commits intoopenclaw:mainfrom
nathapp-io:feat/model-per-prompt-rebase

Conversation

@skywills
Copy link
Copy Markdown

@skywills skywills commented Apr 2, 2026

Summary

This PR fixes a reconnect-session regression where prompt with session and model (for example, model haiku with Claude) could still run on the previously active model after session load/reconnect.

Root Cause

Per-command session options were not consistently preserved through reconnect and queue-owner prompt paths, and the reconnect prompt flow did not always enforce requested model application before prompt execution.

Changes

  • Add undefined-safe session option merge helper in session runtime and prompt runner.
  • Ensure per-command session options are threaded through queued prompt execution path.
  • Merge command-level session options over persisted session defaults when building reconnect clients.
  • Apply requested model via session config option before prompt execution in reconnect flow.
  • Add integration regression test that verifies prompt with session and model applies model update on existing session before prompt.

Files Changed

  • src/session-runtime.ts
  • src/session-runtime/prompt-runner.ts
  • test/integration.test.ts

Validation

  • pnpm run lint
  • pnpm run typecheck
  • Manual reproduction:
    • npx tsx src/cli.ts --model haiku claude prompt -s acpx-test-model "What is your model name"
    • Confirmed model response switched to Claude Haiku.
    • npx tsx src/cli.ts --model sonnet claude prompt -s acpx-test-model "What is your model name"
    • Confirmed model response switched back to Sonnet.

Notes

  • Local scratch file test.text is untracked and excluded from this PR.

subrina.tai and others added 7 commits April 2, 2026 14:14
…_meta

Previously --model was only applied during session/new (createSession).
This meant any prompt to a live session silently ignored the model flag.

Changes:
- SessionSendOptions: add sessionOptions field
- QueueOwnerRuntimeOptions + SessionSendLike: add sessionOptions field
- queueOwnerRuntimeOptionsFromSend: propagate sessionOptions
- runSessionQueueOwner: pass sessionOptions to sharedClient
- RunSessionPromptOptions: add sessionOptions field
- withConnectedSession (prompt-runner): pass sessionOptions to AcpClient
- loadSessionWithOptions (client): include _meta from sessionOptions
- CLI prompt command: wire globalFlags.model/allowedTools/maxTurns into sendSession

Fixes: model flag silently ignored on live sessions (queue owner running)
…sion model switch

- queue-owner-env: parse sessionOptions from ACPX_QUEUE_OWNER_PAYLOAD
- session-runtime: route set_config_option through sharedClient live connection
- client: add updateSessionOptions() for runtime model updates

Fixes mid-session model switching and first-prompt model selection.
client.ts routed model changes through session/set_model (unstable_setSessionModel)
which bypassed the Claude adapter's resolveModelPreference fuzzy matching.
Model aliases like 'sonnet' or 'haiku' were passed raw to query.setModel()
which didn't resolve them.

Now tries session/set_config_option first (which has alias resolution on the
adapter side), then falls back to session/set_model for adapters like Droid
that only support the dedicated method.
runQueuedTask never saved the session record to disk after runSessionPrompt,
so when loadSession failed and a fresh session was created with a new
acpSessionId, subsequent control commands (e.g. model switch) read the stale
record from disk and got 'Session not found' from the adapter.

Now writes the record after each prompt in the queue owner, ensuring
set_config_option fallback sees the correct acpSessionId.
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