Workspace custom agents disappear after Copilot Chat extension-host stalls; file watcher event restores them without reload
- Dominant language
- TypeScript
- Stars
- 193k
- Forks
- 42.4k
- PR merge metrics
- PR metrics pending
Description
# Workspace custom agents disappear after Copilot Chat extension-host stalls; file watcher event restores them without reload
## Type of issue
Bug
## Environment
- VS Code: 1.137.0
- Bundled GitHub Copilot Chat: 0.65.0
- OS: Windows 11 Home 64-bit, 10.0.26200
- Workspace: multi-root workspace with local Windows folders and one WSL UNC folder
- Custom agents: workspace `.github/agents/*.agent.md` files (not Copilot CLI plugin agents)
## Summary
Workspace custom agents intermittently disappear from the Chat agent picker and cannot be invoked by exact name. Their source files remain present and valid. A normal `Developer: Reload Window` restores them, but this interrupts active work.
A less disruptive and consistently successful workaround is to create and immediately delete a valid, non-invocable temporary `.agent.md` file in the same `.github/agents` folder. The resulting file-watcher event refreshes custom-agent discovery, and the missing agents become invocable again without reloading the window.
The disappearance correlates with Copilot Chat making the local extension host temporarily unresponsive. In two automatically captured profiles, `github.copilot-chat` accounted for approximately 97–99% of the sampled extension-host CPU time.
## Steps to reproduce
The exact trigger is intermittent, but this sequence has reproduced multiple times:
1. Open a multi-root workspace containing many valid workspace custom agents under `.github/agents/`.
2. Work in several Copilot Chat sessions for an extended period.
3. Observe temporary local extension-host stalls in `renderer.log` attributed almost entirely to `github.copilot-chat`.
4. Later, open the Chat agent picker or invoke a known custom agent by its exact frontmatter `name`.
5. Observe that agents which were previously available are missing, and named invocation returns:
```text
Requested agent '' not found. Try again with the correct agent name, or omit agentName to use the current agent.
```
6. Confirm that the corresponding `.github/agents/*.agent.md` files still exist and are valid.
7. Create a temporary valid agent file in `.github/agents`, for example:
```markdown
---
name: "Temporary Custom Agent Refresh"
description: "Temporary file used only to trigger custom-agent discovery."
user-invocable: false
disable-model-invocation: true
---
Temporary discovery trigger.
```
8. Delete that temporary file immediately.
9. Retry invocation of the previously missing custom agent.
10. Observe that it succeeds without a window reload.
## Actual behavior
- Workspace agent files remain present and valid.
- Agents disappear from the picker/runtime registry.
- Exact-name subagent invocation reports `Requested agent ... not found`.
- There is no dedicated public command to refresh custom-agent discovery.
- Reloading the window restores the agents, but disrupts active sessions.
- A create/delete watcher event in `.github/agents` restores discovery immediately.
Representative sanitized timeline:
```text
20:38:18 Extension host is unresponsive
20:38:24 github.copilot-chat took 99.35% of a ~4.98 s CPU profile
20:38:32 Extension host is responsive
20:39:26 Extension host is unresponsive
20:39:32 github.copilot-chat took 97.45% of a ~4.88 s CPU profile
20:39:38 Extension host is responsive
21:30:10 Requested agent '' not found
21:34:02 Requested agent '' not found
21:38:45 Requested agent '' not found
Immediately afterward: exact-name invocation of workspace agent B succeeds
```
Two CPU profiles were generated automatically by VS Code and are available after privacy review if maintainers need them.
## Expected behavior
- Valid workspace custom agents should remain registered for the lifetime of the workspace.
- A temporary extension-host stall should not leave the custom-agent discovery cache incomplete or stale.
- If discovery becomes invalid, VS Code should recover automatically when the extension host becomes responsive.
- Ideally, expose a supported `Refresh Custom Agents` command so users do not have to reload the window or synthesize a file-system event.
## Related issues
- #333434 is similar in the user-visible symptom, but concerns Copilot CLI plugin agents and stale plugin nonces. This report concerns ordinary workspace `.github/agents/*.agent.md` files.
- #332344 / #332347 concern selected-agent/list behavior in Claude/Copilot harnesses, but not this extension-host-stall plus watcher-refresh recovery pattern.
- #331632 reports disappearing chat state around a degraded extension-host/update scenario; this report has direct extension-host CPU profiling and a deterministic no-reload recovery through custom-agent file discovery.
## Extension isolation
This cannot be reproduced with all extensions disabled because GitHub Copilot Chat/custom agents are the affected feature. No third-party custom-agent provider is involved in these workspace agents.
## Privacy
Paths, organization names, agent names, workspace contents, account identifiers, and prompt contents have been removed from this report.
Contributor guide
Assessment
This issue has not been assessed yet.