Skip to content

Upgrade copilot CLI library and compatability#28

Open
muhammadbassiony wants to merge 1 commit into
mainfrom
upgrade-copilot-cli
Open

Upgrade copilot CLI library and compatability#28
muhammadbassiony wants to merge 1 commit into
mainfrom
upgrade-copilot-cli

Conversation

@muhammadbassiony
Copy link
Copy Markdown
Collaborator

@muhammadbassiony muhammadbassiony commented Apr 23, 2026

Done

  • upgrade the Copilot SDK to ensure compatibility with the latest CLI version

Copy link
Copy Markdown

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

Upgrades the GitHub Copilot SDK dependency and adapts the internal Copilot CLI client wrapper to the updated SDK APIs so the project remains compatible with the latest Copilot CLI.

Changes:

  • Bump github.com/github/copilot-sdk/go to v0.2.1-preview.1.
  • Update Copilot client calls to the new context-aware SDK method signatures (e.g., Start, Ping, CreateSession, Send, Disconnect).
  • Simplify shutdown handling to the new Stop() error contract.

Reviewed changes

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

File Description
internal/copilotcli/client.go Updates SDK integration code to new context-based APIs and session lifecycle methods.
go.mod Bumps Copilot SDK dependency version.
go.sum Updates checksums for the new Copilot SDK version.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +85 to +90
if err := c.client.Start(context.Background()); err != nil {
return fmt.Errorf("failed to start Copilot client: %w", err)
}

// Verify connectivity with ping
_, err := c.client.Ping("health-check")
_, err := c.client.Ping(context.Background(), "health-check")
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

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

Start() and Ping() are called with context.Background(), so if the CLI blocks/hangs during startup or health-check this can hang indefinitely and cannot be cancelled by the caller. Consider threading a caller-provided context into Start(ctx) (preferred) or at least using a context.WithTimeout for both calls (and returning a timeout error) to avoid stuck orchestrations.

Copilot uses AI. Check for mistakes.
Comment on lines 91 to 93
if err != nil {
c.client.Stop()
_ = c.client.Stop()
return fmt.Errorf("Copilot client ping failed: %w", err)
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

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

On ping failure, the shutdown error from c.client.Stop() is discarded. Since Stop() now returns a single error, it would be better to capture and log (or wrap) it so we don’t silently leak a running CLI process when ping fails.

Copilot uses AI. Check for mistakes.
Comment on lines +119 to 123
session, err := c.client.CreateSession(ctx, &copilot.SessionConfig{
Model: model,
Streaming: true,
OnPermissionRequest: copilot.PermissionHandler.ApproveAll,
})
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

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

OnPermissionRequest: copilot.PermissionHandler.ApproveAll will automatically approve any permission prompts from the CLI. If permission requests can include filesystem/network/tool execution, this becomes a broad escalation surface. Consider making this configurable (e.g., default deny/interactive prompt, with an explicit --auto-approve flag for CI), and/or scoping approvals to the minimum set of permissions required for chunk execution.

Copilot uses AI. Check for mistakes.
Comment on lines +264 to 268
session, err := c.client.CreateSession(ctx, &copilot.SessionConfig{
Model: model,
Streaming: true,
OnPermissionRequest: copilot.PermissionHandler.ApproveAll,
})
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

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

OnPermissionRequest: copilot.PermissionHandler.ApproveAll auto-approves all permission prompts for the summary session as well. Even if chunk execution is trusted, summary generation likely doesn’t require extra permissions; consider using a more restrictive handler here or reusing a configurable policy to avoid unnecessary blanket approvals.

Copilot uses AI. Check for mistakes.
@jmuzina
Copy link
Copy Markdown
Member

jmuzina commented May 1, 2026

When I first tried this, I ran into this issue on starting a job:

{"time":"2026-05-01T11:34:28.599854758-04:00","level":"ERROR","msg":"job execution failed","error":"copilot execution failed: failed to execute chunk 1: failed to create session for chunk 1: failed to create session: JSON-RPC Error -32603: Request session.create failed with message: Model \"gpt-5-mini-high\" is not available.","requestID":"3c8d80d4-4573-11f1-93b5-843a5b6fef31"}

When I switched to gpt-5-mini, things proceeded OK.

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.

3 participants