mirror of
https://github.com/Alishahryar1/free-claude-code.git
synced 2026-05-20 09:02:38 +00:00
## What Fixes the 422 error returned by the proxy when Claude Code v2.1.128+ sends PDF context as Anthropic `document` blocks, plus two related DeepSeek-only issues uncovered while debugging. Closes #357. ## Why Claude Code now attaches PDFs/files as `document` content blocks. The `Message.content` union didn't include that variant, so every follow-up turn after a PDF read returned `422 Unprocessable Content` from the proxy itself (before the request ever reached DeepSeek). ## Changes - `api/models/anthropic.py`: new `ContentBlockDocument`, added to `Message.content` union. - `providers/deepseek/request.py`: - `_strip_unsupported_attachment_blocks` — silently drops `image`/`document` blocks for DeepSeek. - `_serialize_tool_result_content` + `_normalize_tool_result_content` — coerces `tool_result.content` to a string per DeepSeek's API contract. - Hooked into `build_request_body` (strip before validation, normalize before send). - `tests/providers/test_deepseek.py`: +4 tests, 1 legacy test updated. ## Verification - `uv run ruff format` ✅ - `uv run ruff check` ✅ - `uv run ty check` ✅ - `uv run pytest` ✅ (1194 passed) - Manual: `claude-deepseek` against a PDF no longer 422s. ## Scope / non-goals - No README change (per CONTRIBUTING). - Image/document blocks for DeepSeek are stripped, not converted to text — Claude Code already ships the extracted text in the paired tool_result. - No changes to other providers. --------- Co-authored-by: Alishahryar1 <alishahryar2@gmail.com> |
||
|---|---|---|
| .. | ||
| __init__.py | ||
| client.py | ||
| request.py | ||