fix(openaimodel): send executable code parts as text #1956
All Vouch review confidence checks passed
Residual risk 0.19 = Change Risk (0.48) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.48 · 398 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 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.358
Shallow Review Depth
shallow_review_depth
0.289
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #1956"
general
weight: 0.35
ktsoator
Please ensure you have read the contribution guide before creating a pull request.
Linked issue
Problem:
A Gemini turn that stores
ExecutableCodeorCodeExecutionResultmakes the next OpenAI request fail before it is sent. Both Chat Completions and Responses reject the part withopenai: unsupported content part: ExecutableCode(orCodeExecutionResult).Solution:
Send those parts as text, using the same fences as adk-python's Responses converter: a python block for the code and a
code_outputblock for the result. Both APIs do this. adk-python's Chat Completions converter drops these parts; Go deliberately preserves them there so a cross-model session does not hide the code or its output from the model.Behavior change
A request that used to fail on these parts now includes them as text. Other unsupported parts are still rejected.
Testing Plan
Unit Tests:
go test -count=1 -race -timeout 180s ./model/openaimodel/...golangci-lint run(v2.3.1) on those three internal packages reported 0 issues.With your source change reverted and your tests kept, which test fails?
Leaving the new tests in place and not passing
PartFieldCodeExecutionfrom the converters:TestBuildParams_CodeExecutionAsText(responses and completions)TestBuildParams_DropsReplayedThoughts/thought_text_riding_on_code_drops_only_the_textThey fail with
openai: unsupported content part: ExecutableCode.Removing the media-path insertion instead makes these focused cases fail by omitting the fenced code before the image:
TestBuildParams_MediaOnTheWire/executable_code_before_an_inline_image_keeps_its_order(Chat Completions)TestBuildParams_CodeExecutionAsText/code_keeps_its_place_on_a_media_message(Responses)Manual End-to-End (E2E) Tests:
No live model call. The failure is in request construction, and the tests above check the payload that would be sent.
Checklist