Repository navigation
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes GitHub Copilot–hosted Gemini multimodal requests by ensuring the text prompt is included in the user message content (alongside image blocks), avoiding Copilot Gemini’s 400 "Request must contain at least one non-empty message" rejection.
Changes:
- Force
shouldPlaceImagePromptInUserContent()to returntrueformodel.provider === "github-copilot". - Add unit coverage to lock in the Copilot vs non-Copilot request-shape behavior at the
complete()call boundary.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/media-understanding/image.ts |
Routes Copilot image requests through the “prompt in user content” path to satisfy Gemini’s strict payload requirements. |
src/media-understanding/image.test.ts |
Adds regression tests verifying Copilot gets {text + image} in the user message and non-Copilot retains {systemPrompt + image-only user}. |
|
Codex review: needs maintainer review before merge. Summary Reproducibility: yes. Current main has a source-backed path that sends Copilot image requests as systemPrompt plus image-only user content, and the supplied before screenshot shows Copilot Gemini rejecting that shape; I did not run a live credentialed Copilot repro locally. Real behavior proof Next step before merge Security Review detailsBest possible solution: Land this payload-format fix with or after the Copilot image-auth fix, preserving non-Copilot behavior and the focused regression coverage. Do we have a high-confidence way to reproduce the issue? Yes. Current main has a source-backed path that sends Copilot image requests as systemPrompt plus image-only user content, and the supplied before screenshot shows Copilot Gemini rejecting that shape; I did not run a live credentialed Copilot repro locally. Is this the best way to solve the issue? Yes. Extending the existing prompt-in-user-content seam to github-copilot is the narrowest maintainable fix for the payload-format portion, with tests covering both the new Copilot path and retained non-Copilot behavior. Acceptance criteria:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against fd79013b8f37. Re-review progress:
|
…mpatibility When shouldPlaceImagePromptInUserContent returns false, the image prompt is placed in a system message while the user message contains only image data. Copilot-hosted Gemini models reject this format with "Request must contain at least one non-empty message" (400). Return true for github-copilot provider so the prompt text travels in the user message alongside the image, matching the format Copilot Gemini expects. Refs: openclaw#79946
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
1d66fe0 to
7eeeaee
Compare
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]>
|
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:
Proof:
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. |
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]>
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]>
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]>
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]>
When
shouldPlaceImagePromptInUserContentreturnsfalse, the image prompt is placed in asystemmessage while theusermessage contains only image data. Copilot-hosted Gemini models reject this format with"Request must contain at least one non-empty message"(400).Return
trueforgithub-copilotprovider so the prompt text travels in theusermessage alongside the image, matching the format Copilot Gemini expects.Refs: #79946, Follow-up to #80393
Summary
systemmessage and isolated image data in ausermessage. When routed through GitHub Copilot to Gemini backends (likegemini-3.1-pro-preview), this payload format is strictly rejected with a 400 error because it expects non-empty text inside theusermessage.model.provider === "github-copilot") toshouldPlaceImagePromptInUserContentto returntrue, ensuring the text prompt and image data are bundled together in theusermessage's content array.openrouterand other default providers remains completely untouched.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Real behavior proof (required for external PRs)
github-copilot/gemini-3.1-pro-previewin the image tool.github-copilot/gemini-3.1-pro-preview.Describe this image, focusing on expressions.model_not_supported). Legacy models without vision capabilities (not routed to image tool). Live multi-image payloads and edge cases with very long prompts.Root Cause (if applicable)
usermessages contain text content. It rejects multi-modal arrays that exclusively containimage_urltypes when the text prompt is separated into asystemrole.Regression Test Plan (if applicable)
Coverage level that should have caught this:
Target test or file:
src/media-understanding/image.test.tsScenario the test should lock in: Two unit tests in
describeImageWithModel:places image prompt in user content for github-copilot provider— verifies that whenprovider === "github-copilot", the context passed tocomplete()has NOsystemPromptand the user message contains bothtextandimagecontent types.does not place image prompt in user content for non-copilot providers— verifies that non-Copilot models (tested withopenai) retain the original behavior:systemPromptis set and the user message contains onlyimageblocks.Why this is the smallest reliable guardrail: These tests lock in the payload shape at the
complete()call boundary without requiring live endpoint calls, covering both codepaths (copilot and non-copilot).User-visible / Behavior Changes
Users can finally use
github-copilot/gemini-3.1-pro-previewfor multi-modal image tasks seamlessly.Diagram (if applicable)
Security Impact (required)
NoNoNoNoNoYes, explain risk + mitigation: N/A. Pure payload formatting change.Repro + Verification
Environment
github-copilot/gemini-3.1-pro-previewimageModel: { primary: "github-copilot/gemini-3.1-pro-preview" }Steps
github-copilot/gemini-3.1-pro-previewinopenclaw.json.Expected
The API returns a 200 OK and successfully describes the image.
Actual
(Before patch) 400 Bad Request:
Request must contain at least one non-empty message.Evidence
Attach at least one:
Screenshots embedded in the Real behavior proof section above.
Human Verification (required)
gemini-3.1-pro-preview— successfully received an image description without any payload rejection.github-copilot/gemini-3.1-pro-preview✅github-copilot/gpt-4.1✅github-copilot/gpt-5.2✅github-copilot/gpt-4o✅The
{ role: "user", content: [{text}, {image_url}] }format is the canonical OpenAI multimodal schema and is natively supported by all tested models behind Copilot.Review Conversations
Compatibility / Migration
YesNoNoRisks and Mitigations
github-copilotimage models might inadvertently affect how other models (e.g., GPT-4o or Claude) process the system instructions.usermessage) is the standard OpenAI schema and is natively supported by GPT-4o, Claude 3.5, and Gemini. It is fundamentally safe and arguably more standard for multi-modal requests than splitting it.