From 237e6f806559f6853b589bf512a104077d3d9a68 Mon Sep 17 00:00:00 2001 From: Vlad Temian Date: Wed, 31 Dec 2025 16:14:01 +0200 Subject: [PATCH] fix(tui): don't show 'Agent not found' toast for subagents When a command runs with a subagent (e.g., /init with project-initializer), the TUI tried to set the current agent to it, which failed because local.agent.list() only includes primary agents (mode !== 'subagent'). This caused an erroneous 'Agent not found' toast even though the subagent session was created and running correctly in the backend. The fix checks if the agent exists in the primary agents list before attempting to set it. Regression introduced in ed0c0d90b (feat: add variants toggle #6325) --- .../opencode/src/cli/cmd/tui/component/prompt/index.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx b/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx index 2a0ac8461653..ab9487e1dd43 100644 --- a/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx +++ b/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx @@ -202,7 +202,11 @@ export function Prompt(props: PromptProps) { syncedSessionID = sessionID - if (msg.agent) local.agent.set(msg.agent) + // Only set agent if it's a primary agent (not a subagent) + const isPrimaryAgent = local.agent.list().some((x) => x.name === msg.agent) + if (msg.agent && isPrimaryAgent) { + local.agent.set(msg.agent) + } if (msg.model) local.model.set(msg.model) if (msg.variant) local.model.variant.set(msg.variant) }