fix(messages): convert document blocks in user content #1679
All Vouch review confidence checks passed
Residual risk 0.26 = Change Risk (0.48) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.48 · 392 lines diff across 4 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.357
Shallow Review Depth
shallow_review_depth
0.344
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #1679"
general
weight: 0.35
shlokbam
Description
A
documentblock in a user message was forwarded as-is to the completion bridge, while the same block inside a tool result was already converted by_convert_document_block_to_openai. OpenAI-compatible backends got an Anthropic-shaped part they don't accept, and Gemini skipped it, so the model never saw the document._convert_user_blocks_to_openainow convertsdocumentblocks with_convert_document_block_to_openai, like the tool-result path: base64 and url sources become afilepart, andtext/contentsources become a text part. An empty source raisesInvalidRequestError, as it does in a tool result. Other unknown block types are still kept as-is.The Responses path builds its input from the same converted messages, so a user document now goes as
input_file. I updated the one assertion intest_messages_params_to_responses_params_maps_request_fieldsthat expected the raw document block.Wire output after the change, same request as in the issue:
PR Type
Relevant issues
Fixes #1678
Checklist
- [ ] No AI was used.
- [ ] AI was used for drafting/refactoring.
- [x] This is fully AI-generated.
AI Usage Information
Testing details: new tests in
tests/unit/test_messages_compat.py(base64, url and text sources in user content, and an empty source) fail on main and pass with the change.test_messages_compat.py,test_openai_base_provider.pyandtest_gemini_provider.py: 746 passed, 5 skipped. Acrosstests/unitwith the extras I have installed, the change fixes exactly these 5 failures and adds none (the rest fail on main too, for provider SDKs that aren't installed).ruff check/ruff format --check(0.17.3),mypyandcodespellpass on the changed files. I did not run integration tests (no provider keys).<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
<!-- coderabbit-ai-generated:v1 -->
Summary by CodeRabbit
New Features
User messages can now include documents provided as text, encoded files, or URLs. These are converted into compatible text or file content when sent to supported services.
Bug Fixes
Requests with document attachments that lack required file data now return a clear error instead of being processed as valid attachments.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->