Skip to content

fix(github-copilot): exchange API token for image tool requests and update IDE headers - #80393

Closed
afunnyhy wants to merge 3 commits into
openclaw:mainfrom
afunnyhy:fix/copilot-image-token-bypass
Closed

afunnyhy wants to merge 3 commits into
openclaw:mainfrom
afunnyhy:fix/copilot-image-token-bypass

Conversation

@afunnyhy

@afunnyhy afunnyhy commented May 10, 2026 •

Copy link
Copy Markdown
  • Bump COPILOT_USER_AGENT from 0.26.7 to 0.35.0 and COPILOT_EDITOR_VERSION from vscode/1.96.2 to vscode/1.107.0 to match the VS Code Chat extension versions that GitHub maps to the vscode-chat integrator scope.

  • Add /v2/token exchange in resolveImageRuntime for github-copilot models so the image tool obtains a short-lived Copilot API token instead of sending the raw GitHub OAuth access token directly. The raw OAuth token inherits the copilot-language-server integrator scope, which lacks image-capable models like gemini-3.1-pro-preview.

  • Propagate the derived baseUrl from the minted Copilot token to the image model. This aligns the image tool path with the normal chat path and ensures enterprise or proxy-routed Copilot deployments connect to the correct host.

Refs: #79946, Follow-up to #80074

Summary

  • Problem: The image tool bypasses prepareRuntimeAuth and sends the raw GitHub OAuth access token directly to the Copilot API. This token defaults to the copilot-language-server scope, causing 400 The requested model is not available for integrator errors when requesting multi-modal models like gemini-3.1-pro-preview.
  • Why it matters: PR Fix Copilot token integration identity #80074 fixed the token scope for standard chat requests, but image-capable models still fail because the image tool utilizes a separate authentication lifecycle bypass.
  • What changed: Injected a /v2/token exchange step in resolveImageRuntime for github-copilot providers, and ensured the returned baseUrl is correctly applied to the completion model. Bumped outdated User-Agent and Editor-Version constants to prevent shadow downgrades by GitHub's API gateway.
  • What did NOT change (scope boundary): The caching mechanism (isCopilotTokenUsable) and the standard text chat authentication flow remain untouched.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

Real behavior proof (required for external PRs)

  • Behavior or issue addressed: GitHub Copilot image tool bypasses token exchange, causing 400 integrator scope errors.
  • Real environment tested: Ubuntu 22.04 on WSL2, Node.js v22.22.2
  • Exact steps or command run after this patch:
    1. Configured default image model to github-copilot/gemini-3.1-pro-preview.
    2. Executed a prompt with an image: Describe this image, focusing on expressions.
  • Evidence after fix:
    After fix - auth passes, Gemini responds
  • Observed result after fix: The original authorization error (400 The requested model is not available for integrator "copilot-language-server") is completely resolved. The image tool now obtains a short-lived Copilot API token with the vscode-chat integrator scope, which has access to multi-modal models like gemini-3.1-pro-preview. The separate payload-format issue (Gemini rejecting system-level prompt placement) is addressed in a focused follow-up PR per the "Keep PRs focused" guideline.
  • What was not tested: Live testing on macOS/Windows native apps (tested on WSL2).
  • Before evidence:
    Before fix - 400 integrator scope error

Root Cause

This PR addresses two root causes that prevented the image tool from using Copilot-hosted Gemini models:

Cause 1 — Token exchange and baseUrl bypass (core): The image tool in media-understanding/image.ts fetches the raw GitHub OAuth access token via getApiKeyForModel and passes it directly to pi-ai.complete(), bypassing the /v2/token exchange that normal chat performs via prepareRuntimeAuth. This caused two issues: it inherited the restricted copilot-language-server integrator scope, and it discarded the custom baseUrl required by enterprise or proxy-routed Copilot deployments.

Cause 2 — Stale IDE header versions: COPILOT_USER_AGENT and COPILOT_EDITOR_VERSION were pinned to 0.26.7 / vscode/1.96.2. GitHub's /v2/token endpoint maps these older versions to the copilot-language-server integrator. Updated to 0.35.0 / vscode/1.107.0 to match the current VS Code Chat extension identifiers used by pi-ai.

Missing detection: E2E tests mock the endpoint but don't validate token scope/claims required by Copilot's multi-modal models.

Contributing context: PR #80074 added the Copilot-Integration-Id header and cache invalidation for the standard prepareRuntimeAuth chat flow, but did not cover the image tool's separate auth path or the outdated IDE version headers.

Regression Test Plan

  • Coverage level that should have caught this:

    • Unit test
    • Seam / integration test
    • End-to-end test (live Copilot subscription required)
    • Existing coverage already sufficient
  • Existing tests updated: compaction-safeguard.test.ts — UA assertion updated from 0.26.7 to 0.35.0.

  • Scenario that should be locked in: When provider === 'github-copilot', the image tool must call resolveCopilotApiToken to exchange the OAuth token for a short-lived Copilot API token.

  • Why live E2E is the right level: The /v2/token exchange and Copilot API behavior can only be validated against GitHub's live infrastructure. CI-mocked endpoints cannot exercise the actual token scope logic.

User-visible / Behavior Changes

Users can now successfully use github-copilot/gemini-3.1-pro-preview (and future multi-modal Copilot models) as their designated image model without hitting integrator authorization errors.

Diagram (if applicable)

Before (Image Tool Bypass):
[Image Request] -> [Raw OAuth Token] -> [Copilot API] -> [400 Error (language-server scope)]

After (Aligned Auth Path):
[Image Request] -> [/v2/token Exchange] -> [Copilot API Token] -> [Copilot API] -> [200 OK]

Security Impact (required)

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? Yes
  • New/changed network calls? Yes
  • Command/tool execution surface changed? No
  • Data access scope changed? No
  • If any Yes, explain risk + mitigation: Added a network call to https://api.github.com/copilot_internal/v2/token during the image tool initialization. Mitigation: This leverages the exact same secure resolveCopilotApiToken helper used by standard chat, which inherently caches the short-lived token to prevent network spam.

Repro + Verification

Environment

  • OS: WSL2 (Ubuntu 22.04.5 LTS)
  • Runtime/container: Node.js
  • Model/provider: github-copilot/gemini-3.1-pro-preview
  • Relevant config (redacted): imageModel: { primary: "github-copilot/gemini-3.1-pro-preview" }

Steps

  1. Set the image model to github-copilot/gemini-3.1-pro-preview in openclaw.json.
  2. Send an image with a prompt to the agent.
  3. Observe the request lifecycle.

Expected

  • The request uses a minted Copilot API token and returns a 200 OK with the image analysis.

Actual

  • (Before patch) 400 Bad Request: The requested model is not available for integrator "copilot-language-server".

Evidence

Attach at least one:

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Screenshots embedded in the Real behavior proof section above.

Human Verification (required)

What you personally verified (not just CI), and how:

  • Verified scenarios:

    • Live Copilot subscription with github-copilot/gemini-3.1-pro-preview as image model — image tool successfully identified a solid red 100×100 PNG as "red", confirming the vscode-chat integrator scope is now applied and Gemini multimodal models respond correctly.
    • Cached token file (github-copilot.token.json) now includes "integrationId": "vscode-chat" in its payload, confirming the exchange logic and cache metadata are aligned.
    • Token exchange uses updated User-Agent: GitHubCopilotChat/0.35.0 and Editor-Version: vscode/1.107.0, confirmed via diagnostic logging.
  • Edge cases checked:

    • Legacy cached token without integrationId is correctly rejected and a fresh /v2/token exchange is triggered (existing test coverage).
  • What you did not verify:

    • Other Copilot-hosted models beyond gemini-3.1-pro-preview (GPT-4o, Claude Sonnet 4.5, etc.) — these use different auth paths before this PR and should be unaffected.
    • Rate-limiting or token-refresh edge cases under sustained image tool usage.

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

If a bot review conversation is addressed by this PR, resolve that conversation yourself. Do not leave bot review conversation cleanup for maintainers.

Compatibility / Migration

  • Backward compatible? Yes
  • Config/env changes? No
  • Migration needed? No
  • If yes, exact upgrade steps: N/A — existing installations pick up the fix on upgrade. The integrationId cache field is optional (backward compatible with older cache files, which are rejected and re-minted).

Risks and Mitigations

  • Risk: The image tool now makes an additional network call (/v2/token) on first use per session, adding latency (~200-500ms).

    • Mitigation: The Copilot API token is cached with a 5-minute usability window (isCopilotTokenUsable), so subsequent image calls within a session reuse the cached token without an additional exchange.
  • Risk: Updated IDE header versions (0.26.7 → 0.35.0, 1.96.2 → 1.107.0) could theoretically change Copilot API behavior for models other than Gemini.

    • Mitigation: These are the versions used by the current VS Code Chat extension (and by pi-ai internally). The Copilot runtime chat path already sends these headers successfully for all models. No behavioral change expected for non-image Copilot requests.
  • Risk: Token exchange failure in the image tool causes a silent fallback to the raw OAuth token.

    • Mitigation: The fallback preserves existing behavior (OAuth token + copilot-language-server scope) rather than breaking the image tool entirely. Failed exchanges are likely transient and self-heal on the next call.

…up-to-date IDE headers

- Bump COPILOT_USER_AGENT from 0.26.7 to 0.35.0 and COPILOT_EDITOR_VERSION
  from vscode/1.96.2 to vscode/1.107.0 to match the VS Code Chat extension
  versions that GitHub maps to the vscode-chat integrator scope.
- Add /v2/token exchange in resolveImageRuntime for github-copilot models so
  the image tool obtains a short-lived Copilot API token instead of sending
  the raw GitHub OAuth access token directly. The raw OAuth token inherits
  the copilot-language-server integrator scope, which lacks image-capable
  models like gemini-3.1-pro-preview. Normal chat requests already exchange
  via prepareRuntimeAuth; this aligns the image tool path.

Refs: openclaw#79946
Copilot AI review requested due to automatic review settings May 10, 2026 18:59
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 10, 2026
@clawsweeper

clawsweeper Bot commented May 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

Summary
The PR exchanges GitHub Copilot image-tool auth through the Copilot token helper, applies the returned baseUrl to the image model, and updates Copilot IDE header constants plus one header assertion.

Reproducibility: yes. source-level. Current main's image runtime stores and passes the raw resolved key for github-copilot image models, and the supplied before/after screenshots show the live integrator authorization error moving past the auth layer after the patch.

Real behavior proof
Sufficient (screenshot): The screenshots show an after-fix real image-tool run progressing past the Copilot integrator authorization failure to a later payload-format error, which is sufficient for this auth-routing PR.

Next step before merge
No repair lane is needed because the branch already contains the focused auth/baseUrl change and I found no concrete automated repair target.

Security
Cleared: The diff changes token handling by reusing the existing Copilot token exchange helper and adds no dependencies, workflows, permissions, lifecycle scripts, or new code execution paths.

Review details

Best possible solution:

Land this scoped auth/baseUrl alignment after maintainer review, then handle Gemini message-layout compatibility through the separate follow-up.

Do we have a high-confidence way to reproduce the issue?

Yes, source-level. Current main's image runtime stores and passes the raw resolved key for github-copilot image models, and the supplied before/after screenshots show the live integrator authorization error moving past the auth layer after the patch.

Is this the best way to solve the issue?

Yes for the scoped auth fix. Reusing resolveCopilotApiToken and propagating the returned baseUrl matches the adjacent simple completion contract; the later Gemini payload-layout error is a separate narrower repair.

What I checked:

  • Current main image path bypasses token exchange: On current main, resolveImageRuntime obtains the model auth via getApiKeyForModel/requireApiKey, stores that same key in runtime auth storage, and returns the unchanged model; there is no Copilot /v2/token exchange in this path. (src/media-understanding/image.ts:163, a4e6d00770f4)
  • Existing helper provides the intended Copilot contract: resolveCopilotApiToken sends Copilot-Integration-Id through the /v2/token request, rejects cached tokens without that integration id, and returns both the minted token and derived Copilot baseUrl. (src/plugin-sdk/provider-auth.ts:212, a4e6d00770f4)
  • Adjacent chat runtime already applies token and baseUrl: The simple completion path exchanges github-copilot tokens, stores the minted token, and applies runtimeCredential.baseUrl to the model before completing, matching the shape this PR brings to image requests. (src/agents/simple-completion-runtime.ts:119, a4e6d00770f4)
  • PR diff matches the narrow auth/baseUrl fix: The PR imports resolveCopilotApiToken in the image runtime, exchanges github-copilot image keys, applies a non-empty returned baseUrl to the runtime model, and updates the Copilot header constants. (src/media-understanding/image.ts:170, adb3caf0e3d3)
  • Dependency contract uses model.baseUrl: The repo pins @earendil-works/pi-ai 0.74.0, and the package source creates OpenAI-family clients with baseURL from model.baseUrl while adding Copilot dynamic headers for github-copilot models. (package.json:1723, a4e6d00770f4)
  • Real proof shows auth-layer progress: Downloaded before/after screenshots show a live image-tool run changing from the copilot-language-server model-availability error to a later Gemini payload-format error, which is sufficient proof for this scoped auth-routing change. (adb3caf0e3d3)

Likely related people:

  • Shakker: Current blame/log in this checkout attributes the central image-runtime and provider-auth implementations to commit 640d199 on the touched files. (role: recent current-main area contributor; confidence: medium; commits: 640d1994c0ef; files: src/media-understanding/image.ts, src/plugin-sdk/provider-auth.ts)
  • TurboTheTurtle: Authored the merged related Copilot token identity work that added the integration-id exchange/cache behavior this PR reuses for image requests. (role: recent related feature contributor; confidence: medium; commits: c20450a82b82, d83877ae2be7; files: src/plugin-sdk/provider-auth.ts, src/agents/github-copilot-token.test.ts, src/agents/copilot-dynamic-headers.ts)
  • Peter Steinberger: Recent history on the SDK/auth/media files shows repeated release/refactor ownership, and the related merged token-identity PR includes a Peter Steinberger commit shipping the credited fix. (role: recent area contributor and merger; confidence: medium; commits: d83877ae2be7, 4862d349257a, e8866fc738bb; files: src/plugin-sdk/provider-auth.ts, src/media-understanding/image.ts, src/agents/simple-completion-runtime.ts)

Remaining risk / open question:

Codex review notes: model gpt-5.5, reasoning high; reviewed against a4e6d00770f4.

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 fixes GitHub Copilot image-tool authentication so image requests use a minted short-lived Copilot API token (via /copilot_internal/v2/token) rather than sending the raw GitHub OAuth token, and updates Copilot IDE header version constants to match current VS Code Chat identifiers.

Changes:

  • Bumped COPILOT_USER_AGENT and COPILOT_EDITOR_VERSION to newer VS Code Chat-aligned values.
  • Added a Copilot token-exchange step in the image runtime path (resolveImageRuntime) for github-copilot models.
  • Updated a header assertion in compaction-safeguard tests to match the new User-Agent.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/plugin-sdk/provider-auth.ts Updates Copilot IDE header version constants used during token exchange.
src/media-understanding/image.ts Exchanges GitHub OAuth token for a Copilot API token for image-tool requests.
src/agents/pi-hooks/compaction-safeguard.test.ts Updates expected User-Agent header in a test to match the new constant.

Comment thread src/media-understanding/image.ts Resolved
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 10, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 10, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 10, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 10, 2026
resolveCopilotApiToken returns both a minted token and the API endpoint
derived from it. The normal chat path applies baseUrl to the model before
calling complete(); the image path was discarding it, which would break
enterprise or proxy-routed Copilot deployments where the minted token
points to a non-default host.
@afunnyhy
afunnyhy force-pushed the fix/copilot-image-token-bypass branch from 2e84c60 to e7e3ba0 Compare May 10, 2026 19:53
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 10, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 10, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 10, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 10, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 10, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 10, 2026
afunnyhy added a commit to afunnyhy/openclaw that referenced this pull request May 10, 2026
Add two tests verifying the payload structure for image context:

1. github-copilot provider: prompt and image data are bundled together
   in the user message, with NO separate systemPrompt.
2. Non-copilot provider (openai): prompt goes to systemPrompt,
   images stay in user message without text.

Refs: openclaw#79946, openclaw#80393
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 11, 2026
@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 11, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 11, 2026
steipete added a commit that referenced this pull request May 13, 2026
Fixes Copilot image understanding by exchanging OAuth tokens for Copilot API tokens, routing Copilot Gemini image requests through Chat Completions, and sending the prompt in user content with Copilot vision headers.

Real behavior proof:
- Old Responses route with real Copilot key reproduced `400 model gemini-3.1-pro-preview does not support Responses API`.
- Fixed route with the same real Copilot key returned `Cat`.
- Final CLI live smoke returned `ok: true` and `text: Cat` for `github-copilot/gemini-3.1-pro-preview`.

Verification:
- pnpm test src/media-understanding/image.test.ts extensions/github-copilot/models.test.ts extensions/github-copilot/stream.test.ts src/agents/pi-hooks/compaction-safeguard.test.ts -- --reporter=verbose
- pnpm check:changed via Blacksmith Testbox tbx_01krgt56pqmft8txekt017wke6, Actions run https://github.com/openclaw/openclaw/actions/runs/25803926150, exit 0.

Refs #80393, #80442.

Co-authored-by: Yang Haoyu <[email protected]>
@steipete

Copy link
Copy Markdown
Contributor

Thanks @afunnyhy. I landed this as part of the combined maintainer follow-up in #81429 because the two Copilot image fixes needed to be rebased and cleaned up together.

Landed commit: 0b8ee46

What landed:

  • Copilot image understanding now exchanges the GitHub OAuth token for the Copilot API token and uses the returned Copilot base URL.
  • Copilot Gemini models now use the Chat Completions payload route instead of Responses.
  • Image prompts for Copilot are placed in the user content with the image, and Copilot vision/IDE headers are sent.

Proof:

  • Before fix, the real Copilot key on the old Responses route returned 400 model gemini-3.1-pro-preview does not support Responses API.
  • After fix, the real Copilot Gemini image route returned Cat.
  • Final CLI live smoke on the landed branch returned ok: true and text: Cat for github-copilot/gemini-3.1-pro-preview.
  • pnpm check:changed passed via Blacksmith Testbox tbx_01krgt56pqmft8txekt017wke6.

Closing this PR as superseded by the landed replacement. Your commits were preserved in the replacement branch, and the squash merge includes your co-author credit.

l3ocifer pushed a commit to l3ocifer/frack-openclaw that referenced this pull request May 13, 2026
Fixes Copilot image understanding by exchanging OAuth tokens for Copilot API tokens, routing Copilot Gemini image requests through Chat Completions, and sending the prompt in user content with Copilot vision headers.

Real behavior proof:
- Old Responses route with real Copilot key reproduced `400 model gemini-3.1-pro-preview does not support Responses API`.
- Fixed route with the same real Copilot key returned `Cat`.
- Final CLI live smoke returned `ok: true` and `text: Cat` for `github-copilot/gemini-3.1-pro-preview`.

Verification:
- pnpm test src/media-understanding/image.test.ts extensions/github-copilot/models.test.ts extensions/github-copilot/stream.test.ts src/agents/pi-hooks/compaction-safeguard.test.ts -- --reporter=verbose
- pnpm check:changed via Blacksmith Testbox tbx_01krgt56pqmft8txekt017wke6, Actions run https://github.com/openclaw/openclaw/actions/runs/25803926150, exit 0.

Refs openclaw#80393, openclaw#80442.

Co-authored-by: Yang Haoyu <[email protected]>
@afunnyhy
afunnyhy deleted the fix/copilot-image-token-bypass branch May 18, 2026 17:18
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
Fixes Copilot image understanding by exchanging OAuth tokens for Copilot API tokens, routing Copilot Gemini image requests through Chat Completions, and sending the prompt in user content with Copilot vision headers.

Real behavior proof:
- Old Responses route with real Copilot key reproduced `400 model gemini-3.1-pro-preview does not support Responses API`.
- Fixed route with the same real Copilot key returned `Cat`.
- Final CLI live smoke returned `ok: true` and `text: Cat` for `github-copilot/gemini-3.1-pro-preview`.

Verification:
- pnpm test src/media-understanding/image.test.ts extensions/github-copilot/models.test.ts extensions/github-copilot/stream.test.ts src/agents/pi-hooks/compaction-safeguard.test.ts -- --reporter=verbose
- pnpm check:changed via Blacksmith Testbox tbx_01krgt56pqmft8txekt017wke6, Actions run https://github.com/openclaw/openclaw/actions/runs/25803926150, exit 0.

Refs openclaw#80393, openclaw#80442.

Co-authored-by: Yang Haoyu <[email protected]>
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
Fixes Copilot image understanding by exchanging OAuth tokens for Copilot API tokens, routing Copilot Gemini image requests through Chat Completions, and sending the prompt in user content with Copilot vision headers.

Real behavior proof:
- Old Responses route with real Copilot key reproduced `400 model gemini-3.1-pro-preview does not support Responses API`.
- Fixed route with the same real Copilot key returned `Cat`.
- Final CLI live smoke returned `ok: true` and `text: Cat` for `github-copilot/gemini-3.1-pro-preview`.

Verification:
- pnpm test src/media-understanding/image.test.ts extensions/github-copilot/models.test.ts extensions/github-copilot/stream.test.ts src/agents/pi-hooks/compaction-safeguard.test.ts -- --reporter=verbose
- pnpm check:changed via Blacksmith Testbox tbx_01krgt56pqmft8txekt017wke6, Actions run https://github.com/openclaw/openclaw/actions/runs/25803926150, exit 0.

Refs openclaw#80393, openclaw#80442.

Co-authored-by: Yang Haoyu <[email protected]>
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 2026
Fixes Copilot image understanding by exchanging OAuth tokens for Copilot API tokens, routing Copilot Gemini image requests through Chat Completions, and sending the prompt in user content with Copilot vision headers.

Real behavior proof:
- Old Responses route with real Copilot key reproduced `400 model gemini-3.1-pro-preview does not support Responses API`.
- Fixed route with the same real Copilot key returned `Cat`.
- Final CLI live smoke returned `ok: true` and `text: Cat` for `github-copilot/gemini-3.1-pro-preview`.

Verification:
- pnpm test src/media-understanding/image.test.ts extensions/github-copilot/models.test.ts extensions/github-copilot/stream.test.ts src/agents/pi-hooks/compaction-safeguard.test.ts -- --reporter=verbose
- pnpm check:changed via Blacksmith Testbox tbx_01krgt56pqmft8txekt017wke6, Actions run https://github.com/openclaw/openclaw/actions/runs/25803926150, exit 0.

Refs openclaw#80393, openclaw#80442.

Co-authored-by: Yang Haoyu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants