Skip to content

feat(copilot-sdk): support BYOK (Bring Your Own Key)#956

Merged
christso merged 7 commits intomainfrom
feat/955-copilot-sdk-byok
Apr 6, 2026
Merged

feat(copilot-sdk): support BYOK (Bring Your Own Key)#956
christso merged 7 commits intomainfrom
feat/955-copilot-sdk-byok

Conversation

@christso
Copy link
Copy Markdown
Collaborator

@christso christso commented Apr 6, 2026

Summary

  • Add optional byok block to copilot-sdk target config, allowing users to route requests through their own Azure OpenAI, OpenAI, or Anthropic endpoints instead of GitHub's Copilot infrastructure
  • Pass the SDK's provider option to createSession() when BYOK fields are present
  • Auto-normalize bare Azure resource names to full URLs (e.g. my-resourcehttps://my-resource.openai.azure.com)
  • Secrets (api_key, bearer_token) require ${{ ENV_VAR }} syntax — no plaintext literals allowed

Example config

- name: copilot-sdk-azure
  provider: copilot-sdk
  model: ${{ AZURE_DEPLOYMENT_NAME }}
  byok:
    type: azure
    base_url: ${{ AZURE_OPENAI_ENDPOINT }}
    api_key: ${{ AZURE_OPENAI_API_KEY }}
  grader_target: grader

Changes

  • packages/core/src/evaluation/providers/types.ts — add byok field to TargetDefinition
  • packages/core/src/evaluation/providers/targets.ts — add BYOK fields to CopilotSdkResolvedConfig, parse byok block in resolveCopilotSdkConfig()
  • packages/core/src/evaluation/providers/copilot-sdk.ts — build and pass provider block to createSession(), normalize bare Azure resource names
  • packages/core/src/evaluation/validation/targets-validator.ts — add byok to known copilot-sdk settings
  • .agentv/targets.yaml — add copilot-sdk-azure target using AZURE_OPENAI_ENDPOINT
  • Tests for config resolution (9 cases) and provider behavior (8 cases)

Test plan

  • Unit tests pass for config resolution (azure, openai, bearer token, wire_api, missing base_url, literal api_key/bearer_token rejection, no-byok baseline)
  • Unit tests pass for provider session options (azure provider block, bearer token, wireApi, no-provider baseline, default type, non-azure skips azure block, bare resource name normalization, full URL passthrough)
  • Build, typecheck, lint all pass
  • Red/green UAT with a real Azure OpenAI endpoint

Closes #955

🤖 Generated with Claude Code

…target

Add optional `byok` block to copilot-sdk target config, allowing users to
route requests through their own Azure OpenAI, OpenAI, or Anthropic endpoints
instead of GitHub's Copilot infrastructure.

Supported BYOK fields: type, base_url, api_key, bearer_token, api_version,
wire_api. Secrets (api_key, bearer_token) require ${{ ENV_VAR }} syntax.

Closes #955

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Apr 6, 2026

Deploying agentv with  Cloudflare Pages  Cloudflare Pages

Latest commit: 07b3712
Status:⚡️  Build in progress...

View logs

christso and others added 3 commits April 6, 2026 22:10
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Make explicit that manual e2e verification is a prerequisite for the
code review step, not a parallel activity. If e2e fails, fix it before
investing time in review.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Prevents false "Unknown setting" warning when validating targets with
a byok block.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@christso
Copy link
Copy Markdown
Collaborator Author

christso commented Apr 6, 2026

Red/Green UAT Evidence

RED (on main) — BYOK fields silently ignored

=== Test 1: Config resolution ===
kind: copilot-sdk
model: gpt-5.4-mini
byokType: undefined
byokBaseUrl: undefined
byokApiKey: undefined
byokApiVersion: undefined
FAIL: BYOK fields not resolved

Config resolution on main shows the byok block is silently ignored — all BYOK fields resolve to undefined.

GREEN (on feat/955-copilot-sdk-byok) — BYOK fields resolved and routed through Azure

Config resolution:

=== Test 1: Config resolution ===
kind: copilot-sdk
model: gpt-5.4-mini
byokType: azure
byokBaseUrl: ***set***
byokApiKey: ***set***
byokApiVersion: 2024-10-21
PASS: BYOK fields resolved correctly

=== Test 2: Backward compatibility (no byok) ===
PASS: No BYOK fields present (backward compatible)

=== All UAT tests passed ===

Full e2e eval through Copilot SDK → Azure OpenAI:

Using target: copilot-sdk-azure
1/1   ✅ hello-byok | copilot-sdk-azure | 1.000 PASS

RESULT: PASS  (1/1 scored >= 0.8, mean: 1.000)

The eval ran successfully with the Copilot SDK routing through Azure OpenAI via BYOK, scoring 1.000.

christso and others added 3 commits April 6, 2026 22:29
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ase_url

When byok.type is "azure" and base_url is a bare resource name (no
https:// prefix), automatically construct the full URL as
https://{name}.openai.azure.com. This lets users reuse AZURE_OPENAI_ENDPOINT
directly without a separate env var.

Also reverts the AZURE_OPENAI_BYOK_URL env var — no longer needed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@christso christso marked this pull request as ready for review April 6, 2026 22:51
@christso christso merged commit 3b20465 into main Apr 6, 2026
3 of 4 checks passed
@christso christso deleted the feat/955-copilot-sdk-byok branch April 6, 2026 22:52
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.

Support BYOK (Bring Your Own Key) for copilot-sdk target

1 participant