Skip to content

agents.<name>.model is ignored when resolving the primary session model #362

Description

@shuv1337

Summary

A configured agents.build.model (e.g. openai/gpt-5.6-sol) is not used for the primary session's model. With no top-level model and no explicit model on session create, the runner falls back to the catalog default — "newest released available model" — which on a fresh install is a free opencode/* model.

Observed (integration-v2 @ 4668dfc, shuvcode serve --service)

  • GET /api/agent reports {"id":"build","model":{"id":"gpt-5.6-sol","providerID":"openai"}}.
  • A session created without model and prompted normally ran on {"id":"nemotron-3.5-lightning-free","providerID":"opencode"} (which then looped on provider.invalid-output).

Code path

  • packages/core/src/session/context.ts:120models.resolve(selection.session)
  • packages/core/src/session/runner/model.ts:80-83if (!session.model) resolver.resolve(); selection.agent.info.model is never consulted.
  • packages/core/src/model-resolver.ts:356-366catalog.model.default()
  • packages/core/src/catalog.ts:196-205 — no configured default ⇒ model.available()[0], sorted by time.released desc (catalog.ts:180-184).
  • Contrast: the command path does honor the agent model — packages/core/src/session.ts:710: command.model ?? commandAgent?.model ?? input.model.
  • Session.create only stores input.model (session.ts:417-421); switchAgent doesn't touch the model (session.ts:805-811).

Expected

Resolution order session.model ?? agent.model ?? config.model ?? catalog default, consistent with the command path.

Workaround

Set top-level "model" in opencode.json, or pass model on POST /api/session.

Found while running the Discord plugin (shuvcode-bot) on a fresh VM.

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