Skip to content

Repository-level custom agents resolved relative to git root, but skills and .mcp.json relative to cwd #3688

@NiceAsiv

Description

@NiceAsiv

Describe the bug

The three repository-scoped customization sources are discovered using two
different base directories:

Source Discovered at Base directory
Custom agents <git-root>/.github/agents/ git root
Skills <cwd>/.github/skills/ cwd
MCP servers <cwd>/.mcp.json cwd

Because agents are bound to the git root while skills and MCP are bound to the
current working directory, it is impossible to keep all three together in a
subdirectory of a repository. In a monorepo (or any repo where you want to keep
Copilot config in a subfolder, e.g. agent/), you must either:

  • put .github/agents/ at the git root (so the agent loads) — but then skills
    and .mcp.json must ALSO be at the git root, forcing you to run from the git
    root and scattering config across the tree; or
  • copy the agent into the user-level ~/.copilot/agents/ directory, which is
    machine-global and not committed to the repo.

There is no cwd from which a subdirectory-local agent + skills + MCP all load
together.

Affected version

GitHub Copilot CLI 1.0.60-0 (Windows)

Steps to reproduce the behavior

  1. In a git repo, create a subdirectory sub/ and place all three there:
    • sub/.github/agents/myagent.agent.md
    • sub/.github/skills/myskill/SKILL.md
    • sub/.mcp.json
  2. cd sub and run copilot --agent myagent -p "...".
    • Skills and MCP from sub/ do load (cwd-relative).
    • The agent does not load: No such agent: myagent, available: (empty).
  3. Run the same command from the git root — the agent still does not load,
    because <git-root>/.github/agents/ does not exist.
  4. Move .github/ and .mcp.json up to the git root and run from the git root —
    now all three load. This is the only working layout, and it forces config to
    the git root.

A sharper probe: with an agent at <git-root>/.github/agents/A.agent.md AND a
different agent at <git-root>/sub/.github/agents/B.agent.md, running from
cwd=<git-root>/sub lists only A (the git-root one), never B. This shows the
loader goes straight to the git root rather than searching upward from cwd the
way skills do.

Expected behavior

Custom agents should be discoverable using the same base directory as skills and
MCP (cwd, ideally searching upward toward the git root), OR there should be a
configurable agentDirectories setting analogous to skillDirectories, so that
agents + skills + MCP can be co-located in a subdirectory and loaded together.

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:agentsSub-agents, fleet, autopilot, plan mode, background agents, and custom agentsarea:configurationConfig files, instruction files, settings, and environment variables

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions