Skip to content

fix(proxy): replace documents DeepSeek refuses with a note - #73

Merged
williamdes merged 2 commits into
mainfrom
claude/peaceful-mccarthy-iaabb0
Nov 16, 2026
Merged

williamdes merged 2 commits into
mainfrom
claude/peaceful-mccarthy-iaabb0

Conversation

@williamdes

Copy link
Copy Markdown
Member

Problem

DeepSeek's Anthropic-shaped endpoint accepts a document block only from a text or file source and answers a 400 for the whole body otherwise:

messages.300.content.1.source: only file and text document sources are supported

Claude Code attaches a PDF it has read as a base64 document. The block then sits in history, so every later request of the session fails too and the session is stuck.

Fix

A request bound for DeepSeek now has each such block replaced by a text note saying a document was attached and could not be sent, so the model can extract the text with a tool instead.

  • New media.rs module in tab-atelier-proxy, called from the relay's body shaping.
  • Documents nested inside a tool_result are found too.
  • A cache_control breakpoint on the block is kept on the note.
  • The note is a pure function of the block, so the same history shapes to the same bytes each turn and the provider's prefix cache is not disturbed.
  • text and file document sources, and images, are left alone.

Testing

Clippy on the proxy crate is clean and its test suite passes, including five new unit tests in media.rs.


Generated by Claude Code

DeepSeek's Anthropic-shaped endpoint accepts a document block only from
a `text` or `file` source and answers a 400 for the whole body otherwise.
Claude Code attaches a PDF it has read as a base64 document, which then
sits in history, so every later request of the session failed too.

A request bound for DeepSeek now has such blocks replaced by a text note
saying a document was attached and could not be sent. The note is a pure
function of the block, so the cached prefix is not disturbed.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G6dpqKZuw9vLYFzGPuKppp
The document pass's log line moves into the media module, where the
count is produced.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G6dpqKZuw9vLYFzGPuKppp
@williamdes williamdes self-assigned this Nov 16, 2026
@codecov

codecov Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.00990% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 80.29%. Comparing base (6a62b16) to head (d2d9a63).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
crates/tab-atelier-proxy/src/media.rs 98.97% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #73      +/-   ##
==========================================
+ Coverage   80.28%   80.29%   +0.01%     
==========================================
  Files         248      249       +1     
  Lines       76232    76333     +101     
==========================================
+ Hits        61205    61294      +89     
- Misses      15027    15039      +12     
Flag Coverage Δ
rust 80.29% <99.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@williamdes
williamdes merged commit d2d9a63 into main Nov 16, 2026
4 checks passed
@williamdes
williamdes deleted the claude/peaceful-mccarthy-iaabb0 branch November 16, 2026 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants