Skip to content

Improve Copilot timeout handling#17

Merged
sozercan merged 1 commit intomainfrom
fix/copilot-timeout-handling
Apr 23, 2026
Merged

Improve Copilot timeout handling#17
sozercan merged 1 commit intomainfrom
fix/copilot-timeout-handling

Conversation

@sozercan
Copy link
Copy Markdown
Owner

Summary

  • increase the default Copilot MCP response-header timeout to 5 minutes, while keeping global and Copilot-specific env overrides
  • treat Copilot service-returned Error executing tool: payloads as real errors instead of successful chat responses
  • retry transient timeout-shaped Copilot tool failures once and deduplicate repeated correlation metadata before surfacing the error
  • add focused config, MCP client, and Copilot command tests plus docs for timeout tuning

Testing

  • go test ./internal/commands/copilot -count=1
  • go test ./... -count=1
  • go vet ./...

Copilot AI review requested due to automatic review settings April 23, 2026 17:22
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

This PR improves Copilot-related reliability and configurability by introducing service-specific MCP response-header timeouts (with a longer default for Copilot) and by treating Copilot tool “Error executing tool:” payloads as actual errors (with a single retry for timeout-shaped failures).

Changes:

  • Add configurable MCP HTTP response-header timeouts, including a longer default for Copilot and env var overrides.
  • Detect Copilot service-returned Error executing tool: payloads, deduplicate repeated correlation metadata, and retry timeout-shaped failures once.
  • Add targeted unit tests and documentation for timeout tuning.
Show a summary per file
File Description
README.md Documents new timeout-related environment variables.
internal/mcp/client.go Uses configurable response-header timeout and logs it in verbose mode; derives service from endpoint.
internal/mcp/client_test.go Adds coverage for endpoint->service detection and response-header timeout behavior.
internal/config/config.go Introduces default timeouts and env-based override logic.
internal/config/config_test.go Adds tests for timeout defaults and override precedence/validation.
internal/commands/copilot/copilot.go Adds Copilot service-error detection, sanitization/deduplication, and a single retry for timeout-like failures.
internal/commands/copilot/copilot_test.go Adds tests for retry/error surfacing behavior; adds a Copilot SSE tool server helper.
docs/copilot.md Adds guidance for tuning Copilot timeouts via env vars.

Copilot's findings

Tip

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

  • Files reviewed: 8/8 changed files
  • Comments generated: 2

})+"\n\n")
case "tools/call":
idx := *toolCalls
*toolCalls++
Comment on lines +748 to +752
generic := NewClient(server.URL+"/"+config.Servers["teams"]+"/", tokenProvider)
_, err := generic.doRequest(context.Background(), JSONRPCRequest{JSONRPC: "2.0", ID: 1, Method: "tools/list"})
if err == nil {
t.Fatal("expected generic MCP request to hit response-header timeout")
}
@sozercan sozercan merged commit 2b9c8b7 into main Apr 23, 2026
9 checks passed
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.

2 participants