Skip to content

Subagent identity swapping after first tool call #18404

Closed as not planned
Closed as not planned

Description

@rgasper

Description

I have a subagent setup to run a particular MCP/tool which as a lot of context instruction. Quite reliably in the latest version of opencode, after the first tool call, it reverts to the default primary agent mid-conversation and then loses access to that tool. It then delegates out to yet another subagent (which should be impossible, is explicitly banned in my config) to do further tool calls.

So a relatively complex interaction taking a few dozen tool calls will often spawn nearly two dozen subagents as each one swaps identities to the primary agent after the first tool call, loses access to the tool, gets confused, realizes it can delegate, makes new instructions, and tasks a new subagent.

Not ideal!

Plugins

superpowers

OpenCode version

1.2.27

Steps to reproduce

  1. setup a subagent with access to a specialized MCP and "task":{"*": "deny"} permissions.
  2. setup a primary agent instructed to task tool calls to that subagent and permissions denying use of that tool
  3. ask primary to perform this task

With that setup, then I'm observing the following behavior from opencode:

  1. it delegates to subagent
  2. first tool call succeeds
  3. subagent identity swaps, next tool calls fail
  4. new agent identity performs task tool call to subagent that should've been impossible

Screenshot and/or share link

This is a screenshot of the subagent session

Image

Operating System

MacOS 14.8

Terminal

Kitty

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Mar 20, 2026
  2. Vishal2002 commented on Mar 21, 2026

    @Vishal2002

    Can I work on this issue.

  3. removed
    bugSomething isn't working
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  4. github-actions commented on Jul 4, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions