Skip to content

feat: add a default agent setting for new chats and sessions - #47

Closed
YunFeng0817 wants to merge 1 commit into
koltyakov:mainfrom
YunFeng0817:feat/chat-default-agent
Closed

YunFeng0817 wants to merge 1 commit into
koltyakov:mainfrom
YunFeng0817:feat/chat-default-agent

Conversation

@YunFeng0817

@YunFeng0817 YunFeng0817 commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Why

I use a custom primary agent defined in opencode.json, and it is the agent I want for essentially every chat. Varro starts each new chat and session with Build, so I re-select my agent every single time. Models and per-session choices are already remembered; the agent for new chats is not.

This adds a setting for it. varro.chat.defaultAgent names the primary agent that new chats and sessions start with, so a custom agent can simply be the default.

// User settings.json (the setting is application scoped)
{ "varro.chat.defaultAgent": "my-agent" }

What it does

  • Empty (default): exactly the current behaviour. Build is used, or the first primary agent when no Build is configured.
  • Set to a loaded primary agent: new chats, fresh drafts after a reload, and new sessions start with that agent. Custom agents defined in your OpenCode configuration work the same as built-in ones.
  • Set to an unknown, removed, hidden, or subagent name: ignored, Build is used instead. A typo cannot leave the picker on something that is not selectable.

A session's own agent and an explicit pick in the composer still win where they did before, so nothing about existing sessions changes.

Relationship to the existing Build default

New drafts used to restore the stored agent selection. 98be1681 replaced that with a Build default and added tests for it (defaults fresh drafts to build even when ask was persisted); its consolidated message does not mention agents, so the test names are the only record of the intent.

The likely reason is read-only agents: Plan, and the built-in Ask agent, which denies editing tools. A restored selection can therefore make a new chat read-only without anyone asking for it.

This PR does not restore the old behaviour. It keeps Build as the default and adds an explicit way to name a different starting agent, so nothing changes unless you opt in.

Why application scope

An agent determines its own permissions and prompt, and a repository can already influence agent definitions through opencode.json. A checked-in settings.json should not also decide which agent runs your chat, so the setting follows promptCompletionModel and followupsEnabled rather than the window-scoped defaultPermissionMode.

Implementation notes

  • reconcileLoadedAgents takes a new defaultAgent argument; an empty string falls through the existing candidate predicate untouched, which is why the default path is behaviour-identical.
  • The two other resolution points (startNewChatDraft, resolveDefaultAgent) insert the configured name ahead of Build and keep their existing chains behind it.
  • Setting plumbing follows an existing string setting end to end: manifest, ExtensionConfigState, readExtensionConfigState, webview initial state, config/update parsing, app state, and the config-change listener.
  • docs/usage.md lists the setting under Chat view.

Testing

  • npm run test - 411 files, 10835 tests pass
  • npm run typecheck and npm run typecheck:suggestions
  • npm run lint, npm run fmt
  • Not exercised against a live VS Code window; the setting path is covered by unit tests only.

@YunFeng0817
YunFeng0817 force-pushed the feat/chat-default-agent branch from 35b2bf7 to 8572320 Compare October 26, 2026 22:44
New chats and sessions always started with the Build agent, so anyone who
works with a custom primary agent from opencode.json, or in Plan, had to
reselect it every time.

varro.chat.defaultAgent names the primary agent those surfaces start with.
An empty value keeps the current behaviour: Build, or the first primary agent
when no Build is configured. An unknown, removed, hidden, or subagent name is
ignored, so a typo cannot leave the picker on something that is not
selectable.

New drafts used to restore the stored agent selection. 98be168 replaced that
with a Build default, and the tests it added ("defaults fresh drafts to build
even when ask was persisted") are the only record of why; its consolidated
message does not mention agents. The likely reason is read-only agents: Plan,
or the built-in Ask agent, which denies editing tools, so a restored selection
can silently make a new chat read-only.

This change keeps that Build default and makes a different starting agent an
explicit, application-scoped choice, so nothing changes for anyone who does
not opt in.

The setting is application scoped. An OpenCode agent determines its own
permissions, and a repository already influences agent definitions through
opencode.json, so a checked-in settings.json should not decide which agent
runs the chat.
@YunFeng0817
YunFeng0817 force-pushed the feat/chat-default-agent branch from 8572320 to 5885b72 Compare October 26, 2026 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant