Skip to content

feat(serve): list the models a client may pick, set the session model and the thinking level #574

Closed

Description

@ajianaz

What problem does this solve?

The TUI lets the user see the available models, switch the model for the session (Ctrl+L picker, Ctrl+P cycle, /model) and set the thinking level (Shift+Tab, /thinking: minimal, low, medium, high, unset). tole serve has no route for any of it, so a graphical client has no model picker and no thinking selector.

Found while writing the screen inventory for #561 (screen 8, gap C). It blocks screen 8 of the desktop and web clients (#527, #529); a first mobile client (#528) can do without it.

Why this one needs care

Choosing a model also chooses what the token holder spends, and a model setting is part of what a session does later (it survives resume). So the server, not the client, has to decide which models may be picked.

Proposed solution

Three small routes, behind the existing bearer token:

  • GET /models: the models the server allows a client to pick (from the server's own configuration and the provider's /models, filtered by an allow list), plus the current default. A client can only pick from this list.
  • POST /sessions/{id}/model {"model": "<id>"}: sets the session model. It writes the same fact/model register the TUI writes, so the choice survives tole resume. 400 for an id that is not in the allowed list, 404 for an unknown session, 409 while a turn is running (the TUI refuses commands then, because they need the session lock).
  • POST /sessions/{id}/effort {"effort": "low" | ... | null}: sets or clears fact/reasoning_effort, with the same validation and refusals as --effort and /thinking.

An invalid level is refused loudly (as session_effort_e2e already tests for the CLI), never silently coerced.

Alternatives considered

  • Let the client send any model id: simplest, but the token would then choose spend and provider routing freely.
  • Only a read route (GET /models) and leave setting to the host: no picker, which is the point.

Open question for the owner

Is the model picker part of the first desktop release? If yes, this issue goes before #527 starts. If not, the first release ships a fixed model and this stays open.

Acceptance criteria

  • GET /models returns only allowed models; a model outside the list cannot be set (a test).
  • POST …/model and POST …/effort write the registers the TUI writes, and a later tole resume of the session sends them (a test next to session_model_e2e and session_effort_e2e).
  • 409 while a turn runs, 404 for an unknown session, 401 without the token, 400 for an invalid value; each has a test.
  • docs/mobile-control.md and the CHANGELOG are updated in the same PR.

Part of #523. Related: #524, #561, #573.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementpending

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions