fix(model/openaimodel): refuse media in system and developer Responses messages #1887
All Vouch review confidence checks passed
Residual risk 0.31 = Change Risk (0.55) × (1 − Review Confidence (0.43)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.55 · 575 lines diff across 7 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.380
Shallow Review Depth
shallow_review_depth
0.344
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #1887"
general
weight: 0.35
ktsoator
Please ensure you have read the contribution guide before creating a pull request.
Linked issue
1. Link the issue this change is for. Required for everything except small
documentation and typo fixes. If no issue exists yet, please open one first.
2. Describe the change:
_If applicable, please follow the issue templates to provide as much detail as
possible._
Problem:
On the Responses endpoint,
newMessageconverted media parts insystemanddeveloperturns intoinput_image/input_file. The OpenAI API rejects those roles with a 400 (Invalid value: 'input_image'. Supported values are: 'input_text'.). Chat Completions already refuses the same content locally withopenai: media in a %s message is not supported: %s. Callers on Responses only saw a server error.Solution:
Refuse media in those roles inside
newMessagebefore building content, using the same error string as Completions so the caller gets a local error that names the role. User-role media is unchanged. Assistant media was already refused innewOutputMessage.Python Labs Responses still attaches media for system/developer and only skips it for assistant (
src/google/adk/models/lite_llm/_openai_responses_llm.py). This Go change matches Go Chat Completions instead of that path, because the Responses API does not acceptinput_imageon those roles.Behavior change
What behaves differently for someone already on the current release?
A Responses request whose contents include media on a
systemordevelopermessage now fails inbuildParamswithopenai: media in a {role} message is not supported: {mime}instead of being sent and rejected by the API with HTTP 400. User and assistant turns are unchanged. A request that never put media in those roles is unaffected.Testing Plan
_Please describe the tests that you ran to verify your changes. This is required
for all PRs that are not small documentation or typo fixes._
Unit Tests:
With your source change reverted and your tests kept, which test fails?
TestBuildParams_Media/image_in_a_system_message_is_refusedandTestBuildParams_Media/image_in_a_developer_message_is_refused. Both fail withbuildParams() err = nil, want an errorwhenrequest.gois reverted to unmodifiedupstream/main.Commands:
Before (tests added,
newMessageunmodified):After the
newMessageguard:golangci-lint v2.3.1 (repo config):
Manual End-to-End (E2E) Tests:
Not run against a live OpenAI Responses API (no credentials in this environment; LLM traffic in this package is replayed). The unit cases exercise
buildParamswith{Role: "system"|"developer", Parts: [{InlineData: {MIMEType: "image/png", Data: ...}}]}— the same shape as the issue reproduction. A live check would be:API: APIResponseswith that content and assert the local error rather than HTTP 400.Checklist
Additional context
This change was prepared with AI assistance. I remain responsible for the contribution and have reviewed it.