github / github/app

Custom-agent session creation races deferred worktree checkout and fails with “Custom agent not found”

Open
#3,776 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

triage
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
  1. Open a local Git repository in GitHub Copilot App.
  2. Commit a user-invocable custom agent to:
    .github/agents/orchestrator.agent.md.
  3. Create a new worktree-backed session.
  4. Select orchestrator as the custom agent.
  5. Provide an initial kickoff prompt so the session starts immediately.
  6. 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:

  1. An incomplete worktree is exposed with deferred_checkout=true.
  2. session.create performs repository configuration discovery.
  3. .github/agents/ has not been populated yet.
  4. Validation of the selected agent fails.
  5. 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
  1. Make agent-dependent session.create wait for deferred checkout completion.
  2. Resolve the selected repository custom agent from the project's fully populated main checkout while the worktree is being initialized.
  3. Preload the selected agent profile before beginning deferred checkout.
  4. Disable deferred checkout when the kickoff specifies a repository-defined custom agent.

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.