Custom-agent session creation races deferred worktree checkout and fails with “Custom agent not found”
Nobody has claimed this yet.
- Dominant language
- No language data
- Stars
- 2.1k
- Forks
- 157
- PR merge metrics
- No merged PRs in 30d
Description
Short summary
Custom-agent session creation races deferred worktree checkout and fails with “Custom agent not found”
Affected version or release
1.1.19
Installation context
- GitHub Copilot App:
1.1.19 - Bundled Copilot CLI:
1.0.84-4 - OS: Windows 11, x86_64
- Project type: local Git repository
- Session workspace type: worktree
What happened?
Starting a new worktree session with a repository-defined custom agent selected for the initial kickoff intermittently or consistently fails with:
Failed to create session: RPC error -32603: Request session.create failed with message: session construction failed: Custom agent 'orchestrator' not found
Repository setup
The default branch contains:
.github/
└── agents/
└── orchestrator.agent.md
The agent is visible in the custom-agent selector before session creation.
Steps to reproduce
- Open a local Git repository in GitHub Copilot App.
- Commit a user-invocable custom agent to:
.github/agents/orchestrator.agent.md. - Create a new worktree-backed session.
- Select
orchestratoras the custom agent. - Provide an initial kickoff prompt so the session starts immediately.
- Create the session.
Session creation fails:
RPC error -32603: Request session.create failed with message:
session construction failed: Custom agent 'orchestrator' not found
The worktree itself is created, but its session does not start with the selected agent.
Expected behavior
The application completes checkout of the new worktree before constructing the session, or resolves the selected repository agent from the project's existing checkout.
The worktree session starts using the selected orchestrator agent.
Additional context
Impact
Repository custom agents cannot reliably be selected when creating worktree-backed sessions with an initial prompt.
Suspected cause
Worktree creation and session construction are running concurrently:
- An incomplete worktree is exposed with
deferred_checkout=true. session.createperforms repository configuration discovery..github/agents/has not been populated yet.- Validation of the selected agent fails.
- Deferred checkout completes afterward.
Log evidence
The relevant sequence is:
12:02:07.979 create worktree completed
deferred_checkout=true
12:02:08.327 kickoff: creating session
12:02:08.334 session.create begins with
enable_config_discovery=true
12:02:08.621 session creation failed:
Custom agent 'orchestrator' not found
12:02:10.864 deferred worktree checkout complete
Suggested fixes
- Make agent-dependent
session.createwait for deferred checkout completion. - Resolve the selected repository custom agent from the project's fully populated main checkout while the worktree is being initialized.
- Preload the selected agent profile before beginning deferred checkout.
- Disable deferred checkout when the kickoff specifies a repository-defined custom agent.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing session.create and deferred worktree checkout using the reproduction steps and the provided log sequence. Inspect how .github/agents/orchestrator.agent.md is discovered before and after checkout. Done means a worktree-backed kickoff reliably starts with the selected repository agent, with the checkout and session construction ordering covered by the project's relevant tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- git, github
- Domain
- desktop, developer-experience
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100