[PR #13728] feat(opencode): add defaultModel to GET /config response #14791

Open
opened 2026-02-16 18:19:33 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/13728

State: open
Merged: No


Fixes #13727

What does this PR do?

Adds the resolved default model (providerID + modelID) to the GET /config endpoint response.

Problem: When running OpenCode in headless mode (opencode serve), external clients have no way to know which model will be used until the first SSE response arrives. This makes it impossible to display "Using model: X" to users before they send their first prompt.

Solution: Call Provider.defaultModel() in the config route handler and include the result as an optional defaultModel field. This reuses the existing model resolution logic (config -> recent models -> fallback).

Changes:

  • Extended the response schema with optional defaultModel: { providerID, modelID }
  • Added ~10 lines to call Provider.defaultModel() and merge into response
  • Wrapped in try/catch to gracefully handle "no providers configured" case

How did you verify your code works?

  1. Started server with bun dev serve
  2. Verified curl localhost:4096/config now includes defaultModel
  3. Tested with no providers configured - returns config without defaultModel (no error)
  4. Tested with multiple providers - returns the correct default per existing logic
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/13728 **State:** open **Merged:** No --- Fixes #13727 ### What does this PR do? Adds the resolved default model (`providerID` + `modelID`) to the `GET /config` endpoint response. **Problem:** When running OpenCode in headless mode (`opencode serve`), external clients have no way to know which model will be used until the first SSE response arrives. This makes it impossible to display "Using model: X" to users before they send their first prompt. **Solution:** Call `Provider.defaultModel()` in the config route handler and include the result as an optional `defaultModel` field. This reuses the existing model resolution logic (config -> recent models -> fallback). **Changes:** - Extended the response schema with optional `defaultModel: { providerID, modelID }` - Added ~10 lines to call `Provider.defaultModel()` and merge into response - Wrapped in try/catch to gracefully handle "no providers configured" case ### How did you verify your code works? 1. Started server with `bun dev serve` 2. Verified `curl localhost:4096/config` now includes `defaultModel` 3. Tested with no providers configured - returns config without `defaultModel` (no error) 4. Tested with multiple providers - returns the correct default per existing logic
yindo added the pull-request label 2026-02-16 18:19:33 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14791