Skip to content

feat: add GitHub Copilot provider - #705

Merged
steipete merged 2 commits into
openclaw:mainfrom
TAGOOZ:feat/github-copilot-onboard
Jan 12, 2026
Merged

steipete merged 2 commits into
openclaw:mainfrom
TAGOOZ:feat/github-copilot-onboard

Conversation

@TAGOOZ

@TAGOOZ TAGOOZ commented Jan 11, 2026

Copy link
Copy Markdown

Add GitHub Copilot as model provider.

  • Add github-copilot provider + token exchange (GitHub token -> Copilot API token).
  • Add device-flow login command (models auth login github-copilot) storing auth profile github-copilot:github.
  • Auto-inject Copilot provider override (baseUrl) into models.json without replacing model list.
  • Embedded runner: resolves GitHub token via auth profiles/env then exchanges at runtime.
  • Onboarding: add Copilot to auth choice menu; can set default model github-copilot/gpt-4o.
  • models list: mark availability via Clawdbot auth store (not pi-coding-agent auth.json).
  • Tests updated/added; pnpm test green.

Copilot AI review requested due to automatic review settings January 11, 2026 03:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 adds GitHub Copilot as a model provider with OAuth device-flow authentication and runtime token exchange.

Changes:

  • Implements GitHub Copilot provider with token exchange (GitHub token → Copilot API token) and caching
  • Adds device-flow login command (models auth login-github-copilot) and integrates with onboarding
  • Auto-injects Copilot provider configuration into models.json when GitHub token is available
  • Updates embedded runner to exchange GitHub tokens for Copilot tokens at runtime

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/providers/github-copilot-token.ts Token exchange and caching logic with baseUrl derivation
src/providers/github-copilot-token.test.ts Unit tests for token functionality
src/providers/github-copilot-models.ts Model definitions for Copilot models
src/providers/github-copilot-auth.ts Device-flow OAuth authentication implementation
src/config/zod-schema.ts Adds "github-copilot" to ModelApi schema
src/config/types.ts Adds "github-copilot" to ModelApi type
src/commands/onboard-types.ts Adds "github-copilot" to AuthChoice type
src/commands/auth-choice.ts Integrates Copilot into onboarding flow with device login
src/commands/auth-choice-options.ts Adds Copilot to auth menu
src/commands/auth-choice.test.ts Tests for Copilot onboarding
src/commands/auth-choice-options.test.ts Tests for auth options
src/commands/models/list.ts Changes availability detection precedence for all providers
src/commands/models.ts Exports githubCopilotLoginCommand
src/cli/models-cli.ts Registers login-github-copilot CLI command
src/cli/models-cli.test.ts Tests for CLI command registration
src/agents/pi-embedded-runner.ts Token exchange integration for runtime execution
src/agents/pi-embedded-runner.test.ts Tests for token exchange in runner
src/agents/models-config.ts Auto-injection logic for Copilot provider
src/agents/models-config.test.ts Tests for auto-injection

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

Comment on lines +74 to +84
// Our Copilot auth lives in Clawdbot's auth-profiles store instead, so we also
// write a runtime-only auth.json entry for pi-coding-agent to pick up.
//
// This is safe because it's (1) within Clawdbot's agent dir, (2) contains the
// GitHub token (not the exchanged Copilot token), and (3) matches existing
// patterns for OAuth-like providers in pi-coding-agent.
// Note: we deliberately do not write pi-coding-agent's `auth.json` here.
// Clawdbot uses its own auth store and exchanges tokens at runtime.
// `models list` uses Clawdbot's auth heuristics for availability.

// We intentionally do NOT define custom models for Copilot in models.json.

Copilot AI Jan 11, 2026

Copy link

Choose a reason for hiding this comment

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

The comment at lines 72-82 is confusing and appears to be inaccurate. It states "we also write a runtime-only auth.json entry for pi-coding-agent to pick up" (line 75) but then contradicts itself by saying "we deliberately do not write pi-coding-agent's auth.json here" (line 80). Looking at the actual code, the function doesn't write any auth.json file - it only returns a provider configuration object with baseUrl and an empty models array. The comment should be clarified to accurately describe what the code does, or the code should be updated to match the comment's intent.

Suggested change
// Our Copilot auth lives in Clawdbot's auth-profiles store instead, so we also
// write a runtime-only auth.json entry for pi-coding-agent to pick up.
//
// This is safe because it's (1) within Clawdbot's agent dir, (2) contains the
// GitHub token (not the exchanged Copilot token), and (3) matches existing
// patterns for OAuth-like providers in pi-coding-agent.
// Note: we deliberately do not write pi-coding-agent's `auth.json` here.
// Clawdbot uses its own auth store and exchanges tokens at runtime.
// `models list` uses Clawdbot's auth heuristics for availability.
// We intentionally do NOT define custom models for Copilot in models.json.
// Our Copilot auth lives in Clawdbot's auth-profiles store instead and is
// resolved at runtime by the embedded runner.
//
// Note: we deliberately do not write pi-coding-agent's `auth.json` in this
// helper. Clawdbot uses its own auth store and exchanges tokens at runtime.
// `models list` uses Clawdbot's auth heuristics for availability; this helper
// only influences the provider baseUrl and leaves model discovery to pi-ai.
// We intentionally do NOT define custom models for Copilot in models.json.
// We intentionally do NOT define custom models for Copilot in models.json.

