Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion .github/workflows/copilot-setup-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: "1.23"
go-version: "1.24"

# Setup .NET (for .NET SDK)
- name: Set up .NET
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/go-sdk-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
id: setup-copilot
- uses: actions/setup-go@v6
with:
go-version: "1.23"
go-version: "1.24"

- name: Run go fmt
if: runner.os == 'Linux'
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ This is a multi-language SDK repository. Install the tools for the SDK(s) you pl
1. Install dependencies: `cd python && uv pip install -e ".[dev]"`

### Go SDK
1. Install [Go 1.23+](https://go.dev/doc/install)
1. Install [Go 1.24+](https://go.dev/doc/install)
1. Install [golangci-lint](https://golangci-lint.run/welcome/install/#local-installation)
1. Install dependencies: `cd go && go mod download`

Expand Down
60 changes: 30 additions & 30 deletions go/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ func main() {
})

// Start the client
if err := client.Start(); err != nil {
if err := client.Start(context.Background()); err != nil {
log.Fatal(err)
}
defer client.Stop()

// Create a session
session, err := client.CreateSession(&copilot.SessionConfig{
session, err := client.CreateSession(context.Background(), &copilot.SessionConfig{
Model: "gpt-5",
})
if err != nil {
Expand All @@ -57,7 +57,7 @@ func main() {
})

// Send a message
_, err = session.Send(copilot.MessageOptions{
_, err = session.Send(context.Background(), copilot.MessageOptions{
Prompt: "What is 2+2?",
})
if err != nil {
Expand All @@ -74,16 +74,16 @@ func main() {
### Client

- `NewClient(options *ClientOptions) *Client` - Create a new client
- `Start() error` - Start the CLI server
- `Stop() []error` - Stop the CLI server (returns array of errors, empty if all succeeded)
- `Start(ctx context.Context) error` - Start the CLI server
- `Stop() error` - Stop the CLI server
- `ForceStop()` - Forcefully stop without graceful cleanup
- `CreateSession(config *SessionConfig) (*Session, error)` - Create a new session
- `ResumeSession(sessionID string) (*Session, error)` - Resume an existing session
- `ResumeSessionWithOptions(sessionID string, config *ResumeSessionConfig) (*Session, error)` - Resume with additional configuration
- `ListSessions() ([]SessionMetadata, error)` - List all sessions known to the server
- `DeleteSession(sessionID string) error` - Delete a session permanently
- `GetState() ConnectionState` - Get connection state
- `Ping(message string) (*PingResponse, error)` - Ping the server
- `CreateSession(ctx context.Context, config *SessionConfig) (*Session, error)` - Create a new session
- `ResumeSession(ctx context.Context, sessionID string) (*Session, error)` - Resume an existing session
- `ResumeSessionWithOptions(ctx context.Context, sessionID string, config *ResumeSessionConfig) (*Session, error)` - Resume with additional configuration
- `ListSessions(ctx context.Context) ([]SessionMetadata, error)` - List all sessions known to the server
- `DeleteSession(ctx context.Context, sessionID string) error` - Delete a session permanently
- `State() ConnectionState` - Get connection state
- `Ping(ctx context.Context, message string) (*PingResponse, error)` - Ping the server

**ClientOptions:**

Expand Down Expand Up @@ -121,10 +121,10 @@ func main() {

### Session

- `Send(options MessageOptions) (string, error)` - Send a message
- `Send(ctx context.Context, options MessageOptions) (string, error)` - Send a message
- `On(handler SessionEventHandler) func()` - Subscribe to events (returns unsubscribe function)
- `Abort() error` - Abort the currently processing message
- `GetMessages() ([]SessionEvent, error)` - Get message history
- `Abort(ctx context.Context) error` - Abort the currently processing message
- `GetMessages(ctx context.Context) ([]SessionEvent, error)` - Get message history
- `Destroy() error` - Destroy the session

### Helper Functions
Expand All @@ -136,7 +136,7 @@ func main() {
The SDK supports image attachments via the `Attachments` field in `MessageOptions`. You can attach images by providing their file path:

```go
_, err = session.Send(copilot.MessageOptions{
_, err = session.Send(context.Background(), copilot.MessageOptions{
Prompt: "What's in this image?",
Attachments: []copilot.Attachment{
{
Expand All @@ -150,7 +150,7 @@ _, err = session.Send(copilot.MessageOptions{
Supported image formats include JPG, PNG, GIF, and other common image types. The agent's `view` tool can also read images directly from the filesystem, so you can also ask questions like:

```go
_, err = session.Send(copilot.MessageOptions{
_, err = session.Send(context.Background(), copilot.MessageOptions{
Prompt: "What does the most recent jpg in this directory portray?",
})
```
Expand Down Expand Up @@ -178,7 +178,7 @@ lookupIssue := copilot.DefineTool("lookup_issue", "Fetch issue details from our
return issue.Summary, nil
})

session, _ := client.CreateSession(&copilot.SessionConfig{
session, _ := client.CreateSession(context.Background(), &copilot.SessionConfig{
Model: "gpt-5",
Tools: []copilot.Tool{lookupIssue},
})
Expand Down Expand Up @@ -216,7 +216,7 @@ lookupIssue := copilot.Tool{
},
}

session, _ := client.CreateSession(&copilot.SessionConfig{
session, _ := client.CreateSession(context.Background(), &copilot.SessionConfig{
Model: "gpt-5",
Tools: []copilot.Tool{lookupIssue},
})
Expand All @@ -241,12 +241,12 @@ import (
func main() {
client := copilot.NewClient(nil)

if err := client.Start(); err != nil {
if err := client.Start(context.Background()); err != nil {
log.Fatal(err)
}
defer client.Stop()

session, err := client.CreateSession(&copilot.SessionConfig{
session, err := client.CreateSession(context.Background(), &copilot.SessionConfig{
Model: "gpt-5",
Streaming: true,
})
Expand Down Expand Up @@ -286,7 +286,7 @@ func main() {
}
})

_, err = session.Send(copilot.MessageOptions{
_, err = session.Send(context.Background(), copilot.MessageOptions{
Prompt: "Tell me a short story",
})
if err != nil {
Expand All @@ -312,7 +312,7 @@ By default, sessions use **infinite sessions** which automatically manage contex

```go
// Default: infinite sessions enabled with default thresholds
session, _ := client.CreateSession(&copilot.SessionConfig{
session, _ := client.CreateSession(context.Background(), &copilot.SessionConfig{
Model: "gpt-5",
})

Expand All @@ -321,7 +321,7 @@ fmt.Println(session.WorkspacePath())
// => ~/.copilot/session-state/{sessionId}/

// Custom thresholds
session, _ := client.CreateSession(&copilot.SessionConfig{
session, _ := client.CreateSession(context.Background(), &copilot.SessionConfig{
Model: "gpt-5",
InfiniteSessions: &copilot.InfiniteSessionConfig{
Enabled: copilot.Bool(true),
Expand All @@ -331,7 +331,7 @@ session, _ := client.CreateSession(&copilot.SessionConfig{
})

// Disable infinite sessions
session, _ := client.CreateSession(&copilot.SessionConfig{
session, _ := client.CreateSession(context.Background(), &copilot.SessionConfig{
Model: "gpt-5",
InfiniteSessions: &copilot.InfiniteSessionConfig{
Enabled: copilot.Bool(false),
Expand Down Expand Up @@ -360,7 +360,7 @@ The SDK supports custom OpenAI-compatible API providers (BYOK - Bring Your Own K
**Example with Ollama:**

```go
session, err := client.CreateSession(&copilot.SessionConfig{
session, err := client.CreateSession(context.Background(), &copilot.SessionConfig{
Model: "deepseek-coder-v2:16b", // Required when using custom provider
Provider: &copilot.ProviderConfig{
Type: "openai",
Expand All @@ -373,7 +373,7 @@ session, err := client.CreateSession(&copilot.SessionConfig{
**Example with custom OpenAI-compatible API:**

```go
session, err := client.CreateSession(&copilot.SessionConfig{
session, err := client.CreateSession(context.Background(), &copilot.SessionConfig{
Model: "gpt-4",
Provider: &copilot.ProviderConfig{
Type: "openai",
Expand All @@ -386,7 +386,7 @@ session, err := client.CreateSession(&copilot.SessionConfig{
**Example with Azure OpenAI:**

```go
session, err := client.CreateSession(&copilot.SessionConfig{
session, err := client.CreateSession(context.Background(), &copilot.SessionConfig{
Model: "gpt-4",
Provider: &copilot.ProviderConfig{
Type: "azure", // Must be "azure" for Azure endpoints, NOT "openai"
Expand All @@ -408,7 +408,7 @@ session, err := client.CreateSession(&copilot.SessionConfig{
Enable the agent to ask questions to the user using the `ask_user` tool by providing an `OnUserInputRequest` handler:

```go
session, err := client.CreateSession(&copilot.SessionConfig{
session, err := client.CreateSession(context.Background(), &copilot.SessionConfig{
Model: "gpt-5",
OnUserInputRequest: func(request copilot.UserInputRequest, invocation copilot.UserInputInvocation) (copilot.UserInputResponse, error) {
// request.Question - The question to ask
Expand All @@ -434,7 +434,7 @@ session, err := client.CreateSession(&copilot.SessionConfig{
Hook into session lifecycle events by providing handlers in the `Hooks` configuration:

```go
session, err := client.CreateSession(&copilot.SessionConfig{
session, err := client.CreateSession(context.Background(), &copilot.SessionConfig{
Model: "gpt-5",
Hooks: &copilot.SessionHooks{
// Called before each tool execution
Expand Down
Loading
Loading