Skip to content

Conversation

@tonybaloney
Copy link
Contributor

Problem

All 5 Go cookbook recipes and their corresponding markdown documentation use incorrect SDK API patterns that don't compile against the real github.com/github/copilot-sdk/go v0.1.23.

Issues found

  • copilot.NewClient() takes *ClientOptions, should be copilot.NewClient(nil)
  • All methods require context.Context as first param (Start, CreateSession, Send, etc.)
  • SessionConfig must be passed as pointer: &copilot.SessionConfig{}
  • Event handling uses non-existent copilot.Event interface with type assertions; real API uses copilot.SessionEvent with .Type string and .Data fields
  • event.Data.Content is *string (pointer), must nil-check and dereference
  • session.WaitForIdle() doesn't exist, use session.SendAndWait(ctx, ...)
  • copilot.SystemMessage is a constant not a type; correct type is copilot.SystemMessageConfig
  • Import needs alias: copilot "github.com/github/copilot-sdk/go"

Files changed (10)

Recipes: error-handling.go, persisting-sessions.go, multiple-sessions.go, managing-local-files.go, pr-visualization.go

Documentation: error-handling.md, persisting-sessions.md, multiple-sessions.md, managing-local-files.md, pr-visualization.md

Verification

All 5 recipes compile successfully against copilot-sdk/go v0.1.23.

Copilot AI review requested due to automatic review settings February 11, 2026 14:07
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the Go Copilot SDK cookbook recipes and their accompanying markdown docs to use the correct github.com/github/copilot-sdk/go API patterns (as of v0.1.23), so the examples compile and reflect the current SDK surface.

Changes:

  • Switch Go recipes/docs to context-first SDK calls (Start(ctx), CreateSession(ctx, ...), SendAndWait(ctx, ...), etc.) and NewClient(nil).
  • Update session configuration and system message usage to match current types (&copilot.SessionConfig{}, &copilot.SystemMessageConfig{}).
  • Replace legacy event/type-assertion handling with copilot.SessionEvent + event.Type string switching and pointer-safe event.Data access.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
cookbook/copilot-sdk/go/recipe/error-handling.go Updates recipe to use context-first APIs and SendAndWait result handling.
cookbook/copilot-sdk/go/recipe/persisting-sessions.go Updates persistence/resume/list/delete flows to current context-first API calls.
cookbook/copilot-sdk/go/recipe/multiple-sessions.go Updates multiple-session creation and sends to context-first calls.
cookbook/copilot-sdk/go/recipe/managing-local-files.go Updates session creation, event handling, and prompt send to current API.
cookbook/copilot-sdk/go/recipe/pr-visualization.go Updates client/session setup, event handling, and request execution to current API.
cookbook/copilot-sdk/go/error-handling.md Updates docs code blocks to context-first API patterns and SendAndWait.
cookbook/copilot-sdk/go/persisting-sessions.md Updates docs snippets for session persistence/resumption/listing/history to context-first API patterns.
cookbook/copilot-sdk/go/multiple-sessions.md Updates docs snippet to context-first sends across multiple sessions.
cookbook/copilot-sdk/go/managing-local-files.md Updates docs snippets to context-first session setup, event handling, and SendAndWait.
cookbook/copilot-sdk/go/pr-visualization.md Updates docs example to context-first session setup, event handling, and SendAndWait.
Comments suppressed due to low confidence (2)

cookbook/copilot-sdk/go/error-handling.md:91

  • This code block uses both errors.Is(...) and fmt.* but the shown import block only includes context, time, and copilot, so it won’t compile as written. Add the missing errors and fmt imports (or make the snippet explicitly partial).
```go
import (
    "context"
    "time"
    copilot "github.com/github/copilot-sdk/go"
)

cookbook/copilot-sdk/go/recipe/multiple-sessions.go:44

  • Session.Send is described elsewhere in the docs as non-blocking; since this example exits immediately after calling Send, the requests may be aborted during deferred cleanup and users won’t observe any results. Use SendAndWait (and handle its error/return) for these messages, or add an event handler plus a wait for session.idle before exiting.
	// Each session maintains its own conversation history
	session1.Send(ctx, copilot.MessageOptions{Prompt: "You are helping with a Python project"})
	session2.Send(ctx, copilot.MessageOptions{Prompt: "You are helping with a TypeScript project"})
	session3.Send(ctx, copilot.MessageOptions{Prompt: "You are helping with a Go project"})

All 5 Go recipes and their markdown docs used incorrect API patterns
that don't match the real github.com/github/copilot-sdk/go v0.1.23:

- copilot.NewClient() -> copilot.NewClient(nil) (*ClientOptions param)
- client.Start() -> client.Start(ctx) (context.Context required)
- copilot.SessionConfig -> &copilot.SessionConfig (pointer required)
- session.On(func(event copilot.Event)) -> session.On(func(event copilot.SessionEvent))
- Type assertions -> event.Type string check + *event.Data.Content deref
- session.WaitForIdle() -> session.SendAndWait(ctx, ...) (WaitForIdle doesn't exist)
- copilot.SystemMessage -> copilot.SystemMessageConfig

All 5 recipes verified to compile against SDK v0.1.23.
@aaronpowell aaronpowell merged commit 7ebb991 into github:main Feb 11, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants