Visitar URL original
bug: Coder Agents built-in execute/file tools can't target a specific agent in multi-root-agent workspaces · Issue #30503 · coder/coder · GitHub
Skip to content

bug: Coder Agents built-in execute/file tools can't target a specific agent in multi-root-agent workspaces #30503

Description

@phachey-aurorasolar

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

For a chat's built-in workspace tools (execute, read_file, write_file, edit_files, process_output, process_list, process_signal), the agent to connect to is resolved once per chat, not per tool call, via agentselect.FindChatAgent (coderd/x/chatd/agentselect/agentselect.go):

  1. Filters to root agents only (ParentID null) — this is a separate path from the devcontainer sub-agent issues above.
  2. Sorts deterministically by DisplayOrder ASC, then Name ASC (case-insensitive), then Name ASC, then ID ASC.
  3. If exactly one root agent's name ends in the suffix -coderd-chat, uses it.
  4. If zero agents match that suffix (the common case — most templates don't name agents this way), it silently falls back to whichever root agent sorts first. There is no prompt, no error, no indication to the user which agent was picked.
  5. If more than one agent matches the suffix, it errors.

None of the built-in tool argument schemas (ExecuteArgs, ReadFileArgs, etc. in coderd/x/chatd/chattool/) have an agent-selection field, so once a chat is bound to an agent via step 4 above, there is no way to redirect subsequent tool calls to a different root agent in the same workspace — not via a tool argument, not via a chat setting.

The -coderd-chat naming convention is explicitly flagged in source as a stopgap: "Suffix marks chat-designated agents during the current PoC. This naming convention is an implementation detail, not a stable contract."

Relevant Log Output

N/A — this is a source-code analysis of deterministic selection logic, not a runtime error with logs to attach.

Expected Behavior

For a composite/multi-root-agent template (e.g. a workspace with separate frontend, backend, and database agents, each a distinct root coder_agent resource with no parent/child relationship), the user should be able to either:

  • See which agent the chat is currently targeting, and/or
  • Explicitly pick or switch the target agent for a chat (or per tool call), rather than relying on alphabetical/DisplayOrder sort order as a silent default.

For comparison, the newer MCP-exposed tool family (codersdk/toolsdk, e.g. coder_workspace_execute) already solves this cleanly: its workspace argument accepts [owner/]workspace[.agent], and findWorkspaceAndAgent (codersdk/toolsdk/workspaceagent.go) explicitly errors ("multiple agents found, please specify the agent name...") rather than silently guessing when the target is ambiguous. The chatd built-in tools used by the Coder Agents chat UI don't have an equivalent mechanism.

Steps to Reproduce

  1. Create a template with 3+ separate root coder_agent resources (no devcontainers, no parent/child relationship) and none named with a -coderd-chat suffix.
  2. Start a Coder Agents chat against a workspace from that template.
  3. Ask the chat to run a shell command.
  4. Observe it silently runs against whichever agent sorts first alphabetically (or by DisplayOrder), with no way to confirm or change which agent was used, and no way to target a different one later in the same chat.

Environment

  • Host OS: N/A (control-plane logic, not host-dependent)
  • Coder version: confirmed present as of main @ a4b68ac (2026-10-08) and the pinned release v2.36.4+10fd510. agentselect.go is byte-identical between the two, so this isn't a regression — it's present in both.

Additional Context

The issue occurs consistently, I have tested this on the latest version

Activity

  1. linear-code commented on Oct 8, 2026

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions