Skip to content

413 on image-heavy sessions: no request-body byte budget before inlining images (reproducible) #37

Description

@ybx-cn

413 on image-heavy sessions: no request-body byte budget before inlining images (reproducible)

Component: @mars-sea/dsh-commandcode-provider 0.10.5 / 0.10.6 (main checked 2026-09-13) Environment: DSH Desktop (Windows), provider commandcode, model deepseek/deepseek-v4.1-flash, plan individual-goat, transport /provider/v1/chat/completions

Summary

This adapter inlines every historical image as a base64 data URL with no count/byte budget. Command Code's API enforces a hard request-body cap — measured here at ≈50.17 MB (below passes, above is rejected). Once a session's accumulated images cross that cap, every subsequent request on the commandcode route fails with HTTP 413, permanently for that session (images are never reclaimed from history), while the same conversation works fine on other routes.

DSH core already ships the mechanism that prevents this (offloadRequestImagesWithPolicy + offloadedImageText), and both shipped adapters use it (dsh-llm-deepseek, dsh-llm-pi-ai). This adapter does not: adapter.ts imports neither symbol on main, and messagesToOpenAI()/messagesToCC() inline images unconditionally.

Measured: the request-body cap (same endpoint, same model, same session, 2026-09-13)

Request body | prompt tokens | Result -- | -- | -- 63 images × 796,304 B base64 | 36,766 | 200 50,169,000 B (63 images) | 36,766 | 200 50,331,648 B (48.00 MiB, padded) | — | 413 50,970,000 B (64 images) | 37,185 | 413

End-to-end in a live session: after reading 26 large images, the log line

复制
[dsh-cc-image-budget] 图片预算生效:保留 14 张、替换为占位文字 12 张(上限 32 MiB base64 / 60 张)

appeared and the request body dropped to ≈18 MB — the session kept working, no 413.

Optional extra: on a 413, evict and retry once instead of surfacing the error.

Ask

  1. Enforce an image budget in the adapter (preferred — the core helper is right there and is what the shipped adapters use).
  2. If not, at least surface the cap: 413 is currently indistinguishable from a generic provider error, and Command Code's own docs do not document the request-body limit at all (their Error Codes page has no 413).

Full local write-up with raw evidence and repro scripts: commandcode-413-诊断报告.md (this workspace). Happy to re-verify anything against a build you point me at.


中文摘要

本插件把每张历史图片都以 base64 内联进请求体,且没有任何张数/字节预算。Command Code 的 API 对请求体有约 50 MB 的硬上限(实测 50,169,000 B 通过、50,331,648 B → 413)。一旦长会话(例如视觉自检循环里读回 57 张截图)越线,该会话在 commandcode 路由上就会永久 413(图片永不被回收),而同一份内容换 provider 立刻恢复。 DSH 核心已提供 offloadRequestImagesWithPolicy / offloadedImageText,且 dsh-llm-deepseekdsh-llm-pi-ai 都在用——本插件的 adapter.ts  main 上仍未接入。建议在转换前套用该策略(32 MiB 高水位 / 16 MiB 批次 / 60 张 / 30 张批次),并对 413 做一次去图重试。附:本地已实施该补丁并端到端验证通过。

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions