Repository navigation
Description
Summary
An existing session cannot be switched to a different model if omp fails to restore the model saved in that session. The model picker opens and sends the requested set_model command, but the server first resumes the session with its saved model. omp exits during restoration, before the requested model change can run. The composer continues to show the old model without a visible switch-failure explanation.
Observed reproduction
Verified through the actual browser UI against a locally running omp-web instance (not a mocked request):
- Open an existing session whose saved model is
anthropic/claude-sonnet-5-5. No live omp wrapper is running for the session:GET /api/agent/<session-id>returns{"running":false}. - Open the composer model picker. It is enabled and lists alternate models.
- Select
october / gpt-6.1-sol. - Observe the request and response below.
The provider/model names identify the observed case; the replacement model was present in the picker, but its inference availability was not tested. It is not necessary to send a chat message to reproduce the failure.
Request
POST /api/agent/<session-id>
{
"type": "set_model",
"provider": "october",
"modelId": "gpt-6.1-sol"
}Actual result
HTTP 500. Relevant response error (bundle stack omitted):
Error: omp exited (code 1, signal none):
error: Could not restore model anthropic/claude-sonnet-5-5
The composer still displays claude-sonnet-5-5; a subsequent state read still returns running:false. No successful model switch or chat inference was observed. No messages were sent and no session files were manually edited during this check.
Expected behavior
An explicit selection of a replacement model should allow the same session to start with that model even if its previously saved model can no longer be restored. Preserve the session ID, history, and active branch. If the requested replacement also cannot be used, show an actionable error and do not report a successful switch.
Current upstream code path
Checked upstream main at 8888c15:
- app/api/agent/[id]/route.ts, lines 86–94: await
startRpcSession(...)beforesession.send(body). - lib/rpc-manager.ts, lines 195–222: resume arguments include
--resume <session-file>, but do not receive the replacement model from the pendingset_modelrequest. - hooks/useAgentSession.ts, lines 3116–3139: model-switch failures are only logged with
console.error.
The observed error is an omp startup/model-restoration failure, not a missing picker request or a failure to load the model catalog. Why this particular saved model cannot be restored was not established. The exact deployed omp-web and omp version strings were not captured during reproduction; the source revision above is the upstream revision inspected.
Suggested investigation / fix direction (not yet verified)
- Keep the existing RPC path for a live omp process.
- When
set_modelrequires spawning/resuming omp, pass the explicitly selected model into startup so recovery does not depend on restoring the old model first. - omp advertises both
--resumeand--model. First verify on an isolated session that--resume <file> --model <provider/model>takes precedence over an unavailable saved model. If it does not, this also needs an omp-side restoration/precedence fix. This combined behavior has not been tested. - Surface model-switch failures in the UI and reconcile the displayed model from authoritative state after success.
- Do not silently choose a default model, fork the session, or rewrite JSONL as a workaround.
Acceptance / regression scenarios
- No live child + unrestorable saved model + valid replacement: switching succeeds in the same session.
- Session ID, existing history, and active branch are preserved; the selected model survives reload and process restart.
- Existing live-process model switching remains functional.
- Invalid/unavailable replacement: visible error, no false success, no unintended history/branch change.
Related history checked
- 81767f4 — make model switching responsive: switching responsiveness/rollback, not the cold-start restoration ordering.
- 413cc2f — keep model picker visible on model errors and 316b547 — surface model runtime errors: related error presentation, not a direct fix for this path.
- [Bug] "RPC response exceeded the transport limit" when fetching large model catalog #1 / Fix RPC v2 negotiation for large model catalogs #3 concern large model catalogs and RPC transport negotiation, a different failure.
No matching report for Could not restore model or direct cold-start model-switch fix was found in the upstream issue/PR and commit search.
Activity
fix(agent): recover cold model switches with --model at spawn (#277)
fix(agent): recover cold model switches with --model at spawn (#277) (#…