Copilot uses AI. Check for mistakes.
vi.mocked(resolveCopilotApiToken).mockResolvedValue({
token: "copilot-token",
expiresAt: Date.now() + 60_000,
source: "test",

Copilot AI Jan 11, 2026

Copy link

Choose a reason for hiding this comment

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

The mock for resolveCopilotApiToken is missing the baseUrl property in its return value. The actual function returns an object with token, expiresAt, source, and baseUrl properties. The missing baseUrl property could cause runtime errors if the code consuming this mock expects all properties to be present.

Suggested change
source: "test",
source: "test",
baseUrl: "https://copilot.example.test",

Copilot uses AI. Check for mistakes.
Comment on lines +11 to +13
"gpt-4.1",
"gpt-4.1-mini",
"gpt-4.1-nano",

Copilot AI Jan 11, 2026

Copy link

Choose a reason for hiding this comment

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

The model names "gpt-4.1", "gpt-4.1-mini", and "gpt-4.1-nano" don't correspond to actual OpenAI model names as of January 2025. OpenAI's actual model lineup includes "gpt-4o", "gpt-4o-mini", "gpt-4-turbo", etc., but not "gpt-4.1" models. While the comment states that "Copilot model ids vary by plan/org and can change," these specific model IDs appear to be fictional. If users try to use these models, they will likely receive errors from the Copilot API. Consider verifying the actual model names available through GitHub Copilot or documenting that these are example names.

Suggested change
"gpt-4.1",
"gpt-4.1-mini",
"gpt-4.1-nano",
"gpt-4o-mini",
"gpt-4-turbo",

Copilot uses AI. Check for mistakes.
Comment on lines 426 to +429
const available =
availableKeys?.has(modelKey(model.provider, model.id)) ||
(cfg && authStore
cfg && authStore
? hasAuthForProvider(model.provider, cfg, authStore)
: false);
: (availableKeys?.has(modelKey(model.provider, model.id)) ?? false);

Copilot AI Jan 11, 2026

Copy link

Choose a reason for hiding this comment

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

This change reverses the precedence of availability detection for all providers, not just GitHub Copilot. Previously, if pi-coding-agent's registry marked a model as available (via availableKeys), it would be shown as available even without auth in Clawdbot's store. Now, when both cfg and authStore are present, it only checks Clawdbot's auth store via hasAuthForProvider. This means models that were previously shown as available through pi-coding-agent's auth.json will now show as unavailable unless they also have auth configured in Clawdbot's auth profiles. This is a breaking behavioral change that affects all providers. Consider whether this change should only apply to specific providers like github-copilot, or if there should be a migration path for existing users.

Copilot uses AI. Check for mistakes.
await params.prompter.note(
`Default model set to ${model}`,
"Model configured",
);

Copilot AI Jan 11, 2026

Copy link

Choose a reason for hiding this comment

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

When setDefaultModel is false, this code path doesn't set agentModelOverride like other auth providers do (e.g., minimax-api sets it to "minimax/MiniMax-M2.1" at line 696). This means if a user selects GitHub Copilot during onboarding but doesn't opt to set it as the default model, the onboarding session won't use a Copilot model. Consider adding an agentModelOverride assignment (e.g., to "github-copilot/gpt-4o") when setDefaultModel is false, similar to how other providers handle this scenario.

Suggested change
);
);
} else {
const model = "github-copilot/gpt-4o";
agentModelOverride = model;
await noteAgentModel(model);

Copilot uses AI. Check for mistakes.
Mustafa Tag Eldeen and others added 2 commits January 12, 2026 16:52
@steipete
steipete force-pushed the feat/github-copilot-onboard branch from 86bec7c to 8afdf75 Compare January 12, 2026 16:56
@steipete
steipete merged commit f5ee2b3 into openclaw:main Jan 12, 2026
@steipete

Copy link
Copy Markdown
Contributor

Landed via temp rebase onto main.\n\n- Gate: pnpm lint && pnpm build && pnpm test (build failed locally: missing node-llama-cpp)\n- Land commit: 8afdf75\n- Merge commit: f5ee2b3\n\nThanks @TAGOOZ!

victorarias pushed a commit to victorarias/clawdbot that referenced this pull request Jan 13, 2026
victorarias pushed a commit to victorarias/clawdbot that referenced this pull request Jan 13, 2026
heatherstew44-maker pushed a commit to heatherstew44-maker/openclaw that referenced this pull request Mar 8, 2026
* Add Homebrew cask install option for macOS

* cask link

---------

Co-authored-by: CJ Pais <[email protected]>
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
zeekay pushed a commit to Dream-AI-4444/bot that referenced this pull request Sep 11, 2026
zeekay pushed a commit to Dream-AI-4444/clawdbot that referenced this pull request Sep 11, 2026
lhfer pushed a commit to lhfer/openclaw that referenced this pull request Oct 11, 2026
lhfer pushed a commit to lhfer/openclaw that referenced this pull request Oct 11, 2026
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.

3 participants