← Back to Pull requests

[Python] Default max_batch_size in the Gemini and OpenAI model handlers #41361

Open
unknown opened this pull request with 145 lines diff across 1 files
View on GitHub
unknown unknown commented on Nov 15, 2026 11:37 UTC
Author

Fixes #41360

GeminiModelHandler and OpenAIModelHandler set no default max_batch_size, so default batches grow to about 1,000 prompts, and to 10,000 inputs with embedding_from_string, which is over the 2,048 inputs the embeddings endpoint accepts. Per-prompt requests are only sent 32 at a time, and a failed request retries the whole batch.

This PR defaults max_batch_size to 32, or to 2,048 with embedding_from_string, and never below min_batch_size. An explicit max_batch_size behaves as before.

Testing:

  • New tests in gemini_inference_test.py and openai_inference_test.py. They fail on master.

  • Pipelines with fake clients and default settings: embedding requests went from up to 10,000 inputs (7 of 20 over the limit) to at most 2,048 (0 of 43). Gemini batches went from about 1,000 prompts to 32; 3,000 prompts at 0.5 s per call took 51 s before and 53 s after.
  • This is from the same pass over the remote LLM handlers as #40914 and #41359. I'm happy to change the default values if you'd pick different ones, and if something else in this area would be more useful for me to work on, I'd be glad to.

    R: @jrmccluskey
    cc: @claudevdm

    Diff: 145 lines (+108 / -37) across 1 files Reviewer: Mola-maker Review duration: 19338m
    All Vouch review confidence checks passed
    Residual risk 0.20 = Change Risk (0.38) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.38 · 145 lines diff across 1 files
    0.38
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    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
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.298
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #41361"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% 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: 37.8% (MEDIUM) · Higher = larger blast radius
    37.8%
    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: 46.7% · Lower = rushed or shallow review
    46.7%
    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: 20.2% · Safe to merge
    20.2%
    Repository