Remove premature defer client.Stop() in GitHub Copilot provider

This commit is contained in:
Yasuhiro Matsumoto 2026-02-16 00:13:20 +09:00
parent 214b201bfa
commit 3101c33cc7
No known key found for this signature in database
GPG key ID: F2EA90DF2C146D1E

View file

@ -33,11 +33,15 @@ func NewGitHubCopilotProvider(uri string, connectMode string, model string) (*Gi
if err := client.Start(context.Background()); err != nil {
return nil, fmt.Errorf("Can't connect to Github Copilot, https://github.com/github/copilot-sdk/blob/main/docs/getting-started.md#connecting-to-an-external-cli-server for details")
}
defer client.Stop()
session, _ = client.CreateSession(context.Background(), &copilot.SessionConfig{
var err error
session, err = client.CreateSession(context.Background(), &copilot.SessionConfig{
Model: model,
Hooks: &copilot.SessionHooks{},
})
if err != nil {
client.Stop()
return nil, fmt.Errorf("failed to create Copilot session: %w", err)
}
}