July 30th, 2026
like1 reaction

Building agent teams with Agent Framework, GitHub Copilot CLI and Squad

Microsoft Agent Framework supports creating agents that use the GitHub Copilot SDK as their backend. GitHub Copilot agents provide access to powerful coding-oriented AI capabilities, including shell command execution, file operations, URL fetching, Model Context Protocol (MCP) server integration, and can be integrated into your existing development pipeline.

using GitHub.Copilot;
using Microsoft.Agents.AI;
using Microsoft.Extensions.AI;

AIFunction weatherTool = AIFunctionFactory.Create((string location) =>
{
    return $"The weather in {location} is sunny with a high of 25C.";
}, "GetWeather", "Get the weather for a given location.");

await using CopilotClient copilotClient = new();
await copilotClient.StartAsync();

AIAgent agent = copilotClient.AsAIAgent(
    tools: [weatherTool],
    instructions: "You are a helpful weather agent.");

Console.WriteLine(await agent.RunAsync("What's the weather like in Seattle?"));

We recently shipped this integration to v1.0 in C# and Python – fully supported and stable. Find out more here: MS Learn | Agent Framework | GitHub Copilot Agents and check out the samples here: .NET | Python

A great example of using MAF and GitHub Copilot together is Squad. Squad is an open-source multi-agent framework that runs on top of the GitHub Copilot CLI/SDK — you describe a small team (a coordinator plus a few specialists, each with a charter), and the coordinator dispatches the work, lets the specialists argue, and ships a result. (aka.ms/copilot-squad). What gets interesting is the combination of MAF and Squad: MAF gives you the agent runtime, model abstraction, hosting, and telemetry; the GitHub Copilot CLI/SDK gives you a coding agent that already knows how to read repos, edit files, and run shells. Wire them together in one .NET app and you get to enjoy both worlds in the same IServiceCollection.

Because Squad already runs on the Copilot CLI/SDK and MAF has a first-party adapter for it, the bridge between them is almost free. Squad.Agents.AI is a small NuGet that wraps a Squad team as a regular MAF AIAgent. You wire it into your IServiceCollection like any other agent, MAF treats it as a peer, and Squad keeps orchestrating underneath.

The integration in C#

using Microsoft.Agents.AI;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Squad.Agents.AI;

var builder = Host.CreateApplicationBuilder(args);
builder.Services.AddSquadAgent(o =>
{
    o.SquadFolderPath = @"C:\path\to\your\team-root";
});

using var host = builder.Build();
var squad = host.Services.GetRequiredService<AIAgent>();
var session = await squad.CreateSessionAsync();
var response = await squad.RunAsync("What can this Squad team do?", session);
Console.WriteLine(response.Text);

That’s the whole integration. AddSquadAgent() registers your Squad team as both AIAgent (so MAF sees it through the standard abstraction) and SquadAgent (so callers that want Squad-specific knobs can drop down).

Under the hood

SquadAgent is a thin composition of the two pieces Shawn just announced. The Copilot SDK already knows how to talk to copilot.exe; Squad.Agents.AI just points it at a Squad team folder, sets up a session, and hands the result to MAF as a regular AIAgent. The whole class is essentially this:

public sealed class SquadAgent : DelegatingAIAgent

{
    public SquadAgent(SquadAgentOptions options) 
        : base(BuildInnerAgent(options))    // ← inner AIAgent passed to DelegatingAIAgent
    {
    }
    // DelegatingAIAgent forwards RunAsync, RunStreamingAsync, CreateSessionAsync
    // to whatever inner AIAgent we hand the base ctor. SquadAgent doesn't override
    // any of that — the Copilot-backed agent does the work; we just expose the seam.
    private static AIAgent BuildInnerAgent(SquadAgentOptions options)
    {
        // 1. Copilot SDK client, pointed at the Squad team root
        var client = new CopilotClient(/* CLI path, env, token, etc. */);
        // 2. Tell the CLI to auto-discover the .squad/ folder so it picks up
        //    team agents, skills, instructions, and MCP servers at session start.
        var teamRoot       = options.SquadFolderPath;
        var squadConfigDir = Path.Combine(teamRoot, ".squad");

        var sessionConfig = new SessionConfig
        {
             WorkingDirectory      = teamRoot,
             ConfigDirectory       = squadConfigDir,
             EnableConfigDiscovery = true,
             OnPermissionRequest   = PermissionHandler.ApproveAll,
        };

        // 3. Lift the Copilot client into a MAF AIAgent — this is the inner
        //    agent that DelegatingAIAgent will forward every call to.
        return client.AsAIAgent(sessionConfig, name: options.AgentName ?? "Squad");
    }
}

