← Back to Pull requests

fix(openaimodel): send executable code parts as text #1956

Closed
unknown closed this pull request without merging on Nov 06, 2026 09:37 UTC
View on GitHub
unknown unknown commented on Oct 23, 2026 21:41 UTC
Author

Please ensure you have read the contribution guide before creating a pull request.

Linked issue

  • Closes: #1924
  • Problem:
    A Gemini turn that stores ExecutableCode or CodeExecutionResult makes the next OpenAI request fail before it is sent. Both Chat Completions and Responses reject the part with openai: unsupported content part: ExecutableCode (or CodeExecutionResult).

    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_output block 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:

  • All unit tests pass locally.

  • Both endpoints assert the exact request payload for code-only and code-plus-image histories, including the media-message path.
  • go test -count=1 -race -timeout 180s ./model/openaimodel/...

    ok  google.golang.org/adk/v2/model/openaimodel
    ok  google.golang.org/adk/v2/model/openaimodel/internal/completions
    ok  google.golang.org/adk/v2/model/openaimodel/internal/responses
    ok  google.golang.org/adk/v2/model/openaimodel/internal/shared
    

    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 PartFieldCodeExecution from the converters:

  • TestBuildParams_CodeExecutionAsText (responses and completions)

  • TestBuildParams_DropsReplayedThoughts/thought_text_riding_on_code_drops_only_the_text
  • They 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

  • I have read the CONTRIBUTING.md document.

  • I have performed a self-review of my own code.

  • I have commented my code, particularly in hard-to-understand areas.

  • I have added tests that prove my fix is effective or that my feature works.

  • New and existing unit tests pass locally with my changes.

  • I have manually tested my changes end-to-end.

  • Any dependent changes have been merged and published in downstream modules.
  • Diff: 398 lines (+298 / -100) across 4 files Reviewer: ktsoator Review duration: 19436m
    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
    0.48
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 48.2% (MEDIUM) · Higher = larger blast radius
    48.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 19.1% · Safe to merge
    19.1%
    Repository