Repository navigation
fix(analyze-files): send text files to Claude as text, name the rejected files - #1157
Open
ionut-mihalache-uipath wants to merge 5 commits into
Open
ionut-mihalache-uipath wants to merge 5 commits into
ionut-mihalache-uipath wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
PDF detection, binary rejection, and PowerPoint ordering contain correctness gaps.
3 open findings
What changed in this PR
Updates Analyze Files to support non-PDF attachments with Claude-compatible models and provide clearer file-related errors.
Changes:
- Converts text and Office Open XML files into Anthropic text documents.
- Detects unlabeled PDFs and Claude model capabilities.
- Improves provider error mapping and attachment diagnostics.
| File | Description |
|---|---|
pyproject.toml |
Bumps package version. |
uv.lock |
Updates locked project version. |
src/uipath_langchain/agent/exceptions/llm.py |
Adds file-analysis error mapping. |
src/uipath_langchain/agent/multimodal/__init__.py |
Exports model capability detection. |
src/uipath_langchain/agent/multimodal/invoke.py |
Routes attachments by model capability and content. |
src/uipath_langchain/agent/multimodal/text_documents.py |
Extracts text from plain and Office files. |
src/uipath_langchain/agent/multimodal/utils.py |
Adds PDF sniffing and provider detection. |
src/uipath_langchain/agent/tools/internal_tools/analyze_files_tool.py |
Integrates conversion and file-aware errors. |
tests/agent/multimodal/test_text_documents.py |
Tests text-document conversion. |
tests/agent/multimodal/test_utils.py |
Tests model detection and PDF sniffing. |
tests/agent/test_llm_file_analysis.py |
Tests user-facing file errors. |
tests/agent/tools/internal_tools/test_analyze_files_tool.py |
Tests Analyze Files integration. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
ionut-mihalache-uipath
force-pushed
the
fix/analyze-files-anthropic-non-pdf
branch
from
October 16, 2026 12:42
8fffec2 to
275d464
Compare
ionut-mihalache-uipath
force-pushed
the
fix/analyze-files-anthropic-non-pdf
branch
from
October 26, 2026 14:52
66d173f to
ac968b3
Compare
…ted files [PC-5223] Claude over the Anthropic Messages API (Anthropic, ChatAnthropicBedrock, Vertex) accepts a base64 document only as application/pdf, so a CSV attached to Analyze Files failed with a 400 and a "review the model settings" error. - On those models a text file (text/*, e.g. CSV) is decoded (UTF-8, else Windows-1252) and sent as a text document. Converse, OpenAI and Gemini are unchanged. - A PDF declared application/octet-stream or without a type is recognised by its signature, and MIME parameters (application/pdf; name=...) no longer stop a PDF or image from being sent as one. - A provider 400 on an Analyze Files request now names the attached files and says whether the model could not read them or they exceed its context window; unsupported-MIME errors name the files too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018uaE4Knma5aBySxy4Qxu8n
…ions accurate - application/csv, application/json, application/xml and +json/+xml types count as text, so a CSV labelled application/csv no longer hits the 400. - A UTF-16/UTF-32 byte-order mark picks the encoding, and decoded text with a NUL character is rejected as binary instead of sent as garbled text. - A content-filter 400 keeps the generic mapping; when every attachment is a PDF the error no longer advises converting to PDF. - Files are named with the type they are sent as, not the declared one. - One helper reads the gateway's ProblemDetails detail for both mappings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018uaE4Knma5aBySxy4Qxu8n
An application/octet-stream PDF that kept its source file's name (Budget.docx) was renamed by its extension before the %PDF- check ran, so it was sent as a Word document. The check now reads the declared type. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018puK13ufeccUUczMHLct3F
…iles 400s A 400 that names the limit it hit (too many images, image or document too large) already maps to a specific file error; the file-analysis mapping no longer replaces it with the generic "could not read" message. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ly paths Sniffed PDFs, PDFs and images with MIME parameters, and files left to the model still carry the attachment id and name in extras. The text document sent to Claude carries none, and no tag reaches the Anthropic payload. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0136ibA6NKQ2zinUJHapvQud
ionut-mihalache-uipath
force-pushed
the
fix/analyze-files-anthropic-non-pdf
branch
from
November 2, 2026 19:54
ac968b3 to
5d80749
Compare
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




Summary
ChatAnthropic, which includesChatAnthropicBedrock, and VertexChatAnthropicVertex), Analyze Files sends a text file (text/*,application/csv,application/json,application/xml,+json/+xml) as an Anthropic text document (source.type: "text"). The file content is not changedextras): Claude clients send it to the provider as is. File and image blocks keep themapplication/octet-streamor with no type whose bytes start with%PDF-is sent asapplication/pdf, for every provider (SharePoint "Convert to PDF" downloads arrive this way)application/pdf; name="inv.pdf"is sent as a PDFFILE_ERROR, "The model could not read the attached files", naming each file and its type, or "The attached files are too large for the model" when the provider reports a context-window overflow.csvdeclaredapplication/vnd.ms-excelis namedtext/csv)Bedrock Converse, OpenAI and Gemini requests are unchanged; Converse already reads CSV natively.
Why
Analyze Files on Claude failed for a CSV and an unlabeled SharePoint PDF download. The Anthropic Messages API rejects any base64 document whose media type is not
application/pdf(document.source.base64.media_type: Input should be 'application/pdf'), even for a correctly typedtext/csv, and the user saw a generic "review the model settings" error.Testing
langchain_anthropicand Vertex Anthropic formattersruff check,ruff format --check,mypy, fullpytestbuild_file_content_blocks_forand the model:anthropic.claude-sonnet-4-5-20250929-v1:0over Bedrock invoke (UiPathChatAnthropicBedrock) andclaude-sonnet-4-6(UiPathChatAnthropic): UTF-8 CSV, cp1252 CSV, unlabeled PDF and PDF with MIME parameters are all read; an XLSX gets "The model could not read the attached files" naming the fileapplication/csv, a UTF-16 CSV with BOM and a JSON file are read; a PNG labelledtext/plainis sent as a file and gets the named errorKnown limits
🤖 Generated with Claude Code
https://claude.ai/code/session_018uaE4Knma5aBySxy4Qxu8n