Skip to content

[Bug] Cannot switch models when resuming a session whose saved model cannot be restored #277

Closed

Description

@cloudwindy

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):

  1. 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}.
  2. Open the composer model picker. It is enabled and lists alternate models.
  3. Select october / gpt-6.1-sol.
  4. 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:

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_model requires spawning/resuming omp, pass the explicitly selected model into startup so recovery does not depend on restoring the old model first.
  • omp advertises both --resume and --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

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions