Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ client = CopilotClient(log_level="debug")
```go
import copilot "github.com/github/copilot-sdk/go"

client, err := copilot.NewClient(copilot.ClientOptions{
client := copilot.NewClient(&copilot.ClientOptions{
LogLevel: "debug",
})
```
Expand Down Expand Up @@ -169,7 +169,7 @@ var client = new CopilotClient(new CopilotClientOptions
<summary><strong>Go</strong></summary>

```go
client, _ := copilot.NewClient(copilot.ClientOptions{
client := copilot.NewClient(&copilot.ClientOptions{
CLIPath: "/usr/local/bin/copilot",
})
```
Expand Down Expand Up @@ -222,7 +222,7 @@ var client = new CopilotClient(new CopilotClientOptions
<summary><strong>Go</strong></summary>

```go
client, _ := copilot.NewClient(copilot.ClientOptions{
client := copilot.NewClient(&copilot.ClientOptions{
GithubToken: os.Getenv("GITHUB_TOKEN"),
})
```
Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -1020,7 +1020,7 @@ const session = await client.createSession({
});
```

📖 **[Full MCP documentation →](./mcp.md)** - Learn about local vs remote servers, all configuration options, and troubleshooting.
📖 **[Full MCP documentation →](./mcp/overview.md)** - Learn about local vs remote servers, all configuration options, and troubleshooting.

### Create Custom Agents

Expand Down
26 changes: 13 additions & 13 deletions docs/guides/session-persistence.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const session = await client.createSession({
});

// Do some work...
await session.sendPrompt({ content: "Analyze my codebase" });
await session.sendAndWait({ prompt: "Analyze my codebase" });

// Session state is automatically persisted
// You can safely close the client
Expand All @@ -57,24 +57,24 @@ session = await client.create_session(
)

# Do some work...
await session.send_prompt(content="Analyze my codebase")
await session.send_and_wait({"prompt": "Analyze my codebase"})

# Session state is automatically persisted
```

### Go

```go
client, _ := copilot.NewClient()
client := copilot.NewClient(nil)

// Create a session with a meaningful ID
session, _ := client.CreateSession(copilot.CreateSessionOptions{
session, _ := client.CreateSession(context.Background(), &copilot.SessionConfig{
SessionID: "user-123-task-456",
Model: "gpt-5.2-codex",
})

// Do some work...
session.SendPrompt(copilot.PromptOptions{Content: "Analyze my codebase"})
session.SendAndWait(context.Background(), copilot.MessageOptions{Prompt: "Analyze my codebase"})

// Session state is automatically persisted
```
Expand All @@ -94,7 +94,7 @@ var session = await client.CreateSessionAsync(new CreateSessionOptions
});

// Do some work...
await session.SendPromptAsync(new PromptOptions { Content = "Analyze my codebase" });
await session.SendAndWaitAsync(new MessageOptions { Prompt = "Analyze my codebase" });

// Session state is automatically persisted
```
Expand Down Expand Up @@ -124,7 +124,7 @@ flowchart LR
const session = await client.resumeSession("user-123-task-456");

// Continue where you left off
await session.sendPrompt({ content: "What did we discuss earlier?" });
await session.sendAndWait({ prompt: "What did we discuss earlier?" });
```

### Python
Expand All @@ -134,17 +134,17 @@ await session.sendPrompt({ content: "What did we discuss earlier?" });
session = await client.resume_session("user-123-task-456")

# Continue where you left off
await session.send_prompt(content="What did we discuss earlier?")
await session.send_and_wait({"prompt": "What did we discuss earlier?"})
```

### Go

```go
// Resume from a different client instance (or after restart)
session, _ := client.ResumeSession("user-123-task-456", copilot.ResumeSessionOptions{})
session, _ := client.ResumeSession(context.Background(), "user-123-task-456", nil)
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ResumeSession method only takes two arguments: ctx context.Context and sessionID string. The third nil argument should be removed. According to the Go SDK source code (go/client.go:660), the correct signature is func (c *Client) ResumeSession(ctx context.Context, sessionID string) (*Session, error). If additional options are needed, use ResumeSessionWithOptions instead.

Suggested change
session, _ := client.ResumeSession(context.Background(), "user-123-task-456", nil)
session, _ := client.ResumeSession(context.Background(), "user-123-task-456")

Copilot uses AI. Check for mistakes.

// Continue where you left off
session.SendPrompt(copilot.PromptOptions{Content: "What did we discuss earlier?"})
session.SendAndWait(context.Background(), copilot.MessageOptions{Prompt: "What did we discuss earlier?"})
```

### C# (.NET)
Expand All @@ -154,7 +154,7 @@ session.SendPrompt(copilot.PromptOptions{Content: "What did we discuss earlier?"
var session = await client.ResumeSessionAsync("user-123-task-456");

// Continue where you left off
await session.SendPromptAsync(new PromptOptions { Content = "What did we discuss earlier?" });
await session.SendAndWaitAsync(new MessageOptions { Prompt = "What did we discuss earlier?" });
```

## Using BYOK (Bring Your Own Key) with Resumed Sessions
Expand Down Expand Up @@ -290,7 +290,7 @@ When a task completes, destroy the session explicitly rather than waiting for ti
```typescript
try {
// Do work...
await session.sendPrompt({ content: "Complete the task" });
await session.sendAndWait({ prompt: "Complete the task" });

// Task complete - clean up
await session.destroy();
Expand Down Expand Up @@ -472,7 +472,7 @@ async function withSessionLock<T>(
// Usage
await withSessionLock("user-123-task-456", async () => {
const session = await client.resumeSession("user-123-task-456");
await session.sendPrompt({ content: "Continue the task" });
await session.sendAndWait({ prompt: "Continue the task" });
});
```

Expand Down
2 changes: 1 addition & 1 deletion docs/hooks/error-handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ session = await client.create_session({
<summary><strong>Go</strong></summary>

```go
session, _ := client.CreateSession(ctx, copilot.SessionConfig{
session, _ := client.CreateSession(context.Background(), &copilot.SessionConfig{
Hooks: &copilot.SessionHooks{
OnErrorOccurred: func(input copilot.ErrorOccurredHookInput, inv copilot.HookInvocation) (*copilot.ErrorOccurredHookOutput, error) {
fmt.Printf("[%s] Error: %s\n", inv.SessionID, input.Error)
Expand Down
6 changes: 4 additions & 2 deletions docs/hooks/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,15 @@ async def main():
package main

import (
"context"
"fmt"
copilot "github.com/github/copilot-sdk/go"
)

func main() {
client, _ := copilot.NewClient(copilot.ClientOptions{})
client := copilot.NewClient(nil)

session, _ := client.CreateSession(ctx, copilot.SessionConfig{
session, _ := client.CreateSession(context.Background(), &copilot.SessionConfig{
Hooks: &copilot.SessionHooks{
OnPreToolUse: func(input copilot.PreToolUseHookInput, inv copilot.HookInvocation) (*copilot.PreToolUseHookOutput, error) {
fmt.Printf("Tool called: %s\n", input.ToolName)
Expand All @@ -113,6 +114,7 @@ func main() {
},
},
})
_ = session
}
```

Expand Down
2 changes: 1 addition & 1 deletion docs/hooks/post-tool-use.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ session = await client.create_session({
<summary><strong>Go</strong></summary>

```go
session, _ := client.CreateSession(ctx, copilot.SessionConfig{
session, _ := client.CreateSession(context.Background(), &copilot.SessionConfig{
Hooks: &copilot.SessionHooks{
OnPostToolUse: func(input copilot.PostToolUseHookInput, inv copilot.HookInvocation) (*copilot.PostToolUseHookOutput, error) {
fmt.Printf("[%s] Tool: %s\n", inv.SessionID, input.ToolName)
Expand Down
2 changes: 1 addition & 1 deletion docs/hooks/pre-tool-use.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ session = await client.create_session({
<summary><strong>Go</strong></summary>

```go
session, _ := client.CreateSession(ctx, copilot.SessionConfig{
session, _ := client.CreateSession(context.Background(), &copilot.SessionConfig{
Hooks: &copilot.SessionHooks{
OnPreToolUse: func(input copilot.PreToolUseHookInput, inv copilot.HookInvocation) (*copilot.PreToolUseHookOutput, error) {
fmt.Printf("[%s] Calling %s\n", inv.SessionID, input.ToolName)
Expand Down
2 changes: 1 addition & 1 deletion docs/hooks/user-prompt-submitted.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ session = await client.create_session({
<summary><strong>Go</strong></summary>

```go
session, _ := client.CreateSession(ctx, copilot.SessionConfig{
session, _ := client.CreateSession(context.Background(), &copilot.SessionConfig{
Hooks: &copilot.SessionHooks{
OnUserPromptSubmitted: func(input copilot.UserPromptSubmittedHookInput, inv copilot.HookInvocation) (*copilot.UserPromptSubmittedHookOutput, error) {
fmt.Printf("[%s] User: %s\n", inv.SessionID, input.Prompt)
Expand Down
Loading