Technical Preview ยท v0.2.0 ยท March 2026
Agents for Every App
Embed Copilot's agentic workflows in your application
Examples & slides
A programmable SDK that brings Copilot's agent runtime into your application โ no orchestration to build.
Same runtime behind Copilot CLI, battle-tested at scale
TypeScript, Python, Go, .NET, and Java SDKs available
Custom tools, agents, MCP servers, hooks, and skills
๐ README.md
โก Auto-managed or external CLI
๐พ Session persistence
๐ฅ Multi-client support (v3)
๐ก 40+ streaming event types
๐ Horizontal scaling
๐ OpenTelemetry tracing
| Language | Install Command |
|---|---|
| Node.js / TypeScript | npm install @github/copilot-sdk |
| Python | pip install github-copilot-sdk |
| Go | go get github.com/github/copilot-sdk/go |
| .NET | dotnet add package GitHub.Copilot.SDK |
| Java | com.github:copilot-sdk-java (Maven/Gradle) |
Community SDKs also available: Rust, Clojure, C++
Define functions Copilot can invoke
Specialized AI personas with scoped tools
External tool integration via standard protocol
Reusable prompt modules from directories
Intercept sessions for security and auditing
40+ real-time event types
Bring your own model provider API keys
Built-in OpenTelemetry instrumentation
Real problems your teams face today โ solved with the SDK
Problem: Manual reviews miss security issues and take days
โ Deploy a security auditor agent that reviews every PR in seconds using OWASP-focused prompts and read-only tools
Problem: Pipelines fail silently; debugging takes hours
โ Run agents in your pipeline that analyze failures, suggest fixes, and auto-generate test coverage
Problem: Non-technical teams can't self-serve data queries
โ Connect MCP servers to your database โ users ask in natural language, agent writes and explains SQL
Problem: Docs are always outdated, nobody wants to write them
โ Agents analyze your codebase and produce up-to-date, comprehensive documentation on every release
Problem: Building AI features requires custom orchestration and model plumbing
โ Embed Copilot's agent runtime in your product with per-user OAuth, session isolation, and streaming โ ship AI features in days, not months
Problem: Complex tasks need multiple specialized AI roles working together
โ Use Microsoft Agent Framework to orchestrate Copilot alongside Azure OpenAI and Anthropic in sequential or parallel pipelines
Problem: Incident response and infrastructure changes require deep expertise
โ Agents that diagnose production issues, manage infrastructure, and automate deployments with guardrailed shell access
Problem: Internal tools lack intelligence and require constant maintenance
โ Embed Copilot in your developer portal, CLI tools, and dashboards โ let third-party teams build on your AI-powered platform
First-party tools available to every session โ all enabled by default
read_file โ Read file contentsview โ View file or directoryglob โ Find files by name patterngrep โ Search contents (ripgrep)list_dir โ List directory contentsedit โ Targeted edits to existing filescreate โ Create new fileswrite_file โ Write / overwrite filesbash / shell โ Execute commandsweb_fetch โ Fetch content from URLstask โ Delegate to sub-agentsask_user โ Ask the user a questionstore_memory โ Persist factsPlus: MCP server tools (e.g. GitHub MCP) and your custom tools via @define_tool
Three ways to restrict what the agent can do
Whitelist or blacklist at creation
session = await client.create_session(
available_tools=[
"grep", "glob", "view"
],
# OR
excluded_tools=[
"bash", "shell"
],
)
Dynamic per-call decisions
ALLOWED = [
"read_file", "glob",
"grep", "view"
]
async def on_pre_tool_use(inp, inv):
if inp["toolName"] not in ALLOWED:
return {
"permissionDecision": "deny"
}
return {
"permissionDecision": "allow"
}
Replace with your own (v0.1.30+)
@define_tool(
description="Custom grep",
overrides_built_in_tool=True,
)
async def grep(params):
# Your custom implementation
return custom_search(
params.query
)
Define custom functions that Copilot can invoke during conversations
You define a tool with a name, description, JSON Schema parameters, and a handler function. The agent automatically decides when to call it based on the user's prompt.
Name, description, and typed parameters via JSON Schema
Your async function runs when the agent calls the tool
Pass tools array to createSession()
const getWeather = defineTool("get_weather", {
description: "Get the current weather for a city",
parameters: {
type: "object",
properties: {
city: { type: "string", description: "The city name" },
},
required: ["city"],
},
handler: async (args) => {
const data = await fetchWeatherAPI(args.city);
return { city: args.city, temp: data.temp, condition: data.condition };
},
});
const session = await client.createSession({
model: "gpt-4.1",
tools: [getWeather],
});
Define specialized AI personas with their own prompts, tool restrictions, and MCP servers
Tools: grep, glob, view
Analyze code, answer questions. Read-only.
Tools: view, edit, bash
Make minimal, surgical code changes.
Tools: grep, glob, view
Focus on OWASP Top 10 vulnerabilities.
Automatic Delegation โ The runtime auto-selects the right agent based on user intent when infer: true is set.
Model Context Protocol โ open standard for connecting AI to external tools
Runs as a subprocess, communicates via stdin/stdout
Local tools, file access, scripts
Accessed via HTTP endpoint, supports SSE
Shared services, cloud tools
Connect to any MCP server from the community directory โ GitHub, SQLite, Puppeteer, filesystem, and more. The tools array controls which tools are exposed.
๐ docs/features/mcp.md
const session = await client.createSession({
mcpServers: {
github: {
type: "http",
url: "https://api.githubcopilot.com/mcp/",
},
filesystem: {
type: "local",
command: "npx",
args: ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"],
tools: ["*"],
},
},
});
๐ docs/features/mcp.md
Add context, audit logging
Modify or filter user input
Approve, deny, or modify tool calls
Transform results, redact secrets
Custom error handling, retry logic
Cleanup, finalize audit trail
Use for: permissions, auditing, prompt enrichment, secret redaction, error recovery
Four methods โ choose based on your deployment scenario
| Method | Use Case | Subscription |
|---|---|---|
| ๐ค Signed-in User | Desktop, local dev | Required |
| ๐ OAuth App | Web apps, SaaS | Required |
| โ๏ธ Env Variables | CI/CD, automation | Required |
| ๐๏ธ BYOK | Own API keys | Not Required |
Token support: gho_ โ
ยท ghu_ โ
ยท github_pat_ โ
ยท ghp_ โ
OAuth Apps + GitHub Apps both supported for multi-user scenarios
๐ docs/auth/index.md
Build multi-user apps โ each user authenticates with their GitHub account
gho_xxx tokengithubTokenEnterprise: Works with org memberships, EMU, and SAML SSO automatically.
const client = new CopilotClient({
githubToken: userAccessToken,
useLoggedInUser: false,
});
const session = await client.createSession({
sessionId: `user-${userId}`,
model: "gpt-4.1",
onPermissionRequest: approveAll,
});
Use your own model provider API keys โ no Copilot subscription required
Direct API access
Enterprise deployments
Claude models
Local models
On-device AI
vLLM, LiteLLM, etc.
๐ docs/auth/byok.md
const session = await client.createSession({
model: "gpt-5.2-codex",
provider: {
type: "openai",
baseUrl: "https://your-resource.openai.azure.com/openai/v1/",
wireApi: "responses",
apiKey: process.env.FOUNDRY_API_KEY,
},
});
The wireApi setting controls the API format โ use "responses" for newer GPT-5 series models and "completions" for older ones.
๐ docs/auth/byok.md
All SDKs communicate via JSON-RPC โ the SDK manages the CLI process lifecycle automatically
SDK spawns CLI as a child process
new CopilotClient()CLI runs as a headless server on a port
copilot --headless --port 4321Package the Copilot CLI binary alongside your application โ users don't need to install anything separately.
copilot-darwin-arm64copilot-linux-x64copilot-win-x64.exeHobbyist
SDK spawns CLI as child process. Simplest path for personal projects and development.
Desktop App
Ship the CLI binary with your app. Standalone apps with zero external dependencies.
Enterprise
CLI as headless server over TCP. Web backends, APIs, and microservices.
Platform
Horizontal scaling with session isolation. Serve thousands of users reliably.
๐ docs/setup/index.md
Compose Copilot alongside Azure OpenAI, Anthropic, and others in orchestrated workflows
What this does: Create a client, open a session, send a prompt, and get a response โ the "Hello World" of the SDK. Just 6 lines of meaningful code.
import { CopilotClient } from "@github/copilot-sdk";
const client = new CopilotClient();
const session = await client.createSession({
model: "gpt-4.1",
onPermissionRequest: async () =>
({ kind: "approved" }),
});
const response = await session.sendAndWait({
prompt: "Explain how async/await works"
});
console.log(response?.data.content);
await client.stop();
What this does: Same "Hello World" in Python โ identical concept, idiomatic API. The v0.2.0 SDK uses keyword arguments and positional prompts.
from copilot import CopilotClient
from copilot import PermissionHandler
client = CopilotClient()
await client.start()
session = await client.create_session(
on_permission_request=
PermissionHandler.approve_all,
model="gpt-4.1",
)
response = await session.send_and_wait(
"Explain how async/await works"
)
print(response.data.content)
await client.stop()
๐ python/README.md
What this does: Define a tool that queries your internal ticket system. The agent automatically calls it when a user asks about a ticket โ no routing code needed. This pattern works for any internal system: CRMs, dashboards, HR tools.
const lookupTicket = defineTool("lookup_ticket", {
description: "Look up a support ticket by ID",
parameters: {
type: "object",
properties: {
ticketId: { type: "string", description: "Ticket ID (e.g. TICK-1234)" },
},
required: ["ticketId"],
},
handler: async (args) => {
const ticket = await db.tickets.findById(args.ticketId);
return {
id: ticket.id, status: ticket.status,
title: ticket.title, assignee: ticket.assignee,
};
},
});
What this does: Register the tool, send a natural language question. The agent recognizes it needs the ticket tool, calls it automatically, and formulates a human-readable answer from the structured data.
const session = await client.createSession({
model: "gpt-4.1",
tools: [lookupTicket],
onPermissionRequest: async () => ({ kind: "approved" }),
});
await session.sendAndWait({
prompt: "What's the status of TICK-4521?"
});
// Copilot automatically calls lookup_ticket("TICK-4521")
This pattern works for any internal system: CRMs, monitoring dashboards, inventory systems, HR tools โ anything with an API or database.
What this does: Run Copilot as a production backend โ the CLI runs as a headless server, your Express API connects over TCP, each user gets their own session with per-user OAuth. This is the pattern for SaaS products and internal tools at scale.
import express from "express";
import { CopilotClient } from "@github/copilot-sdk";
const app = express();
app.use(express.json());
// Connect to headless CLI server
const client = new CopilotClient({ cliUrl: "localhost:4321" });
app.post("/api/chat", async (req, res) => {
const { sessionId, message, userToken } = req.body;
const session = await client.createSession({
sessionId: `user-${sessionId}`,
model: "gpt-4.1",
githubToken: userToken, // Per-user OAuth token
});
const response = await session.sendAndWait({ prompt: message });
res.json({ sessionId, content: response?.data.content });
});
app.listen(3000);
Follow the Copilot CLI installation guide
npm, pip, go get, dotnet add, or Maven/Gradle
client.createSession({ model: "gpt-4.1" })
| Resource | Link |
|---|---|
| SDK Repository | github.com/github/copilot-sdk |
| Documentation | docs/ in the repository |
| Cookbook & Recipes | github.com/github/awesome-copilot |
| Java SDK | github.com/github/copilot-sdk-java |
| GitHub MCP Server | github.com/github/github-mcp-server |
Stream AI responses token by token for interactive, real-time user experiences
const session = await client.createSession({
model: "gpt-4.1",
streaming: true,
onPermissionRequest: async () => ({ kind: "approved" }),
});
// Subscribe to real-time streaming events
session.on("assistant.message_delta", (event) => {
process.stdout.write(event.data.delta ?? "");
});
session.on("assistant.message", (event) => {
console.log("\n--- Full response complete ---");
});
await session.sendAndWait({
prompt: "Write a quicksort implementation in TypeScript"
});
Combine custom agents with hooks for enterprise-grade auditing
const READ_ONLY_TOOLS = ["read_file", "glob", "grep", "view"];
const session = await client.createSession({
model: "gpt-4.1",
customAgents: [{
name: "security-auditor",
prompt: "You are a security expert. Focus on OWASP Top 10.",
tools: READ_ONLY_TOOLS,
}],
agent: "security-auditor",
});
hooks: {
onPreToolUse: async (input) => {
// Enforce read-only: deny any write operations
if (!READ_ONLY_TOOLS.includes(input.toolName)) {
return { permissionDecision: "deny",
permissionDecisionReason: `"${input.toolName}" blocked` };
}
return { permissionDecision: "allow" };
},
onPostToolUse: async (input) => {
// Redact any secrets found in tool output
if (typeof input.toolResult === "string") {
const redacted = input.toolResult.replace(
/api[_-]?key\s*[:=]\s*["']?[\w\-\.]+["']?/gi, "[REDACTED]");
if (redacted !== input.toolResult)
return { modifiedResult: redacted };
}
return null;
},
}
A major release with new capabilities, API refinements, and breaking changes
skipPermission on tools โ bypass confirmation for low-risk read-only toolsautoRestart removed โ deprecated across all SDKsStart() context โ cancelling context no longer kills CLI process; use Stop()LogOptions.Ephemeral โ changed from bool to *boolcopilot.jsonrpc โ copilot._jsonrpc๐ releases/tag/v0.2.0
Surgically edit individual sections of the Copilot system prompt
replace | Replace entire section content |
append | Add content after the section |
prepend | Add content before the section |
remove | Remove the section entirely |
transform | Callback โ receives text, returns modified |
await client.createSession({
systemMessage: {
mode: "customize",
sections: {
identity: {
action: (current) =>
current.replace("Copilot",
"Acme Assistant"),
},
tone: {
action: "replace",
content: "Be concise.",
},
},
},
});