You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constmaxImagesPerRequest=config.maxImagesPerRequest??600;constimageOffloadByteQuantum=config.imageOffloadByteQuantum??67108864;// 64MiBconstinlineImageOffloadByteQuantum=config.inlineImageOffloadByteQuantum??10485760;// 10MiBconstimageOffloadCountQuantum=config.imageOffloadCountQuantum??20;if(imageOffloadCountQuantum>maxImagesPerRequest)thrownewError("llm-deepseek: imageOffloadCountQuantum must not exceed maxImagesPerRequest");
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
补充一份源码级的根因分析 + 完整改动清单,把这条线索钉死,也给官方一个最小改动的修法。
一、结论
llm-pi-ai的图片卸载调用只传了「字节」维度,完全没传「张数」维度;llm-deepseek两者都传。所以上游按张数限流时,llm-pi-ai路线上卸载逻辑永远不会触发。二、源码对照(
0.1.5-rc.2实测)A.
dsh-llm-pi-ai—— 卸载调用只带字节node_modules/@deepseek-ai/dsh-llm-pi-ai/lib/index.js:1286-1300:配置 schema 也只有三项(
lib/index.js:1011-1013):全文件检索(
lib/index.js,2688 行):maxImagesPerRequest0 次、imageOffloadCountQuantum0 次、imageOffloadByteQuantum0 次。B.
dsh-llm-deepseek—— 卸载调用带张数node_modules/@deepseek-ai/dsh-llm-deepseek/lib/index.js:1677-1685:base64 分支同样带(
1697-1705:maxImagesPerRequest/byteQuantum/countQuantum)。默认值与交叉校验(1970-1982):差异一目了然:同一个
offloadRequestImagesWithPolicy,llm-deepseek传maxImages+countQuantum,llm-pi-ai一个都没传。C. 为什么默认值必然漏
llm-pi-ai的maxRequestImageBytes默认 20MiB;而byteLength把单图按min(ref.bytes, 1MiB)计(1280-1283:requestImagePolicy默认{ maxPixels: 4194304, maxBytes: 1048576 })。31 张图若平均 < 0.68MiB,合计就不到 20MiB ⇒ 字节闸门不触发 ⇒ 31 张原样发出 ⇒ 上游 400。这就是「上游按张数、适配器按字节」的口径错位。
三、故障复现(本人环境)
环境:DSH 桌面端
0.2.0-rc.2|@deepseek-ai/dsh-llm-pi-ai0.1.5-rc.2| provider =opencode-go(上游报错来自 "Console Go")turn 37400 ... Too many images in request: 31 > 30(INVALID_REQUEST)turn 38turn 39/compactcompaction/end的error字段仍是同一条 400/compact救不了的原因:compaction 压的是文本,图片作为历史内容原样留在请求里,压完还是 31 张。四、我改了什么(完整 diff)
~/.dsh/profiles/desktop/cordis.patch.yml:- id: llm-pi-ai name: "@deepseek-ai/dsh-llm-pi-ai" config: providers: opencode-go: apiKeyEnv: OPENCODE_GO_API_KEY + # 上游(Console Go)单请求限 30 张图,默认 20MiB 字节闸门不会触发 + # → 31>30 永久卡死会话。调小到 2MiB 强制「最老优先」逐张卸载为文字占位。 + maxRequestImageBytes: 2097152 # 2MiB(改动前已备份
cordis.patch.yml.bak-20261004-imgcap,可一键回滚。)五、效果与验证
/compact)~/.dsh/sessions/**/session.v4.jsonl.zstd(38 个会话),按事件类型过滤后确认assistant/attempt/turn/end/compaction/end中再无该 400代价与调参建议(重要):卸载是「最老优先,直到总量 ≤
maxRequestImageBytes」。设 2MiB 时,若单图平均 0.6MiB,只剩约 3 张图留在上下文里——能用,但很激进。更精细的取值应接近 (上游张数上限 − 1) × 单图平均字节(例:29 × 0.6MiB ≈ 17MiB)。但字节口径本质上无法精确控制张数——这正是下面建议的由来。
六、上游修复状态(截至 2026-10-12)
核对 npm 上最新发布版
@deepseek-ai/dsh-llm-pi-ai@0.2.0-rc.2:maxImagesPerRequest/imageOffloadCountQuantum出现 0 次,maxRequestImageBytes9 次。→ 仍未落地。
七、建议的上游改法(最小改动)
PiAiProviderProfile增加maxImagesPerRequest?: number与imageOffloadCountQuantum?: number(语义对齐llm-deepseek)toPiContextWithImages的两处offloadRequestImagesWithPolicy调用补上:llm-deepseek对齐:imageOffloadCountQuantum ≤ maxImagesPerRequest按路线对号入座(给遇到同样问题的人)
llm-deepseek(DeepSeek 官方路由):用 PerryLink 在讨论 请求图片超过上限后无法继续、无法压缩上下文,导致会话无法继续 #6432 里的方案llm-pi-ai或其它网关路由(opencode-go、各类 OpenAI 兼容中转):没有张数字段,只能调小字节闸门maxRequestImageBytes(2MiB 起步)All reactions