-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Fix Go cookbook recipes to use correct SDK API #698
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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.) 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
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.