Skip to content

GitHub Copilot SDK

A programmable layer that embeds Copilot agent capabilities — planning, tool invocation, file editing, and command execution — into any application.

What the SDK provides

The Copilot SDK gives you the same execution loop that runs GitHub Copilot CLI, packaged as a library you embed in your own applications. Instead of reaching Copilot through an IDE or web interface, you create agent sessions, send prompts, and handle streaming responses in code. GitHub announced the SDK as generally available on 2026-06-02, graduating it from public preview.

Core capabilities:

  • Planning and execution: the agent plans multi-step tasks, invokes tools, edits files, and runs commands
  • Multi-turn context: persistent memory across turns, with session compaction
  • Model choice: support for several AI models, with user selection at different workflow steps
  • Tool integration: custom tool definitions and MCP server support
  • Real-time streaming: async task delegation with streaming responses

Language support

The SDK provides bindings for Node.js, Python, Go, .NET, and Java.

Architecture

The SDK abstracts the infrastructure that the Copilot CLI uses in production:

  • Planner and tool orchestration
  • Multi-model routing
  • MCP server management
  • GitHub authentication flows
  • Chat session persistence

Applications built on the SDK inherit the same production-tested execution loop without reimplementing agent orchestration. Authentication runs through existing GitHub Copilot subscriptions or custom API keys (BYOK for enterprises).

Why it works

Embedding a shared execution loop, rather than building agent orchestration from scratch, removes a class of maintenance work. Context compaction, tool invocation order, and model routing are problems every agent must solve. The SDK keeps those solutions in one place, so your application code handles only domain-specific logic. The same runtime also gets the fixes and model updates applied to Copilot CLI, with no changes needed in the embedding application.

Agent-in-app pattern

The SDK supports an "agent-in-app" architecture, where you embed AI coding capabilities directly in domain-specific tools rather than reach them through general-purpose interfaces. GitHub's announcement lists use cases such as custom agent GUIs, speech-to-command workflows, content summarization tools, and purpose-built developer platforms.

This pattern lets you move agent capabilities from a fixed surface (IDE, CLI) to any application context where code generation, editing, or reasoning helps.

When this backfires

Embedding the Copilot SDK ties your application to GitHub's subscription model, rate limits, and runtime decisions. Conditions where this is worse than the alternative:

  • Subscription dependency: users need an active Copilot subscription, or you supply BYOK keys. Applications that must serve users without Copilot access cannot use the SDK as-is.
  • Rate limit exposure: SDK requests count against premium request quotas, so high-volume workflows can exhaust limits faster than interactive use does.
  • Runtime lock-in: the execution loop, tool surface, and session management are GitHub's. If the runtime changes behavior (model swap, tool API change), embedding applications absorb the regression without direct control over the upgrade path.

The rate-limit risk is not theoretical: in April 2026 GitHub paused new Copilot sign-ups after agentic usage broke flat-rate economics, fixed a token-counting bug that had been under-counting newer models, and announced a shift to token-based billing with tighter rate limits for individual plans. Applications embedding the SDK inherit whatever quota regime GitHub sets for their users' plans.

Runtime lock-in is similarly concrete. In May 2026 a cross-binding bug (github/copilot-sdk#251) stopped custom agents initialized through the SDK from reaching the assistant in either Node or .NET — a defect in the shared copilot-agent-runtime that no embedding application could patch. A practitioner ship report covering six SDK upgrades documents runtime changes breaking the embedding harness mid-iteration (SDK upgrade-path regression). The SDK gives you GitHub's execution loop — and GitHub's bugs.

Example

The following Node.js snippet illustrates the agent-in-app pattern: starting the client, creating a session, subscribing to streaming events, and sending a task prompt (nodejs README).

import { CopilotClient, approveAll } from "@github/copilot-sdk";

const client = new CopilotClient();
await client.start();

const session = await client.createSession({
  model: "gpt-5",
  streaming: true,
  onPermissionRequest: approveAll,
});

const done = new Promise<void>((resolve) => {
  session.on("assistant.message_delta", (event) => {
    process.stdout.write(event.data.deltaContent);
  });
  session.on("session.idle", () => resolve());
});

await session.send({
  prompt: "Refactor src/utils.ts to use async/await throughout",
});
await done;

await session.disconnect();
await client.stop();

Streaming is event-based rather than async-iterable: assistant.message_delta fires for each incremental chunk, and session.idle signals completion. onPermissionRequest controls how tool invocations are authorized; approveAll suits trusted environments only. Register more MCP servers through the client configuration to extend the agent with domain-specific tools.

Key Takeaways

  • The Copilot SDK exposes Copilot CLI's production execution loop as an embeddable library you can integrate into your own applications
  • Supports Node.js, Python, Go, .NET, and Java with the same agent capabilities across all bindings
  • Enables the agent-in-app pattern: you embed planning, tool use, and file editing into custom applications
  • MCP server support and custom tool definitions let you extend the agent's capabilities beyond built-in tools
  • Generally available (GA as of 2026-06-02) with authentication through Copilot subscriptions or custom API keys; requests count against premium quotas
Feedback