Describe the bug
Summary
When a custom agent's filename differs from its frontmatter name field, two issues occur:
- The agent appears duplicated in the
/agent selection menu (one entry from the filename, one from the name field).
- After session restart, the CLI fails to find the previously selected agent with error:
Custom agent "xxx" not found.
Environment
- GitHub Copilot CLI version: v1.0.16-1
- Model: Claude Opus 4.6 (6x) (high)
- OS: Ubuntu 24.04.4 LTS (WSL2) on Windows
- Kernel: Linux 6.6.87.2-microsoft-standard-WSL2 aarch64
- Node.js: v24.14.0
- Agent directory:
~/.copilot/agents/
Agent Configuration
Two custom agent files exist in ~/.copilot/agents/:
| File |
Frontmatter name |
azure-expert.md |
azure-solution-expert |
azure-aws-doc.md |
azure-vs-aws-compare-expert |
Note: the filename and the name field in frontmatter are intentionally different.
Steps to Reproduce
Bug 1: Duplicate agent entry
- Create a custom agent file at
~/.copilot/agents/azure-expert.md with frontmatter name: azure-solution-expert
- Start
ghcp
- Run
/agent to open the agent selection menu
Expected: The agent should appear once in the list.
Actual: The agent appears twice:
Select Agent:
1. Default (deselect current agent)
> 2. azure-solution-expert (current)
3. azure-solution-expert · user <-- duplicate
4. azure-vs-aws-compare-expert · user
Bug 2: Agent not found after restart
- Select the custom agent
azure-solution-expert via /agent
- Restart the CLI session (close and reopen, or the session restarts automatically)
Expected: The agent should be loaded successfully on restart.
Actual: Error message on startup:
✗ Custom agent "azure-solution-expert" not found. Available agents: azure-aws-doc, azure-expert
● Environment loaded: 5 MCP servers, 1 skill, 2 agents
● Selected custom agent: azure-solution-expert
The "Available agents" list uses filenames (azure-aws-doc, azure-expert), but the persisted selection uses the frontmatter name (azure-solution-expert). The lookup fails because these don't match.
Root Cause Analysis
The CLI appears to use two different identifiers for agents inconsistently:
- Agent selection/persistence: Uses the
name field from the agent file's YAML frontmatter
- Agent lookup on restart: Uses the filename (without
.md extension)
When filename ≠ frontmatter name, the agent:
- Gets registered under both identifiers → duplicate in list
- Gets persisted by frontmatter name but looked up by filename on restart → not found error
Expected Behavior
- The agent should appear exactly once in the selection list regardless of whether the filename matches the frontmatter
name field.
- The CLI should use a consistent identifier (either filename or frontmatter
name, not both) for selection, persistence, and lookup.
- If the frontmatter
name takes priority over the filename, the persisted selection should resolve correctly on restart.
Screenshot

Workaround
Rename the agent file to match the frontmatter name field:
mv ~/.copilot/agents/azure-expert.md ~/.copilot/agents/azure-solution-expert.md
mv ~/.copilot/agents/azure-aws-doc.md ~/.copilot/agents/azure-vs-aws-compare-expert.md
Labels
bug, custom-agents, cli
Affected version
No response
Steps to reproduce the behavior
No response
Expected behavior
No response
Additional context
No response
Describe the bug
Summary
When a custom agent's filename differs from its frontmatter
namefield, two issues occur:/agentselection menu (one entry from the filename, one from thenamefield).Custom agent "xxx" not found.Environment
~/.copilot/agents/Agent Configuration
Two custom agent files exist in
~/.copilot/agents/:nameazure-expert.mdazure-solution-expertazure-aws-doc.mdazure-vs-aws-compare-expertNote: the filename and the
namefield in frontmatter are intentionally different.Steps to Reproduce
Bug 1: Duplicate agent entry
~/.copilot/agents/azure-expert.mdwith frontmattername: azure-solution-expertghcp/agentto open the agent selection menuExpected: The agent should appear once in the list.
Actual: The agent appears twice:
Bug 2: Agent not found after restart
azure-solution-expertvia/agentExpected: The agent should be loaded successfully on restart.
Actual: Error message on startup:
The "Available agents" list uses filenames (
azure-aws-doc,azure-expert), but the persisted selection uses the frontmattername(azure-solution-expert). The lookup fails because these don't match.Root Cause Analysis
The CLI appears to use two different identifiers for agents inconsistently:
namefield from the agent file's YAML frontmatter.mdextension)When filename ≠ frontmatter name, the agent:
Expected Behavior
namefield.name, not both) for selection, persistence, and lookup.nametakes priority over the filename, the persisted selection should resolve correctly on restart.Screenshot
Workaround
Rename the agent file to match the frontmatter
namefield:Labels
bug,custom-agents,cliAffected version
No response
Steps to reproduce the behavior
No response
Expected behavior
No response
Additional context
No response