Custom Agents are not working | Node | Dotnet
Session created with Custom Agents are initialized but when asked about listing custom agents, the assistant is not aware of any custom agents available.
Tried with both node and dotnet SDKs. Do custom agents need special configuration?
const customAgents: CustomAgentConfig[] = [
{
name: "test-agent",
displayName: "Test Agent",
description: "A test agent for SDK testing",
prompt: "You are a helpful test agent.",
infer: true,
},
];
const client = new CopilotClient();
const session = await client.createSession({
model: "gpt-5.2",
streaming: true,
//tools: [getWeather],
customAgents: customAgents,
onPermissionRequest: (request, invocation) => {
console.log(`Tool permission requested: ${request.kind}`);
console.log(`Tool details: ${JSON.stringify(request)}`);
let result: PermissionRequestResult = { kind: "approved" };
rl.question("Allow (y/n)?", (answer) => {
if (answer.toLowerCase() !== "y") {
result = { kind: "denied-interactively-by-user"}
}
});
return result;
}
});
const prompt = () => {
rl.question("You: ", async (input) => {
if (input.toLowerCase() === "exit") {
await client.stop();
rl.close();
return;
}
process.stdout.write("Assistant: ");
await session.sendAndWait({ prompt: "List all custom agents" });
console.log("\n");
prompt();
});
};
Output -
You: list all custom agents
Assistant: I’ll pull the Copilot CLI help/docs and extract the list of available custom agents.The Copilot CLI ships with these built-in (custom) agents:
- **explore**
- **task**
- **general-purpose**
- **code-review**
If you mean *user-defined* custom agents (from `/skills` or MCP/plugin configuration), run **`/agent`** to browse what’s currently installed/available in your setup.
Thank you for reporting this issue, @ShrayRastogi!
I've applied the following labels:
bug— Custom agents are not being recognized as expectedsdk/nodejsandsdk/dotnet— Affects both SDK implementationsneeds-info— Need more details to help diagnose
Questions for clarification:
- SDK versions: Which versions of the Node.js and .NET SDKs are you using?
- Expected behavior: When you ask "list all custom agents," what were you expecting to see? Should the assistant be aware of the
test-agentyou defined? - Similar issue: This looks related to #244, which involves custom agents not working when AI tools are present. In your code, I see
//tools: [getWeather]is commented out. Does the issue occur both with and without tools defined? - Session creation: Does
createSession()succeed without errors? Are there any error messages or warnings in your console?
Note: The assistant's response mentions "built-in (custom) agents" (explore, task, general-purpose, code-review), which are different from user-defined custom agents like your test-agent. This suggests the session might not be receiving your custom agent configuration properly.
AI generated by Issue Triage Agent
Thank you for reporting this issue, @ShrayRastogi!
I've applied the following labels:
bug— Custom agents are not being recognized as expectedsdk/nodejsandsdk/dotnet— Affects both SDK implementationsneeds-info— Need more details to help diagnoseQuestions for clarification:
- SDK versions: Which versions of the Node.js and .NET SDKs are you using?
- Expected behavior: When you ask "list all custom agents," what were you expecting to see? Should the assistant be aware of the
test-agentyou defined?- Similar issue: This looks related to Custom agent doesn't work with AI Function #244, which involves custom agents not working when AI tools are present. In your code, I see
//tools: [getWeather]is commented out. Does the issue occur both with and without tools defined?- Session creation: Does
createSession()succeed without errors? Are there any error messages or warnings in your console?Note: The assistant's response mentions "built-in (custom) agents" (explore, task, general-purpose, code-review), which are different from user-defined custom agents like your
test-agent. This suggests the session might not be receiving your custom agent configuration properly.AI generated by Issue Triage Agent
SDK versions: Node: 0.1.19 & Dotnet: 0.1.19
Expected behavior: Yes, the assistant should be aware of these custom agents as custom agents are building blocks of multi-agent systems and custom orchestration. VSCode GitHub Copilot and Copilot CLI supports file-based agent definitions for enabling custom agents. Need clarity on support for custom agents in Copilot SDK and how they should be used. the samples given only show how to define custom agents but not usage. If this is expected to be released in future versions, please specify the timeline.
Similar issue: The issue is similar but only talks about testing docs. My findings and experience suggest that custom agents though defined does not work in SDK. It does not work with tools or without tools.
Session creation: Yes, it succeeds without errors.
I am having the same issue in node. After a quick review by copilot it is saying the cli is not picking up the schema change on the task tool
It was working for me then stopped... not sure what changed
@patniko @friggeri - Could you please specify when this feature would be available to use?
I'm having the same issue with .net10 :
SessionConfig config = new SessionConfig
{
Model = "gpt-4.1",
CustomAgents = new List<CustomAgentConfig>
{
new CustomAgentConfig
{
Name = "RhymingAssistant",
DisplayName = "Rhyming Assistant",
Description = "Rhyming Answers.",
Prompt = "You only ever answer in rhymes.",
Infer = true
}
}
};
await using CopilotClient client = new CopilotClient();
await using var session = await client.CreateSessionAsync(config);
Console.WriteLine(config.CustomAgents.Count);
var response = await session.SendAndWaitAsync(new MessageOptions
{
Prompt = "What is 2 + 2?",
});
Console.WriteLine(response?.Data.Content);
The response from the agent just outputs 2+2=4. The agent definition is ignored.
I'm using the GitHub.Copilot.SDK package version 0.1.23
We traced this to initializeSession in the CLI. The chain:
- SDK sends
session.createwithcustomAgents: [...]→ CLI setsthis.customAgentscorrectly initializeSession()then callsupdateOptions()multiple times for each feature callback (external tools, permission request, user input request, hooks) — none of these calls include thecustomAgentskey- Inside
updateOptions, when e.customAgents !== void 0 is false (i.e. key absent), it firesthis.loadCustomAgents() loadCustomAgents()with Copilot auth (provider is falsy, authInfo is set) fetches org/enterprise agents from the GitHub API → returns [] → overwritesthis.customAgents
Each updateOptions call without customAgents triggers a fresh loadCustomAgents(), so the overwrite can happen multiple times.
Workaround until issue is fixed: Removing enableUserInputCallback and enableHooksCallback from the session config skips the updateOptions calls that trigger the overwrite, which remediated the issue for us.
Suggested fix: Skip loadCustomAgents() when agents were explicitly provided at session creation, or (b) pass customAgents through in every updateOptions call from initializeSession.
We traced this to
initializeSessionin the CLI. The chain:
- SDK sends
session.createwithcustomAgents: [...]→ CLI setsthis.customAgentscorrectlyinitializeSession()then callsupdateOptions()multiple times for each feature callback (external tools, permission request, user input request, hooks) — none of these calls include thecustomAgentskey- Inside
updateOptions, when e.customAgents !== void 0 is false (i.e. key absent), it firesthis.loadCustomAgents()loadCustomAgents()with Copilot auth (provider is falsy, authInfo is set) fetches org/enterprise agents from the GitHub API → returns [] → overwritesthis.customAgentsEach
updateOptionscall withoutcustomAgentstriggers a freshloadCustomAgents(), so the overwrite can happen multiple times.Workaround until issue is fixed: Removing
enableUserInputCallbackandenableHooksCallbackfrom the session config skips theupdateOptionscalls that trigger the overwrite, which remediated the issue for us.Suggested fix: Skip
loadCustomAgents()when agents were explicitly provided at session creation, or (b) passcustomAgentsthrough in everyupdateOptionscall frominitializeSession.
@knifeyspoony - Is this workaround applicable for DOTNET SDK as well? Also, did you notice any side effects of this workaround?
We traced this to
initializeSessionin the CLI. The chain:
- SDK sends
session.createwithcustomAgents: [...]→ CLI setsthis.customAgentscorrectlyinitializeSession()then callsupdateOptions()multiple times for each feature callback (external tools, permission request, user input request, hooks) — none of these calls include thecustomAgentskey- Inside
updateOptions, when e.customAgents !== void 0 is false (i.e. key absent), it firesthis.loadCustomAgents()loadCustomAgents()with Copilot auth (provider is falsy, authInfo is set) fetches org/enterprise agents from the GitHub API → returns [] → overwritesthis.customAgentsEach
updateOptionscall withoutcustomAgentstriggers a freshloadCustomAgents(), so the overwrite can happen multiple times. Workaround until issue is fixed: RemovingenableUserInputCallbackandenableHooksCallbackfrom the session config skips theupdateOptionscalls that trigger the overwrite, which remediated the issue for us. Suggested fix: SkiploadCustomAgents()when agents were explicitly provided at session creation, or (b) passcustomAgentsthrough in everyupdateOptionscall frominitializeSession.@knifeyspoony - Is this workaround applicable for DOTNET SDK as well? Also, did you notice any side effects of this workaround?
@knifeyspoony - I confirm this workaround works in dotnet sdk as well by not using Tools and OnPermissionRequest. Thanks for putting it here. It appears we have to wait till copilot-cli or copilot-sdk team fixes the bug.
@SteveSandersonMS @friggeri - requesting an update here pls?
@ShrayRastogi can you share an example of the workaround in .net please? I couldn't get it working following the workaround in JS.
@ShrayRastogi can you share an example of the workaround in .net please? I couldn't get it working following the workaround in JS.
using Azure.Core;
using Azure.Identity;
using GitHub.Copilot.SDK;
using Microsoft.Extensions.AI;
using System.ComponentModel;
var customAgents = new List<CustomAgentConfig>
{
new CustomAgentConfig
{
Name = "agent1",
DisplayName = "Agent One",
Description = "You are specialized in responding with Hello. You are inferable, copilot can delegate tasks to you if user is asking anything about Hello.",
Prompt = "You are agent one. You only respond with 'Hello'",
Infer = true
},
new CustomAgentConfig
{
Name = "agent2",
DisplayName = "Agent Two",
Description = "You are specialized in responding with 'Sup'. You are inferable, copilot can delegate tasks to you if user is asking anything about 'Sup'.",
Prompt = "You are agent two. You only respond with 'Sup'",
Infer = true
}
};
await using var client = new CopilotClient(new CopilotClientOptions { LogLevel = "all" });
await using var session = await client.CreateSessionAsync(new SessionConfig
{
Model = "gpt-5.2",
Streaming = true,
CustomAgents = customAgents
});
// Listen for events including tool executions
session.On(ev =>
{
// Stream response chunks
if (ev is AssistantMessageDeltaEvent deltaEvent)
{
Console.Write(deltaEvent.Data.DeltaContent);
}
if (ev is SessionIdleEvent)
{
Console.WriteLine();
}
});
Console.WriteLine("Cli Custom Agent (type 'exit' to quit)");
Console.WriteLine("Try: Show me all custom agents available. \n");
while (true)
{
Console.Write("You: ");
var input = Console.ReadLine();
if (string.IsNullOrEmpty(input) || input.Equals("exit", StringComparison.OrdinalIgnoreCase))
{
break;
}
Console.Write("Assistant: ");
await session.SendAndWaitAsync(new MessageOptions { Prompt = input });
Console.WriteLine("\n");
}
You can now try asking -
- Show me all custom agents available
- delegate task to agent1 to talk about Hello
To verify, find logs under - C:\Users<your-username>.copilot\logs (Windows) You should see below kind of logs printed -
1. Received session.create request: {"model":"gpt-5.2","streaming":true,"customAgents":[{"name":"agent1","displayName":"Agent One","description":
2. "agent_type": {
"type": "string",
"enum": [
"explore",
"task",
"general-purpose",
"code-review",
"agent1",
"agent2"
],
"description": "The type of specialized agent to use for this task."
},
3. {
"message": {
"content": null,
"refusal": null,
"role": "assistant",
"tool_calls": [
{
"id": "call_7KvJhkkJEXxzxJI0r6DyWyLs",
"type": "function",
"function": {
"name": "report_intent",
"arguments": "{\"intent\":\"Delegating to agent1\"}"
}
}
]
},
"index": 1,
"finish_reason": "tool_calls",
"logprobs": null
},
4. {
"message": {
"content": null,
"refusal": null,
"role": "assistant",
"tool_calls": [
{
"id": "call_KEEqwnolYsrHOjrM6ZF2PYbb",
"type": "function",
"function": {
"name": "task",
"arguments": "{\"description\":\"Ask agent1 Hello meaning\",\"prompt\":\"User asked: \\\"what is Hello\\\". Provide the answer.\",\"agent_type\":\"agent1\",\"mode\":\"sync\"}"
}
}
]
},
"index": 2,
"finish_reason": "tool_calls",
"logprobs": null
}
Hope it helps!
Confirming this affects the Python SDK as well (github-copilot-sdk 0.1.25, CLI 0.0.412).
FYI - As of v0.1.29 custom agents now works with the Python SDK. Good job everyone!
I'm still unable to deactivate the default subagents:
- explore
- task
- general-purpose
- code-review
@cdufresne81 - Can you confirm if custom agents are working with Tools and OnPermissionRequest handler while creating the session? Because for dotnet and node, it does not work with those present while creating session.
@cdufresne81 - Can you confirm if custom agents are working with Tools and OnPermissionRequest handler while creating the session? Because for dotnet and node, it does not work with those present while creating session.
As far as I can tell it's working with on_permission_request, init session_config
session_config = {
"model": self._current_model,
"streaming": True,
"system_message": {
"mode": "replace",
"content": system_content,
},
"tools": self._tools,
"custom_agents": custom_agents,
"on_permission_request": self._handle_permission_request,
"infinite_sessions": {
"enabled": True,
"background_compaction_threshold": 0.80,
"buffer_exhaustion_threshold": 0.95,
},
}
self._main_session = await self._client.create_session(session_config)
Snippet from the logs
2026-03-05 09:18:04 [cmdcenter.agent] INFO: Custom agents for session: ['memory-explorer', 'footman']
...
2026-03-03 11:32:44 [cmdcenter.agent] INFO: Chat: response complete (735 chars)
2026-03-03 11:57:53 [cmdcenter.agent] INFO: Chat: user message (64 chars)
2026-03-03 11:57:56 [cmdcenter.agent] INFO: Tool call: report_intent({'intent': 'Querying subagent models'})
2026-03-03 11:57:56 [cmdcenter.agent] INFO: Tool done: report_intent (0.0s) success=True
2026-03-03 11:57:56 [cmdcenter.agent] INFO: Tool result [report_intent]: Intent logged
2026-03-03 11:57:59 [cmdcenter.agent] INFO: Subagent started: Task (tool_call_id=call_ltbnFJi8fB4ql1GfUcx7XTfw)
2026-03-03 11:57:59 [cmdcenter.agent] INFO: Subagent started: Task (tool_call_id=call_Fxp4nTOigBhwIq6QRu667Ny5)
2026-03-03 11:57:59 [cmdcenter.agent] INFO: Subagent started: Task (tool_call_id=call_aHXAtSXDWOZzgQntmqXpc46T)
2026-03-03 11:57:59 [cmdcenter.agent] INFO: Subagent started: Task (tool_call_id=call_EvCjaijcc1ddMAvb372cHyX6)
2026-03-03 11:57:59 [cmdcenter.agent] INFO: Subagent started: Task (tool_call_id=call_glBvPfgTURtq6mVTKTfqzwMt)
2026-03-03 11:57:59 [cmdcenter.agent] INFO: Subagent started: Task (tool_call_id=call_njWpDcT9isxU6AUZrdhabfu7)
2026-03-03 11:57:59 [cmdcenter.agent] INFO: Subagent started: Memory Explorer (parent=None)
2026-03-03 11:57:59 [cmdcenter.agent] INFO: Subagent started: Footman (parent=None)
2026-03-03 11:57:59 [cmdcenter.agent] INFO: Subagent started: General Purpose Agent (parent=None)
2026-03-03 11:57:59 [cmdcenter.agent] INFO: Subagent started: Code Review Agent (parent=None)
2026-03-03 11:57:59 [cmdcenter.agent] INFO: Subagent started: Explore Agent (parent=None)
2026-03-03 11:57:59 [cmdcenter.agent] INFO: Subagent started: Task Agent (parent=None)
2026-03-03 11:58:00 [cmdcenter.agent] INFO: Subagent message [Task]: gpt-4
2026-03-03 11:58:00 [cmdcenter.agent] INFO: Subagent completed: explore (0.0s)
2026-03-03 11:58:00 [cmdcenter.agent] INFO: Subagent completed: Task (0.9s) success=True
2026-03-03 11:58:00 [cmdcenter.agent] INFO: Subagent message [Task]: claude-haiku-4.5
2026-03-03 11:58:00 [cmdcenter.agent] INFO: Subagent message [Task]: claude-sonnet-4.5
2026-03-03 11:58:00 [cmdcenter.agent] INFO: Subagent completed: task (0.0s)
2026-03-03 11:58:00 [cmdcenter.agent] INFO: Subagent completed: Task (1.5s) success=True
2026-03-03 11:58:01 [cmdcenter.agent] INFO: Subagent completed: code-review (0.0s)
2026-03-03 11:58:01 [cmdcenter.agent] INFO: Subagent completed: Task (1.6s) success=True
2026-03-03 11:58:01 [cmdcenter.agent] INFO: Subagent message [Task]: gpt-4.
2026-03-03 11:58:01 [cmdcenter.agent] INFO: Subagent completed: general-purpose (0.0s)
2026-03-03 11:58:01 [cmdcenter.agent] INFO: Subagent completed: Task (1.9s) success=True
2026-03-03 11:58:01 [cmdcenter.agent] INFO: Subagent message [Task]: claude-3-opus-20240229
2026-03-03 11:58:01 [cmdcenter.agent] INFO: Subagent message [Task]: claude-sonnet-4.5
2026-03-03 11:58:01 [cmdcenter.agent] INFO: Subagent completed: footman (0.0s)
@MackinnonBuck a good one to look at. We need to go into the runtime for a change first.
Keep JSON object out of the matter curriculum for Good 👍 it's going to run smoothly
This should be fixed in the latest SDK (0.1.32 at the time of writing). If others continue to hit this problem, please open a new issue with detailed repro steps. Thanks!