You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CustomAgents - Ignores agents loaded from .github/agents folder #1889
When you set SessionConfig.CustomAgents all agents that would be otherwise loaded from the workspace .github/agent folder are ignored
This simple examples shows the behaviour
usingGitHub.Copilot;// path to .github folder containing agents folderconststringWorkingDirectory=@"C:\SomeWorkspace";awaitusingvarclient=newCopilotClient();awaitusingvarsession=awaitclient.CreateSessionAsync(newSessionConfig{WorkingDirectory=WorkingDirectory,EnableConfigDiscovery=true,// Note that this has to be true to get any agents to load from disk - (see https://github.com/github/copilot-sdk/issues/1887)CustomAgents=[// Remove this property and you'll see that all agents are loaded from the .github/agents foldernew(){Name="Custom"}]});varagentsList=awaitsession.Rpc.Agent.ListAsync();foreach(varagentinagentsList.Agents){// You'll only see the "Custom" agent.Console.WriteLine(agent.Name);}
Agent file I was using in a .github/agents/sample.agent.md file:
---name: sampledescription: Sample Agent---
You are an sample agent for this repository, you're just happy to be here!
The agent list isn't merged together like skills, instructions and MCPs are.
Additionally, are there any plans to bring the agents loaded in via the CustomAgents property into full parity with agents loaded from the .github/agents folder? It seems that not all properties are supported, like Handoffs, which means no SessionHandoffEvent can ever be raised and agent passing can only happen via sub-agents via the task tool.
Thanks for the detailed report. I investigated the relevant code in the .NET SDK (dotnet/src/Types.cs, dotnet/src/Client.cs) and the documentation (docs/features/custom-agents.md) to understand this behavior.
What I found
The non-merging behavior is by design, not a bug. The EnableConfigDiscovery property's documentation explicitly describes what it merges:
When true, automatically discovers MCP server configurations (e.g. .mcp.json, .vscode/mcp.json) and skill directories from the working directory and merges them with any explicitly provided McpServers and SkillDirectories, with explicit values taking precedence on name collision.
Agents from .github/agents are not listed among what gets merged. The SDK simply passes both customAgents and enableConfigDiscovery as separate parameters to the Copilot CLI runtime — no merge is performed on the SDK side either. The runtime treats programmatic CustomAgents and workspace-discovered agents as distinct, non-combined sources.
This asymmetry is real — MCPs and skills are merged, but agents are not — but it reflects the current design rather than a defect.
On the Handoffs / SessionHandoffEvent parity concern
You are correct that CustomAgentConfig (in dotnet/src/Types.cs) does not expose a Handoffs property. The current public properties are: Name, DisplayName, Description, Tools, Prompt, McpServers, Infer, Skills, and Model. SessionHandoffEvent exists in the generated session events, but it can only be raised by workspace-file-based agents today.
Reclassification
Both observations — merging workspace agents with CustomAgents when EnableConfigDiscovery is true, and adding Handoffs support and other missing properties to CustomAgentConfig — represent new capabilities beyond what is currently designed and documented. I'm relabelling this as an enhancement request.
The workaround today, as you noted, is to either:
Use only CustomAgents (and duplicate any workspace agents programmatically), or
Use only EnableConfigDiscovery = true without setting CustomAgents (relying entirely on .github/agents files).
Agent merging and full CustomAgentConfig parity with workspace agents would be a valuable addition to the SDK. Leaving this open for the team to evaluate.
Thanks for the report. We've shipped fixes in this area since this was filed, and we believe this may now be resolved. Could you retest on the latest release (Copilot SDK v1.0.26, which bundles Copilot CLI v1.0.103) and let us know whether you still see it? If we don't hear back in a couple of weeks, we may close this issue — you can always reopen it.
Triaged as part of a Copilot SDK backlog review, with help from GitHub Copilot.
I executed the original .NET discovery scenario against the published GitHub.Copilot.SDK 1.0.34 NuGet package and runtime 1.0.112. The workspace agent is now merged with the explicitly supplied agent:
Configuration
Actual agent names
Workspace .github/agents/sample.agent.md only
sample
Same workspace plus CustomAgents=[new(){Name="Custom"}]
Custom, sample
The fixture uses the default CopilotCli client mode, EnableConfigDiscovery=true, an isolated Git-initialized workspace, and no CustomAgentsLocalOnly override. It does not need model inference. Equivalent Node checks passed on SDK/runtime 1.0.34/1.0.112 and 2.0.0/1.0.113.
This supersedes the earlier comment's claim that explicit and discovered agents are intentionally never merged.
Leaving this issue open: its additional request for full programmatic-agent property parity, specifically Handoffs / SessionHandoffEvent, is distinct. The list-merging check neither demonstrates nor implements that feature, so a passing original repro is not proof that the whole issue is addressed.
usingGitHub.Copilot;usingSystem.Diagnostics;usingSystem.Text.Json;vardirectory=Path.Combine(args[0],$"discovery-{Guid.NewGuid():N}");Directory.CreateDirectory(Path.Combine(directory,"tmp"));Directory.CreateDirectory(Path.Combine(directory,".github","agents"));File.WriteAllText(Path.Combine(directory,".github","agents","sample.agent.md"),"---\nname: sample\ndescription: Sample workspace agent\n---\nYou are the workspace discovery fixture.\n");using(vargit=Process.Start(newProcessStartInfo("git"){ArgumentList={"init","--quiet",directory},UseShellExecute=false,})!){awaitgit.WaitForExitAsync();if(git.ExitCode!=0)thrownewException("git init failed");}awaitusingvarclient=newCopilotClient(newCopilotClientOptions{Connection=RuntimeConnection.ForStdio(args[1]),Mode=CopilotClientMode.CopilotCli,BaseDirectory=directory,WorkingDirectory=directory,UseLoggedInUser=false,Environment=newDictionary<string,string>{["PATH"]=Environment.GetEnvironmentVariable("PATH")!,["HOME"]=directory,["TMPDIR"]=Path.Combine(directory,"tmp"),},});varresults=newList<object>();foreach(varexplicitAgentsinnew[]{false,true}){awaitusingvarsession=awaitclient.CreateSessionAsync(newSessionConfig{Model="gpt-4.1",Provider=newProviderConfig{Type="openai",BaseUrl="http://127.0.0.1:9/v1",ApiKey="local"},WorkingDirectory=directory,EnableConfigDiscovery=true,AvailableTools=[],OnPermissionRequest=PermissionHandler.ApproveAll,CustomAgents=explicitAgents?[new(){Name="Custom"}]:null,});varlisted=awaitsession.Rpc.Agent.ListAsync();varnames=listed.Agents.Select(agent =>agent.Name).ToArray();if(!names.Contains("sample")||(explicitAgents&&!names.Contains("Custom")))thrownewException(JsonSerializer.Serialize(names));results.Add(new{explicitAgents,agents=names});}varoutput=JsonSerializer.Serialize(new{issue=1889,sdk="GitHub.Copilot.SDK 1.0.34",results});File.WriteAllText(Path.Combine(directory,"result.json"),output);Console.WriteLine(output);
Run with dotnet run --project sdk-dotnet-discovery-repro -- <writable-fixture-parent-directory> <path-to-copilot-runtime>. The runtime used here is the published 1.0.112 binary bundled with @github/[email protected]; no inference or credentials are required.
The shared fixture below supplies the isolated spawned runtime and loopback endpoint. Its Responses/Completions replies only drive the runtime through the operation; they are not claims about live provider behavior.
Activity
github-actions commentedon Jul 2, 2026
Investigation findings
Thanks for the detailed report. I investigated the relevant code in the .NET SDK (
dotnet/src/Types.cs,dotnet/src/Client.cs) and the documentation (docs/features/custom-agents.md) to understand this behavior.What I found
The non-merging behavior is by design, not a bug. The
EnableConfigDiscoveryproperty's documentation explicitly describes what it merges:Agents from
.github/agentsare not listed among what gets merged. The SDK simply passes bothcustomAgentsandenableConfigDiscoveryas separate parameters to the Copilot CLI runtime — no merge is performed on the SDK side either. The runtime treats programmaticCustomAgentsand workspace-discovered agents as distinct, non-combined sources.This asymmetry is real — MCPs and skills are merged, but agents are not — but it reflects the current design rather than a defect.
On the
Handoffs/SessionHandoffEventparity concernYou are correct that
CustomAgentConfig(indotnet/src/Types.cs) does not expose aHandoffsproperty. The current public properties are:Name,DisplayName,Description,Tools,Prompt,McpServers,Infer,Skills, andModel.SessionHandoffEventexists in the generated session events, but it can only be raised by workspace-file-based agents today.Reclassification
Both observations — merging workspace agents with
CustomAgentswhenEnableConfigDiscoveryis true, and addingHandoffssupport and other missing properties toCustomAgentConfig— represent new capabilities beyond what is currently designed and documented. I'm relabelling this as an enhancement request.The workaround today, as you noted, is to either:
CustomAgents(and duplicate any workspace agents programmatically), orEnableConfigDiscovery = truewithout settingCustomAgents(relying entirely on.github/agentsfiles).Agent merging and full
CustomAgentConfigparity with workspace agents would be a valuable addition to the SDK. Leaving this open for the team to evaluate.patniko commentedon Oct 26, 2026
Thanks for the report. We've shipped fixes in this area since this was filed, and we believe this may now be resolved. Could you retest on the latest release (Copilot SDK v1.0.26, which bundles Copilot CLI v1.0.103) and let us know whether you still see it? If we don't hear back in a couple of weeks, we may close this issue — you can always reopen it.
Triaged as part of a Copilot SDK backlog review, with help from GitHub Copilot.
roji commentedon Nov 18, 2026
I executed the original .NET discovery scenario against the published GitHub.Copilot.SDK 1.0.34 NuGet package and runtime 1.0.112. The workspace agent is now merged with the explicitly supplied agent:
The fixture uses the default
CopilotCliclient mode,EnableConfigDiscovery=true, an isolated Git-initialized workspace, and noCustomAgentsLocalOnlyoverride. It does not need model inference. Equivalent Node checks passed on SDK/runtime 1.0.34/1.0.112 and 2.0.0/1.0.113.This supersedes the earlier comment's claim that explicit and discovered agents are intentionally never merged.
Leaving this issue open: its additional request for full programmatic-agent property parity, specifically
Handoffs/SessionHandoffEvent, is distinct. The list-merging check neither demonstrates nor implements that feature, so a passing original repro is not proof that the whole issue is addressed.Executed .NET project (published NuGet 1.0.34)
Save as
sdk-dotnet-discovery-repro/Check.csproj:Save as
sdk-dotnet-discovery-repro/Program.cs:Run with
dotnet run --project sdk-dotnet-discovery-repro -- <writable-fixture-parent-directory> <path-to-copilot-runtime>. The runtime used here is the published 1.0.112 binary bundled with@github/[email protected]; no inference or credentials are required.Runnable reproduction / diagnostic (repro-1889.mjs)
Put the files below together in an otherwise empty directory. Install the exact packages and run:
repro-1889.mjs:The shared fixture below supplies the isolated spawned runtime and loopback endpoint. Its Responses/Completions replies only drive the runtime through the operation; they are not claims about live provider behavior.
repro-support.mjs: