github / github/copilot-cli

--agent <name>  doesn't recognize custom agents loaded via  --add-dir

Open
#4,752 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area:agents area:configuration
Dominant language
Shell
Stars
11.2k
Forks
1.9k
Avg merge
14h 16m
Merged PRs (30d)
6

Description

Describe the bug

Custom agents loaded from a directory passed via  --add-dir  are correctly discovered for task-tool delegation (they appear in the model's list of available sub-agents, and can be invoked by mentioning them by name in a prompt), but the top-level  --agent   flag does not recognize them. Passing  --agent   for an agent that only exists under an  --add-dir -added directory's  .github/agents/  fails with "No such agent", even when that agent's frontmatter sets  user-invocable: true .

Affected version

GitHub Copilot CLI 1.0.83

Steps to reproduce the behavior
  1. Create a custom agent at  /.github/agents/my-agent.agent.md  with  user-invocable: true  in its frontmatter.
  2. Run:
    copilot --add-dir <some-dir> -p "List every custom agent name available to you via the task tool." --allow-all-tools
    my-agent appears in the list, confirming --add-dir loaded it correctly.
  3. Run:
    copilot --add-dir <some-dir> --agent my-agent -p "hello" --allow-all-tools
    → Fails with:
    No such agent: my-agent, available: <only agents registered through other mechanisms, e.g. plugins>
Expected behavior

 --agent   should be able to select any agent discovered via  --add-dir 's  .github/agents/  directory — the same set of agents already visible to/usable by the task tool in that same session — especially when the agent explicitly sets  user-invocable: true .

Additional context

• Workaround: instead of  --agent  , invoke the agent by mentioning its name directly in the prompt, e.g.  -p "use the my-agent agent to ..." . This reliably delegates to the correct agent via the task tool.
• OS: macOS
• Shell: bash

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the behavior with --add-dir and --agent using a .github/agents/my-agent.agent.md file whose frontmatter sets user-invocable: true. Compare how the task tool discovers that agent with how the top-level --agent option validates names. Done means --agent my-agent selects the same custom agent without the “No such agent” error.

Written by the indexing model from the issue text.

Assessment

Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.