The constructor chain is the part that ties it together. BuildInnerAgent produces a Copilot-backed AIAgent; the public ctor passes that straight to : base(…), and DelegatingAIAgent forwards every RunAsync, RunStreamingAsync, and CreateSessionAsync call to it. No protocol, no extra runtime, no overrides — just inheritance plus delegation. Three lines do the work that matters: build a CopilotClient (Copilot SDK), describe a SessionConfig that aims it at your team’s .squad/ folder, then call client.AsAIAgent(…) — the extension from Microsoft.Agents.AI.GitHub.Copilot that turns it into a MAF agent.

The EnableConfigDiscovery flag is what makes the CLI auto-load your team’s charters, skills, and MCP servers at session start instead of forcing the agent to re-read them via runtime file tools every turn. That’s the part you’d otherwise have to rebuild by hand. (SquadAgent.cs)

Streaming uses the same surface — await foreach (var update in squad.RunStreamingAsync(prompt, session)) does what you’d expect. The depth — keyed multi-team registration, BYOK token delegates, security defaults — lives in the README.

Why Squad inside MAF?

A MAF workflow already lets you mix deterministic steps, stateless AI calls, and targeted agents you’ve prompt-engineered. Each of those resets to zero on every invocation — they know exactly what their prompt tells them, nothing more.

A Squad is different. It’s a self-learning team that accumulates domain knowledge with use:

  1. It remembers decisions. “We chose Postgres over Cosmos for this service” — logged once, respected by every specialist on every future call. You don’t re-explain your architecture each invocation.
  2. It extracts skills. The first time an agent figures out your deployment flow, it writes a skill file. The tenth time, it just reads the skill and executes. Patterns compound instead of being rediscovered.
  3. It respects your corrections. Say “we never use that library” once. The directive is captured. The team won’t suggest it again — not because you hardcoded a blocklist, but because the team learned.
  4. It onboards new specialists instantly. Add a security reviewer to the team next month. They inherit the full decision ledger and skill library on their first session — same way a new hire reads the team wiki.

That self-learning nature changes what the Squad-as-AIAgent slot means inside a MAF pipeline:

  • Content pipeline — Your Squad team doesn’t just research-draft-review. After ten runs it knows your tone guide, remembers which sources you rejected last time, and skips the style arguments it already resolved. A stateless fan-out would relearn all of that every call.
  • Code review bot — The Squad remembers your codebase conventions, past review decisions (“we don’t flag this pattern”), and which reviewer concerns carry more weight. Each review is sharper than the last.
  • Customer support escalation — The Squad team has seen your product’s failure modes before. It knows that “sync error” usually means a token expiry, not a network issue, because it logged that three weeks ago. Stateless agents would chase the wrong root cause every time.
  • Release readiness gate — The Squad knows what “ready” means for your project specifically — because it captured your release criteria as decisions over time, not because someone hardcoded them in a prompt.

The result: inside your MAF pipeline, the Squad slot isn’t just “call an LLM.” It’s “call the team that’s been learning your project for the past six weeks.” The host sees one AIAgent. Underneath, a coordinator dispatches to specialists who carry institutional memory — and get better at your specific domain every time they run. A targeted agent gives you repeatability. A Squad gives you repeatability that improves over time.

The subagent observability is the part I underestimated and now lean on hardest. By default the package emits one OpenTelemetry span per dispatched specialist (squad.subagent {Name}, with lifecycle events on the live span), so any host that’s already wired into Aspire, Jaeger, or Application Insights sees the full multi-agent fan-out without extra plumbing. You see who got asked, what they said, and how long they took, on the same trace as the rest of your request.

If you’re already building on MAF and you want multi-agent orchestration that learns your domain over time without you rewriting prompts, this is the cheap path. The MAF team did the agent-framework work; we did the team-of-agents work; the seam is one DI call.

Try it today

dotnet add package Squad.Agents.AI --prerelease

Full README: github.com/bradygaster/squad/src/Squad.Agents.AI.

Author

Shawn Henry
Principal Group Product Manager

Principal Group Product Manager

tamir dresher
Principal Engineer

Principal Engineer, Microsoft Threat Protection

0 comments