fix(models): move documents out of OpenAI tool messages into a user message #5961
All Vouch review confidence checks passed
Residual risk 0.24 = Change Risk (0.45) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 293 lines diff across 3 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
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.340
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #5961"
general
weight: 0.35
chrikrah
HUMAN:
I moved documents the same way images already move, but only PDFs — those are the only documents the API accepts in a user message. I read every changed line and ran the model tests locally on Windows (Python 3.12, openai 3.x, litellm 1.10x):
test_openai.pyandtest_litellm.pyare 260 passed, ruff clean. I did not run a live Bedrock call; the bot's repro is the evidence for that path.---
AGENT:
Why
OpenAIModel.format_request_tool_messagekeeps a document in the tool message:format_request_message_contentrenders it as afilepart, and the tool message keeps its array form. The Chat Completions tool role accepts text only, so that request is invalid for the tool-message shape, while_split_tool_message_imagesalready moves images into a following user message for exactly this reason.Summary
fileparts alongsideimage_urlparts in the tool-message splitter, returning them in one user message and leaving the tool message text-only.filepart inside a tool message into a native tool-result document, and moving one would break that path without making an OpenAI request valid._split_tool_message_mediasince it now covers both kinds, and the informational text says which kind moved.Issue Number
Related to #5848.
How to Test
260 passed. The new tests fail without the source change: the PDF test sees a
filepart left in the tool message, and the non-PDF test sees it moved.Type
Notes
The informational text for an image is the same sentence as before, split across two literals to stay inside the line limit. Non-PDF documents are untouched, so
LiteLLMModel→ Bedrock keeps working as it does onmain.