Fix Go cookbook recipes to use correct SDK API#698
Merged
aaronpowell merged 1 commit intogithub:mainfrom Feb 11, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
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.) andNewClient(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.Typestring switching and pointer-safeevent.Dataaccess.
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(...)andfmt.*but the shown import block only includescontext,time, andcopilot, so it won’t compile as written. Add the missingerrorsandfmtimports (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.Sendis described elsewhere in the docs as non-blocking; since this example exits immediately after callingSend, the requests may be aborted during deferred cleanup and users won’t observe any results. UseSendAndWait(and handle its error/return) for these messages, or add an event handler plus a wait forsession.idlebefore 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.
0eadc52 to
5eb7adb
Compare
aaronpowell
approved these changes
Feb 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
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.