Das Copilot Agent SDK ermöglicht die Entwicklung eigener KI-Agenten für GitHub Copilot. So erweitern Sie Copilot um Ihre Business-Logik.
Was ist das Copilot Agent SDK?
Das SDK ist ein Framework zur Erstellung von:
- Custom Agents – Spezialisierte KI-Assistenten
- Tool Integrations – Externe Systeme anbinden
- Workflow Automation – Komplexe Abläufe automatisieren
- Domain Experts – Branchenspezifisches Wissen einbringen
Architektur-Überblick
Komponenten
[GitHub Copilot] ←→ [Agent Runtime]
↓
[Your Agent]
↓
[Tools] [Memory] [Context]Agent-Lebenszyklus
- 1Initialisierung – Agent wird geladen
- 2Context-Aufbau – Relevanter Kontext wird bereitgestellt
- 3Reasoning – Agent verarbeitet Anfrage
- 4Tool Execution – Agent nutzt Tools
- 5Response – Ergebnis wird zurückgegeben
Erste Schritte
Installation
npm install @github/copilot-agent-sdkBasis-Agent erstellen
import { Agent, AgentContext } from '@github/copilot-agent-sdk';
export class MyCustomAgent extends Agent {
name = 'my-custom-agent';
description = 'Ein Agent für spezifische Aufgaben';
async execute(context: AgentContext): Promise<string> {
const { query, files, history } = context;
// Ihre Logik hier
const result = await this.processQuery(query);
return result;
}
}Agent registrieren
import { registerAgent } from '@github/copilot-agent-sdk';
import { MyCustomAgent } from './my-agent';
registerAgent(new MyCustomAgent());Agent-Konfiguration
Manifest
name: my-custom-agent
version: 1.0.0
description: Beschreibung des Agenten
capabilities:
- code-generation
- file-operations
- external-api
triggers:
- pattern: "@myagent"
description: Aktiviert den Custom AgentPermissions
permissions:
files:
read: true
write: true
network:
allowed_hosts:
- api.cnext.ch
secrets:
- MY_API_KEYKontext und Memory
Context-Zugriff
async execute(context: AgentContext) {
// Aktuelle Datei
const currentFile = context.activeFile;
// Workspace-Dateien
const files = await context.workspace.getFiles('**/*.ts');
// Conversation-History
const previousMessages = context.history;
// User-Präferenzen
const preferences = context.user.preferences;
}Langzeit-Memory
// Speichern
await context.memory.set('lastAnalysis', analysisResult);
// Abrufen
const cached = await context.memory.get('lastAnalysis');
// Mit TTL
await context.memory.set('session', data, { ttl: 3600 });Tools definieren
Tool-Struktur
import { Tool, ToolResult } from '@github/copilot-agent-sdk';
const searchTool: Tool = {
name: 'search-docs',
description: 'Durchsucht die Dokumentation',
parameters: {
query: { type: 'string', required: true },
limit: { type: 'number', default: 10 }
},
execute: async (params): Promise<ToolResult> => {
const results = await searchDocumentation(params.query);
return { success: true, data: results };
}
};Tools registrieren
class MyAgent extends Agent {
tools = [searchTool, analyzeTool, generateTool];
}Testing
Unit Tests
import { TestContext } from '@github/copilot-agent-sdk/testing';
describe('MyCustomAgent', () => {
it('should process query correctly', async () => {
const agent = new MyCustomAgent();
const context = TestContext.create({
query: 'Analysiere den Code',
files: ['src/main.ts']
});
const result = await agent.execute(context);
expect(result).toContain('Analyse');
});
});Integration Tests
npx copilot-agent test --interactiveDeployment
Lokale Entwicklung
npx copilot-agent devPublishing
npx copilot-agent publishBest Practices
Klare Verantwortlichkeiten
- Ein Agent = Eine Aufgabe
- Fokussierte Funktionalität
- Gute Beschreibungen
Fehlerbehandlung
try {
const result = await externalApi.call();
return formatSuccess(result);
} catch (error) {
logger.error('API call failed', error);
return formatError('Versuchen Sie es später erneut');
}Performance
- Caching nutzen
- Parallele Tool-Aufrufe
- Streaming für lange Antworten
CNEXT-Unterstützung
Wir helfen bei:
- 1Agent-Konzeption – Use Cases definieren
- 2Entwicklung – Custom Agents bauen
- 3Integration – Enterprise-Systeme anbinden
- 4Deployment – Sicheres Rollout
Fazit
Das Copilot Agent SDK macht Copilot zu Ihrer Plattform. Entwickeln Sie Agenten, die Ihr Business verstehen.

