This guide covers common issues and debugging techniques for the Copilot SDK across all supported languages.
The first step in debugging is enabling verbose logging to see what's happening under the hood.
import { CopilotClient } from "copilot-sdk-supercharged";
const client = new CopilotClient({
logLevel: "debug", // Options: "none", "error", "warning", "info", "debug", "all"
});
from copilot import CopilotClient
client = CopilotClient({"log_level": "debug"})
import copilot "github.com/jeremiahjordanisaacson/copilot-sdk-supercharged/go"
client := copilot.NewClient(&copilot.ClientOptions{
LogLevel: "debug",
})
using GitHub.Copilot.SDK;
using Microsoft.Extensions.Logging;
// Using ILogger
var loggerFactory = LoggerFactory.Create(builder =>
{
builder.SetMinimumLevel(LogLevel.Debug);
builder.AddConsole();
});
var client = new CopilotClient(new CopilotClientOptions
{
LogLevel = "debug",
Logger = loggerFactory.CreateLogger<CopilotClient>()
});
The CLI writes logs to a directory. You can specify a custom location:
const client = new CopilotClient({
cliArgs: ["--log-dir", "/path/to/logs"],
});
# The Python SDK does not currently support passing extra CLI arguments.
# Logs are written to the default location or can be configured via
# the CLI when running in server mode.
Note: Python SDK logging configuration is limited. For advanced logging, run the CLI manually with
--log-dirand connect viacli_url.
// The Go SDK does not currently support passing extra CLI arguments.
// For custom log directories, run the CLI manually with --log-dir
// and connect via CLIUrl option.
var client = new CopilotClient(new CopilotClientOptions
{
CliArgs = new[] { "--log-dir", "/path/to/logs" }
});
Cause: The Copilot CLI is not installed or not in PATH.
Solution:
Install the CLI: Installation guide
Verify installation:
copilot --version
Or specify the full path:
const client = new CopilotClient({
cliPath: "/usr/local/bin/copilot",
});
client = CopilotClient({"cli_path": "/usr/local/bin/copilot"})
client := copilot.NewClient(&copilot.ClientOptions{
CLIPath: "/usr/local/bin/copilot",
})
var client = new CopilotClient(new CopilotClientOptions
{
CliPath = "/usr/local/bin/copilot"
});
Cause: The CLI is not authenticated with GitHub.
Solution:
Authenticate the CLI:
copilot auth login
Or provide a token programmatically:
const client = new CopilotClient({
githubToken: process.env.GITHUB_TOKEN,
});
import os
client = CopilotClient({"github_token": os.environ.get("GITHUB_TOKEN")})
client := copilot.NewClient(&copilot.ClientOptions{
GithubToken: os.Getenv("GITHUB_TOKEN"),
})
var client = new CopilotClient(new CopilotClientOptions
{
GithubToken = Environment.GetEnvironmentVariable("GITHUB_TOKEN")
});
Cause: Attempting to use a session that was destroyed or doesn't exist.
Solution:
Ensure you're not calling methods after destroy():
await session.destroy();
// Don't use session after this!
For resuming sessions, verify the session ID exists:
const sessions = await client.listSessions();
console.log("Available sessions:", sessions);
Cause: The CLI server process crashed or failed to start.
Solution:
Check if the CLI runs correctly standalone:
copilot --server --stdio
Enable auto-restart (enabled by default):
const client = new CopilotClient({
autoRestart: true,
});
Check for port conflicts if using TCP mode:
const client = new CopilotClient({
useStdio: false,
port: 0, // Use random available port
});
MCP (Model Context Protocol) servers can be tricky to debug. For comprehensive MCP debugging guidance, see the dedicated MCP Debugging Guide.
tools: ["*"]initialize request correctlycwd) is set if neededBefore integrating with the SDK, verify your MCP server works:
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}' | /path/to/your/mcp-server
See MCP Debugging Guide for detailed troubleshooting.
The SDK supports two transport modes:
| Mode | Description | Use Case |
|---|---|---|
| Stdio (default) | CLI runs as subprocess, communicates via pipes | Local development, single process |
| TCP | CLI runs separately, communicates via TCP socket | Multiple clients, remote CLI |
Stdio mode (default):
const client = new CopilotClient({
useStdio: true, // This is the default
});
TCP mode:
const client = new CopilotClient({
useStdio: false,
port: 8080, // Or 0 for random port
});
Connect to existing server:
const client = new CopilotClient({
cliUrl: "localhost:8080", // Connect to running server
});
Check client state:
console.log("Connection state:", client.getState());
// Should be "connected" after start()
Listen for state changes:
client.on("stateChange", (state) => {
console.log("State changed to:", state);
});
Verify CLI process is running:
# Check for copilot processes
ps aux | grep copilot
Verify tool registration:
const session = await client.createSession({
tools: [myTool],
});
// Check registered tools
console.log("Registered tools:", session.getTools?.());
Check tool schema is valid JSON Schema:
const myTool = {
name: "get_weather",
description: "Get weather for a location",
parameters: {
type: "object",
properties: {
location: { type: "string", description: "City name" },
},
required: ["location"],
},
handler: async (args) => {
return { temperature: 72 };
},
};
Ensure handler returns valid result:
handler: async (args) => {
// Must return something JSON-serializable
return { success: true, data: "result" };
// Don't return undefined or non-serializable objects
}
Subscribe to error events:
session.on("tool.execution_error", (event) => {
console.error("Tool error:", event.data);
});
session.on("error", (event) => {
console.error("Session error:", event.data);
});
Path separators: Use raw strings or forward slashes:
CliPath = @"C:\Program Files\GitHub\copilot.exe"
// or
CliPath = "C:/Program Files/GitHub/copilot.exe"
PATHEXT resolution: The SDK handles this automatically, but if issues persist:
// Explicitly specify .exe
Command = "myserver.exe" // Not just "myserver"
Console encoding: Ensure UTF-8 for proper JSON handling:
Console.OutputEncoding = System.Text.Encoding.UTF8;
Gatekeeper issues: If CLI is blocked:
xattr -d com.apple.quarantine /path/to/copilot
PATH issues in GUI apps: GUI applications may not inherit shell PATH:
const client = new CopilotClient({
cliPath: "/opt/homebrew/bin/copilot", // Full path
});
Permission issues:
chmod +x /path/to/copilot
Missing libraries: Check for required shared libraries:
ldd /path/to/copilot
If you're still stuck:
Collect debug information:
copilot --version)Search existing issues: GitHub Issues
Open a new issue with the collected information
Can you improve this documentation? These fine people already did:
Patrick Nikoletich & Jeremiah IsaacsonEdit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |