fix: preserve PDF filenames from tool output - #42401
Conversation
OpenAI Responses converts file content inside a tool result without the original filename. Providers that validate file extensions can reject the synthesized filename and poison every later replay of the session. Move PDF tool attachments into a normal user message for OpenAI and Bedrock Mantle transports. This keeps the filename, preserves supported PDF input, and lets the existing capability guard replace unsupported PDFs with an actionable model-visible error. Closes anomalyco#21908 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
|
The following comment was made by an LLM, it may be inaccurate: Potential related PRs found:
These PRs address the same general problem space of handling PDFs and media in tool results across different providers and model capabilities. Check if this PR (42401) is a fresh approach to an already-addressed issue or if it complements/supersedes the earlier work. |
Prevent PDF tool results from poisoning sessions on OpenAI-compatible provider transports.
The AI SDK turns media embedded in a tool result into an
input_filewith a fallback filename when the stored attachment filename is unavailable. Providers that validate the filename reject that replay, and every later request in the session fails on the same history. OpenCode now moves PDFs into a normal user message, where it preserves the filename and applies the existing model capability guard.Changes
Effects
datafile inside a tool result.Verified with all 40
message-v2tests, package typecheck, repository pre-push typecheck, Prettier, and Oxlint.Closes #21908
🤖 Generated with Claude Code