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({
mode: "coding-agent",
observability: {
logLevel: "debug",
},
});
from copilot import CopilotClient
client = CopilotClient(mode="coding-agent", observability={"log_level": "debug"})
package main
import copilot "github.com/microsoft/copilot-sdk/go/v2"
func main() {
client := copilot.NewClient(&copilot.ClientOptions{
Mode: copilot.ModeCodingAgent,
Observability: copilot.ClientObservabilityOptions{
LogLevel: "debug",
},
})
_ = client
}
import copilot "github.com/microsoft/copilot-sdk/go/v2"
client := copilot.NewClient(&copilot.ClientOptions{
Mode: copilot.ModeCodingAgent,
Observability: copilot.ClientObservabilityOptions{
LogLevel: "debug",
},
})
using Microsoft.Copilot;
using Microsoft.Extensions.Logging;
// Using ILogger (AddConsole comes from the Microsoft.Extensions.Logging.Console package)
var loggerFactory = LoggerFactory.Create(builder =>
{
builder.SetMinimumLevel(LogLevel.Debug);
builder.AddConsole();
});
var client = new CopilotClient(new CopilotClientOptions
{
Mode = CopilotClientMode.CodingAgent,
Observability = new ClientObservabilityOptions
{
LogLevel = CopilotLogLevel.Debug,
Logger = loggerFactory.CreateLogger<CopilotClient>()
}
});
import com.microsoft.copilot.CopilotClient;
import com.microsoft.copilot.rpc.*;
var client = new CopilotClient(new CopilotClientOptions().setMode(CopilotClientMode.CODING_AGENT)
.setObservability(new ClientObservabilityOptions()
.setLogLevel("debug")));
40 languages supported. See the full SDK list with cookbooks for Objective-C, F#, Groovy, Julia, COBOL, OCaml, Zig, Nim, D, Erlang, Crystal, Tcl, Solidity, V, and 18 more.
The SDK-managed out-of-process runtime writes redacted
process-<timestamp>-<pid>.log files under the Copilot home's logs directory
by default in coding-agent mode. SDKs in empty mode do not set the logging
opt-in, but an inherited setting can still enable it; session events remain
available to collectLogs. An explicitly selected older runtime executable may
ignore this setting. You can specify a custom log location with --log-dir;
collectLogs searches the configured directory. In-process connections do
not start a separate logging process.
import { CopilotClient, RuntimeConnection } from "copilot-sdk-supercharged";
const client = new CopilotClient({
mode: "coding-agent",
runtime: RuntimeConnection.forSpawnedStdio({ args: ["--log-dir", "/path/to/logs"] }),
});
from copilot import CopilotClient, RuntimeConnection
client = CopilotClient(
mode="coding-agent",
runtime=RuntimeConnection.for_spawned_stdio(args=["--log-dir", "/path/to/logs"])
)
package main
import copilot "github.com/microsoft/copilot-sdk/go/v2"
func main() {
client := copilot.NewClient(&copilot.ClientOptions{
Mode: copilot.ModeCodingAgent,
Runtime: copilot.SpawnedStdioConnection{
Args: []string{"--log-dir", "/path/to/logs"},
},
})
_ = client
}
client := copilot.NewClient(&copilot.ClientOptions{
Mode: copilot.ModeCodingAgent,
Runtime: copilot.SpawnedStdioConnection{
Args: []string{"--log-dir", "/path/to/logs"},
},
})
var client = new CopilotClient(new CopilotClientOptions
{
Mode = CopilotClientMode.CodingAgent,
Runtime = RuntimeConnection.ForSpawnedStdio(args: new[] { "--log-dir", "/path/to/logs" })
});
import com.microsoft.copilot.rpc.CopilotClientMode;
import com.microsoft.copilot.CopilotClient;
import com.microsoft.copilot.rpc.CopilotClientOptions;
import com.microsoft.copilot.rpc.RuntimeConnection;
import java.util.List;
var client = new CopilotClient(new CopilotClientOptions().setMode(CopilotClientMode.CODING_AGENT)
.setRuntime(RuntimeConnection.forSpawnedStdio().setArgs(List.of("--log-dir", "/path/to/logs"))));
Cause: A spawned connection (forSpawnedStdio or forSpawnedTcp) could not find the Copilot runtime executable (copilot-runtime), or the path you configured for it is invalid. The SDK does not need a separate Copilot CLI installation. The default in-process connection loads the native runtime library instead of starting an executable; if that library is missing or doesn't match your platform, startup fails without falling back to a subprocess. See Runtime library resolution.
Solution:
Make sure the runtime is available. The Node.js SDK installs it with an optional @microsoft/copilot-sdk-<platform> package, the .NET SDK downloads it for your build's runtime identifier, and the Rust SDK bundles it by default, so reinstall or rebuild if it is missing. For Python, run python -m copilot download-runtime; for Go, run the bundler tool; for Java, add com.microsoft:copilot-sdk-runtime with the classifier for your platform. If you supply the executable yourself, use the github-copilot-<version>-<platform>.tgz asset from the Copilot CLI releases for the runtime version that matches your SDK, and keep the package layout intact: copilot-runtime loads runtime.node from its own directory and finds its bundled assets in the package root. The examples below assume the archive's package directory was extracted to /opt/copilot.
Specify the full path to the runtime executable:
import { CopilotClient, RuntimeConnection } from "copilot-sdk-supercharged";
const client = new CopilotClient({
mode: "coding-agent",
runtime: RuntimeConnection.forSpawnedStdio({ path: "/opt/copilot/prebuilds/linux-x64/copilot-runtime" }),
});
from copilot import CopilotClient, RuntimeConnection
client = CopilotClient(
mode="coding-agent",
runtime=RuntimeConnection.for_spawned_stdio(path="/opt/copilot/prebuilds/linux-x64/copilot-runtime")
)
package main
import copilot "github.com/microsoft/copilot-sdk/go/v2"
func main() {
client := copilot.NewClient(&copilot.ClientOptions{
Mode: copilot.ModeCodingAgent,
Runtime: copilot.SpawnedStdioConnection{Path: "/opt/copilot/prebuilds/linux-x64/copilot-runtime"},
})
_ = client
}
client := copilot.NewClient(&copilot.ClientOptions{
Mode: copilot.ModeCodingAgent,
Runtime: copilot.SpawnedStdioConnection{Path: "/opt/copilot/prebuilds/linux-x64/copilot-runtime"},
})
var client = new CopilotClient(new CopilotClientOptions
{
Mode = CopilotClientMode.CodingAgent,
Runtime = RuntimeConnection.ForSpawnedStdio(path: "/opt/copilot/prebuilds/linux-x64/copilot-runtime"),
});
var client = new CopilotClient(new CopilotClientOptions().setMode(CopilotClientMode.CODING_AGENT)
.setRuntime(RuntimeConnection.forSpawnedStdio("/opt/copilot/prebuilds/linux-x64/copilot-runtime"))
);
Cause: The runtime has no GitHub credentials to use.
Sending a message on such a session produces a session.error event with errorType: "authentication", errorCode: "no_account", the message This session is not signed in., and remediation: "sign_in". Session calls that reject with Not authenticated, such as session.model.list, carry the same fields in their JSON-RPC error data. Use errorCode to detect this state instead of matching the message text.
Solution:
Sign in once with the Copilot CLI; the runtime can use the stored credentials:
copilot login
Or provide a token programmatically:
import { CopilotClient } from "copilot-sdk-supercharged";
const client = new CopilotClient({
mode: "coding-agent",
github: {
token: process.env.GITHUB_TOKEN,
},
});
import os
from copilot import CopilotClient
client = CopilotClient(mode="coding-agent", github={"token": os.environ.get("GITHUB_TOKEN")})
package main
import (
copilot "github.com/microsoft/copilot-sdk/go/v2"
"os"
)
func main() {
client := copilot.NewClient(&copilot.ClientOptions{
Mode: copilot.ModeCodingAgent,
GitHub: copilot.ClientGitHubOptions{
Token: os.Getenv("GITHUB_TOKEN"),
},
})
_ = client
}
client := copilot.NewClient(&copilot.ClientOptions{
Mode: copilot.ModeCodingAgent,
GitHub: copilot.ClientGitHubOptions{
Token: os.Getenv("GITHUB_TOKEN"),
},
})
var client = new CopilotClient(new CopilotClientOptions
{
Mode = CopilotClientMode.CodingAgent,
GitHub = new ClientGitHubOptions
{
Token = Environment.GetEnvironmentVariable("GITHUB_TOKEN")
}
});
var client = new CopilotClient(new CopilotClientOptions().setMode(CopilotClientMode.CODING_AGENT)
.setGitHub(new ClientGitHubOptions()
.setToken(System
.getenv("GITHUB_TOKEN"))));
Cause: Attempting to use a session that was destroyed or doesn't exist.
Solution:
Ensure you're not calling methods after disconnect():
await session.disconnect();
// 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 runtime process crashed or failed to start, or no runtime server is listening at the address you connected to.
Solution:
Check if the runtime starts correctly on its own. It prints CLI server listening on port <port> when it is ready; press Ctrl+C to stop it:
copilot-runtime --server
Check for port conflicts if using TCP mode:
import { CopilotClient, RuntimeConnection } from "copilot-sdk-supercharged";
const client = new CopilotClient({
mode: "coding-agent",
runtime: RuntimeConnection.forSpawnedTcp({ 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 correctlyworkingDirectory) 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.
Choose the connection type appropriate to your deployment:
| Mode | Description | Use Case |
|---|---|---|
| In-process (default) | Native runtime in the application process, JSON-RPC over the C ABI | Applications with matching native runtime assets |
| Stdio | Runtime runs as a subprocess, communicates via pipes | Subprocess isolation or per-client process configuration |
| TCP | Runtime listens on a TCP socket, spawned by the SDK or separately | Multiple clients, shared or remote runtime |
Stdio mode:
import { CopilotClient, RuntimeConnection } from "copilot-sdk-supercharged";
const client = new CopilotClient({
mode: "coding-agent",
runtime: RuntimeConnection.forSpawnedStdio(),
});
TCP mode:
import { CopilotClient, RuntimeConnection } from "copilot-sdk-supercharged";
const client = new CopilotClient({
mode: "coding-agent",
runtime: RuntimeConnection.forSpawnedTcp({ port: 8080 }), // Or 0 for random port
});
Connect to a running runtime server:
import { CopilotClient, RuntimeConnection } from "copilot-sdk-supercharged";
const client = new CopilotClient({
mode: "coding-agent",
runtime: RuntimeConnection.forTcp("localhost", 8080), // Connect to a running runtime server
});
The default in-process transport runs the runtime inside your application process, so there is no child process or socket to check; see In-process runtime.
Check the connection:
const response = await client.ping();
console.log("Server responded at", response.timestamp);
// Starts the client if needed; surfaces startup and connection errors
For spawned connections, verify the runtime process is running:
# Check for copilot-runtime processes
ps aux | grep copilot-runtime
Verify tool registration:
import type { Tool } from "copilot-sdk-supercharged";
declare const myTool: Tool<{ location: string }>;
const session = await client.createSession({
tools: {
definitions: [myTool],
},
});
const session = await client.createSession({
tools: {
definitions: [myTool],
},
});
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: { location: string }) => {
return { temperature: 72 };
},
};
Ensure handler returns valid result:
handler: async (args: { location: string }) => {
// Must return something JSON-serializable
return { success: true, data: "result" };
// Don't return undefined or non-serializable objects
};
A failed tool call arrives as tool.execution_complete with success: false, and session errors arrive as session.error:
session.on("tool.execution_complete", (event) => {
if (!event.data.success) {
console.error("Tool error:", event.data.error);
}
});
session.on("session.error", (event) => {
console.error("Session error:", event.data);
});
Path separators: Use raw strings or forward slashes:
var options = new CopilotClientOptions
{
Mode = CopilotClientMode.CodingAgent,
// Verbatim string
Runtime = RuntimeConnection.ForSpawnedStdio(path: @"C:\Program Files\Copilot\prebuilds\win32-x64\copilot-runtime.exe"),
};
// or forward slashes
options.Runtime = RuntimeConnection.ForSpawnedStdio(path: "C:/Program Files/Copilot/prebuilds/win32-x64/copilot-runtime.exe");
PATHEXT resolution: The SDK handles this automatically, but if issues persist:
var server = new McpStdioServerConfig
{
// 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 the runtime executable is blocked:
xattr -d com.apple.quarantine /path/to/copilot-runtime
PATH issues in GUI apps: GUI applications may not inherit shell PATH:
import { CopilotClient, RuntimeConnection } from "copilot-sdk-supercharged";
const client = new CopilotClient({
mode: "coding-agent",
runtime: RuntimeConnection.forSpawnedStdio({ path: "/opt/copilot/prebuilds/darwin-arm64/copilot-runtime" }), // Full path
});
Permission issues:
chmod +x /path/to/copilot-runtime
Missing libraries: Check for required shared libraries:
ldd /path/to/copilot-runtime
If you're still stuck:
Collect debug information:
version from client.getStatus())Search existing issues: GitHub Issues
Open a new issue with the collected information
Can you improve this documentation? These fine people already did:
copilot-cli-release-app[bot], Steve Sanderson, Jeremiah Isaacson, copilot-sdk-mirror-writer[bot], Stephen Toub, Sunbrye Ly, Patrick Nikoletich, Ed Burns & Bruno BorgesEdit 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 |