Skip to content

EnableConfigDiscovery - Incorrect Behaviour #1887

Description

@shudles

The SessionConfig.EnableConfigDiscovery property's summary tag reads:

    /// <summary>
    /// When <see langword="true"/>, automatically discovers MCP server configurations
    /// (e.g. <c>.mcp.json</c>, <c>.vscode/mcp.json</c>) and skill directories from
    /// the working directory and merges them with any explicitly provided
    /// <see cref="McpServers"/> and <see cref="SkillDirectories"/>, with explicit
    /// values taking precedence on name collision.
    /// <para>
    /// Custom instruction files (<c>.github/copilot-instructions.md</c>, <c>AGENTS.md</c>, etc.)
    /// are always loaded from the working directory regardless of this setting.
    /// </para>
    /// </summary>
    public bool? EnableConfigDiscovery { get; set; }

Using this simple example, you can discover it's not this the case. Agents will ONLY be loaded when the value is set to true. Which is counter to:
"Custom instruction files (.github/copilot-instructions.md, AGENTS.md, etc. are always loaded from the working directory regardless of this setting"

using GitHub.Copilot;

// path to .github folder containing agents folder
const string WorkingDirectory = @"C:\SomeWorkspace";

await using var client = new CopilotClient();


await using var session = await client.CreateSessionAsync(new SessionConfig
{
    WorkingDirectory = WorkingDirectory,
    EnableConfigDiscovery = false, // switch this to true if you want agents to be actually loaded.
});

var agentsList = await session.Rpc.Agent.ListAsync();

foreach (var agent in agentsList.Agents)
{
    Console.WriteLine(agent.Name);
}

Agent file I was using in a .github/agents/sample.agent.md file

---
name: sample
description: Sample Agent
---

You are an sample agent for this repository, you're just happy to be here!

Additionally, are there any plans to support an AgentsDirectories property similar to SkillDirectories, PluginDirectories & InstructionDirectories?

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions