[PR #5843] feat: support configuring a default_agent across all API/user surfaces #11610

Closed
opened 2026-02-16 18:16:29 -05:00 by yindo · 0 comments
Owner

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

State: closed
Merged: Yes


This PR supports defining a default_agent in opencode config (TUI, CLI, desktop, GitHub) so that opencode uses that from the outset. It also expands existing cases where users can provide an --agent flag to warn if their specified agent isn't found and fall back to "build" (existing behaviour, just not explicit to a user).

Changes

  • adds default_agent field to config schema (Config.Info)
  • adds default field to Agent.Info schema so clients (TUI, desktop) know which agent is the default
  • adds Agent.defaultAgent() helper that resolves the configured default agent
  • updates all hardcoded "build" fallbacks to use Agent.defaultAgent()
  • updates TUI to select the default agent on initialization (was just picking first agent)
  • adds agent input to GitHub Action for per-workflow override
  • updates documentation for config and GitHub Action
  • regenerates SDK types

Validation

  • only primary agents can be set as the default (not subagents like explore)
  • can be a built-in agent (build, plan) or a custom agent defined in config
  • invalid/missing agents log a warning: default agent "{name}" not found. Falling back to "build"

Usage

{
  "$schema": "https://opencode.ai/config.json",
  "default_agent": "plan"
}
# GitHub Action
- uses: sst/opencode/github@latest
  with:
    model: anthropic/claude-sonnet-4-20250514
    agent: docs  # overrides the config default
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/5843 **State:** closed **Merged:** Yes --- This PR supports defining a `default_agent` in opencode config (TUI, CLI, desktop, GitHub) so that opencode uses that from the outset. It also expands existing cases where users can provide an `--agent` flag to warn if their specified agent isn't found and fall back to `"build"` (existing behaviour, just not explicit to a user). #### Changes - adds `default_agent` field to config schema (`Config.Info`) - adds `default` field to `Agent.Info` schema so clients (TUI, desktop) know which agent is the default - adds `Agent.defaultAgent()` helper that resolves the configured default agent - updates all hardcoded `"build"` fallbacks to use `Agent.defaultAgent()` - updates TUI to select the default agent on initialization (was just picking first agent) - adds `agent` input to GitHub Action for per-workflow override - updates documentation for config and GitHub Action - regenerates SDK types #### Validation - only **primary agents** can be set as the default (not subagents like `explore`) - can be a built-in agent (`build`, `plan`) or a custom agent defined in config - invalid/missing agents log a warning: `default agent "{name}" not found. Falling back to "build"` #### Usage ```json { "$schema": "https://opencode.ai/config.json", "default_agent": "plan" } ``` ```yaml # GitHub Action - uses: sst/opencode/github@latest with: model: anthropic/claude-sonnet-4-20250514 agent: docs # overrides the config default ```
yindo added the pull-request label 2026-02-16 18:16:29 -05:00
yindo closed this issue 2026-02-16 18:16:29 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#11610