Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@vtemian
Copy link
Contributor

@vtemian vtemian commented Dec 31, 2025

Summary

When a command runs with a subagent (e.g., /init with project-initializer), the TUI incorrectly shows an "Agent not found" toast error.

Related issues

#6518

Root Cause

The code added in #6325 (variants toggle) syncs the agent from the last user message to the TUI:

if (msg.agent) local.agent.set(msg.agent)

However, local.agent.list() only includes primary agents (mode !== 'subagent'), so when a command runs with a subagent, the set() call fails and shows the toast.

The backend correctly creates and runs the subagent session - only the TUI display has this bug.

Fix

Check if the agent exists in the primary agents list before attempting to set it:

if (msg.agent && local.agent.list().some((x) => x.name === msg.agent)) local.agent.set(msg.agent)

Testing

  1. Create a custom command that uses a subagent (e.g., /init with agent: "my-subagent")
  2. Run the command
  3. Before: "Agent not found: my-subagent" toast appears
  4. After: No toast, command runs correctly

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 ed0c0d9 (feat: add variants toggle sst#6325)
@vtemian vtemian force-pushed the fix/subagent-toast-error branch from ba3916a to 237e6f8 Compare December 31, 2025 14:14
@rekram1-node rekram1-node merged commit 87f9ebd into anomalyco:dev Dec 31, 2025
2 checks passed
rekram1-node added a commit that referenced this pull request Dec 31, 2025
burgercrisis pushed a commit to burgercrisis/opencode that referenced this pull request Dec 31, 2025
rekram1-node added a commit that referenced this pull request Jan 1, 2026
hk9890 pushed a commit to hk9890/opencode that referenced this pull request Jan 1, 2026
hk9890 pushed a commit to hk9890/opencode that referenced this pull request Jan 1, 2026
hk9890 pushed a commit to hk9890/opencode that referenced this pull request Jan 1, 2026
ariane-emory pushed a commit to ariane-emory/opencode that referenced this pull request Jan 1, 2026
dl-alexandre pushed a commit to dl-alexandre/opencode that referenced this pull request Jan 2, 2026
dl-alexandre pushed a commit to dl-alexandre/opencode that referenced this pull request Jan 2, 2026
dl-alexandre pushed a commit to dl-alexandre/opencode that referenced this pull request Jan 2, 2026
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.

2 participants