Skip to content

Commit 6e6463f

Browse files
Copilotpelikhan
andauthored
Fix claude engine github provider: inject COPILOT_GITHUB_TOKEN for api-proxy configuration
When model-provider: github is used with the claude engine, the compiled workflow sets ANTHROPIC_API_KEY=${{ secrets.COPILOT_GITHUB_TOKEN }} and routes ANTHROPIC_BASE_URL to port 10002 (copilot provider). However, the api-proxy container needs COPILOT_GITHUB_TOKEN set directly in the host environment to configure the copilot backend at that port. Without COPILOT_GITHUB_TOKEN in the step env, the api-proxy copilot provider shows ❌ (unconfigured) and every inference request returns 401 Unauthorized. The fix injects COPILOT_GITHUB_TOKEN alongside ANTHROPIC_API_KEY when firewall is enabled and model-provider is github. The --exclude-env COPILOT_GITHUB_TOKEN flag already prevents the raw token from reaching the agent container. Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
1 parent be4177f commit 6e6463f

3 files changed

Lines changed: 13 additions & 0 deletions

File tree

.github/workflows/smoke-claude-on-copilot.lock.yml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/workflow/claude_engine.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,15 @@ func (e *ClaudeEngine) GetExecutionSteps(workflowData *WorkflowData, logFile str
382382
if isFirewallEnabled(workflowData) && provider != LLMProviderAnthropic {
383383
env["ANTHROPIC_BASE_URL"] = llmProviderGatewayBaseURL(provider)
384384
}
385+
// When using the GitHub/Copilot provider (model-provider: github), the api-proxy container
386+
// needs COPILOT_GITHUB_TOKEN in the host environment to configure the copilot provider at
387+
// port CopilotLLMGatewayPort. ANTHROPIC_API_KEY alone (set above) is forwarded into the
388+
// agent container but is insufficient to configure the api-proxy's copilot backend.
389+
// COPILOT_GITHUB_TOKEN is already excluded from the agent container via ExcludeEnvVarNames,
390+
// so injecting it here only makes it available to the api-proxy, not to the agent process.
391+
if isFirewallEnabled(workflowData) && provider == LLMProviderGitHub {
392+
env["COPILOT_GITHUB_TOKEN"] = llmProviderSecretExpression(provider, workflowData)
393+
}
385394
injectWorkflowCallNetworkAllowedEnv(env, workflowData)
386395
// Indicate the phase: "agent" for the main run, "detection" for threat detection
387396
// Include the compiler version so agents can identify which gh-aw version generated the workflow

pkg/workflow/claude_engine_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,9 @@ func TestClaudeEngineLLMProviderGitHubUsesCopilotCredentials(t *testing.T) {
193193
assert.Contains(t, stepContent, "GH_AW_LLM_PROVIDER: github")
194194
assert.Contains(t, stepContent, "ANTHROPIC_API_KEY: ${{ secrets.COPILOT_GITHUB_TOKEN }}")
195195
assert.Contains(t, stepContent, fmt.Sprintf("ANTHROPIC_BASE_URL: http://host.docker.internal:%d", constants.CopilotLLMGatewayPort))
196+
// COPILOT_GITHUB_TOKEN must also be set directly so the api-proxy can configure the
197+
// copilot provider. It is excluded from the agent container via ExcludeEnvVarNames.
198+
assert.Contains(t, stepContent, "COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_GITHUB_TOKEN }}")
196199
}
197200

198201
func TestClaudeEngineAllowsMountedMCPCLICommandsInRestrictedBash(t *testing.T) {

0 commit comments

Comments
 (0)