Skip to content

Detach cli lifespan from the context passed to Client.Start#689

Open
qmuntal wants to merge 1 commit intogithub:mainfrom
qmuntal:dev/qmuntal/ctxlife
Open

Detach cli lifespan from the context passed to Client.Start#689
qmuntal wants to merge 1 commit intogithub:mainfrom
qmuntal:dev/qmuntal/ctxlife

Conversation

@qmuntal
Copy link
Contributor

@qmuntal qmuntal commented Mar 5, 2026

Fixes #668

@qmuntal qmuntal requested a review from a team as a code owner March 5, 2026 16:02
Copilot AI review requested due to automatic review settings March 5, 2026 16:02
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

This PR fixes Go SDK issue #668 by ensuring the Copilot CLI subprocess spawned by Client.Start(ctx) is not tied to (and killed by) cancellation of the provided context after startup.

Changes:

  • Spawn the CLI process with exec.Command instead of exec.CommandContext so canceling the Start context doesn’t kill the CLI.
  • Thread the caller context through ensureConnected(ctx) and simplify foreground session methods to reuse that helper.
  • Add a regression test asserting that canceling the Start context does not break subsequent CLI requests (Ping).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
go/client.go Decouples CLI process lifetime from Start context; refactors connection checks and tightens startup/dial timeouts.
go/client_test.go Adds regression test ensuring Start-context cancellation doesn’t kill the CLI process.

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.

(Go SDK) Cancelling a context, passed to client.Start, kills the copilot CLI process

2 participants