Skip to content

Conversation

@ssncferreira
Copy link
Contributor

@ssncferreira ssncferreira commented Jan 21, 2026

Description

Adds support for GitHub Copilot as an AI provider. Unlike other providers that use a global API key, Copilot uses per-user keys passed in the Authorization header. Copilot's API is OpenAI-compatible, so the provider reuses the existing OpenAI interceptors.

Changes

  • Add Copilot provider in with support for:
    • /chat/completions endpoint
    • /responses endpoint
    • Passthrough routes: /models, /agents/, /mcp/
  • InjectAuthHeader is a no-op since Copilot uses per-user keys from the original request
  • Add Copilot specific tests

Related to: coder/internal#1235

Copy link
Contributor Author

ssncferreira commented Jan 21, 2026

@ssncferreira ssncferreira force-pushed the ssncferreira/feat-copilot-provider branch 2 times, most recently from ca6355f to 0b199a7 Compare January 22, 2026 10:47
@ssncferreira ssncferreira force-pushed the ssncferreira/fix-actor-nil branch from b99f59b to 7bd40c9 Compare January 22, 2026 10:47
@ssncferreira ssncferreira force-pushed the ssncferreira/feat-copilot-provider branch 2 times, most recently from b0be741 to 68e00ca Compare January 23, 2026 15:51
@ssncferreira ssncferreira force-pushed the ssncferreira/fix-actor-nil branch from 9182ea4 to 6a9968e Compare January 23, 2026 15:51
@ssncferreira ssncferreira changed the base branch from ssncferreira/fix-actor-nil to graphite-base/137 January 23, 2026 15:54
ssncferreira added a commit that referenced this pull request Jan 23, 2026
## Description

Fixes a nil pointer dereference when extracting Actor ID for trace attributes.

Discovered while testing the Copilot provider implementation (implemented upstack #137), where requests may not always have an actor set in the context.

## Changes 

Adds `ActorIDFromContext` helper that safely returns an empty string if no actor is present, and updates the interceptors to use it.
@ssncferreira ssncferreira force-pushed the ssncferreira/feat-copilot-provider branch from 68e00ca to ea722ff Compare January 23, 2026 16:00
@graphite-app graphite-app bot changed the base branch from graphite-base/137 to main January 23, 2026 16:00
@ssncferreira ssncferreira force-pushed the ssncferreira/feat-copilot-provider branch from ea722ff to ca7e288 Compare January 23, 2026 16:00
@ssncferreira ssncferreira changed the base branch from main to graphite-base/137 January 23, 2026 18:14
@ssncferreira ssncferreira force-pushed the ssncferreira/feat-copilot-provider branch from ca7e288 to 77dea81 Compare January 23, 2026 18:14
@ssncferreira ssncferreira changed the base branch from graphite-base/137 to ssncferreira/fix-chatcompletions-streaming-toolcall January 23, 2026 18:14
@ssncferreira ssncferreira force-pushed the ssncferreira/feat-copilot-provider branch 2 times, most recently from 3744945 to c1d483a Compare January 23, 2026 18:51
@ssncferreira ssncferreira force-pushed the ssncferreira/fix-chatcompletions-streaming-toolcall branch from b4479ce to 6de1225 Compare January 23, 2026 18:52
@ssncferreira ssncferreira force-pushed the ssncferreira/feat-copilot-provider branch 3 times, most recently from f3cc0dd to bb51264 Compare January 23, 2026 19:24
@ssncferreira ssncferreira force-pushed the ssncferreira/fix-chatcompletions-streaming-toolcall branch from 6de1225 to 82de4d9 Compare January 23, 2026 20:43
@ssncferreira ssncferreira force-pushed the ssncferreira/feat-copilot-provider branch 2 times, most recently from 01ca570 to 905e2b5 Compare January 23, 2026 20:45
@ssncferreira ssncferreira force-pushed the ssncferreira/fix-chatcompletions-streaming-toolcall branch from 82de4d9 to d02fd35 Compare January 23, 2026 20:45
@ssncferreira ssncferreira force-pushed the ssncferreira/feat-copilot-provider branch from 905e2b5 to 274b1ba Compare January 23, 2026 20:53
@ssncferreira ssncferreira force-pushed the ssncferreira/fix-chatcompletions-streaming-toolcall branch from d02fd35 to 9e54caf Compare January 23, 2026 20:53
@ssncferreira ssncferreira marked this pull request as ready for review January 26, 2026 08:38
@ssncferreira ssncferreira force-pushed the ssncferreira/feat-copilot-provider branch from 274b1ba to 1646733 Compare January 26, 2026 10:57
@ssncferreira ssncferreira force-pushed the ssncferreira/fix-chatcompletions-streaming-toolcall branch from 9e54caf to e9bac3b Compare January 26, 2026 10:57
@ssncferreira ssncferreira force-pushed the ssncferreira/feat-copilot-provider branch from 1646733 to a2eb2d3 Compare January 26, 2026 12:09
@ssncferreira ssncferreira force-pushed the ssncferreira/feat-copilot-provider branch from a2eb2d3 to cad2669 Compare January 26, 2026 12:15
@ssncferreira ssncferreira force-pushed the ssncferreira/fix-chatcompletions-streaming-toolcall branch from efa7ba4 to 734ddda Compare January 26, 2026 12:15
@ssncferreira ssncferreira force-pushed the ssncferreira/feat-copilot-provider branch from cad2669 to 79e2524 Compare January 26, 2026 18:56
@ssncferreira ssncferreira force-pushed the ssncferreira/feat-copilot-provider branch from ce1e93a to 8fec1c2 Compare January 27, 2026 10:15
@ssncferreira ssncferreira force-pushed the ssncferreira/feat-copilot-provider branch from bf4405e to ecd5e50 Compare January 27, 2026 10:21
Copy link
Contributor Author

ssncferreira commented Jan 27, 2026

Merge activity

  • Jan 27, 10:29 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jan 27, 10:32 AM UTC: Graphite couldn't merge this PR because it had merge conflicts.
  • Jan 27, 10:44 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jan 27, 10:44 AM UTC: @ssncferreira merged this pull request with Graphite.

@ssncferreira ssncferreira changed the base branch from ssncferreira/fix-chatcompletions-streaming-toolcall to graphite-base/137 January 27, 2026 10:29
@ssncferreira ssncferreira changed the base branch from graphite-base/137 to main January 27, 2026 10:30
Copy link
Contributor

@pawbana pawbana left a comment

Choose a reason for hiding this comment

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

LGTM
some tests nits that can be ignored


body := `{"model": "gpt-4", "messages": [{"role": "user", "content": "hello"}], "stream": false}`
req := httptest.NewRequest(http.MethodPost, routeCopilotChatCompletions, bytes.NewBufferString(body))
req.Header.Set("Authorization", "Bearer test-token")
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: storing headers in map would be more clear when checking equal later.

@ssncferreira ssncferreira merged commit 602942b into main Jan 27, 2026
2 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.

4 participants