dsh-image-guard
DeepSeek Harness plugin: trims the oldest images from outgoing chat requests and, when the provider rejects the image count with HTTP 400, parses the limit from the error and retries with fewer images. · DSH 插件:裁剪即将发出请求中的历史图片,并在上游因图片数量返回 400 时解析该上限并按更少的图片重试。
安装
$
npx -p @deepseek-ai/dsh dsh plugin --profile web add github:mafeis/dsh-image-guard说明文档
阅读完整 README ↗配置
~/.dsh/image-guard.json,修改后热更新、无需重启;也可在设置页或通过 /_dsh/image-guard 路由修改。
| 字段 | 默认值 | 说明 |
|---|---|---|
enabled | true | 总开关;关闭后完全透传 |
keepRecent | 12 | 保留最新的图片张数,其余替换为标记(0 表示全部) |
maxRetries | 3 | 400 后的降级重试次数 |
learnLimit | true | 是否从 400 响应中解析上游上限 |
dryRun | false | 仅观察,不修改任何请求 |
matchPath | /chat/completions|/messages | 处理的路径(正则) |
markerLang | 空(跟随界面语言) | 标记语言:留空跟随宿主界面语言,zh / en 为固定值;决定默认模板与标记正文(身份、取回提示)的语言 |
placeholder | 空 | 标记模板;留空或等于某语言默认模板 = 用生效语言的默认模板(zh → [图片已省略 #{index}{identity}{hint}],en → [image omitted #{index}{identity}{hint}]) |
pathMode | basename | full / relative / basename / none |
tokensPerImage | 972 | 估算节省量所用的单张图片视觉 token 数(0 表示不估算) |
verbose | true | 是否输出日志 |
插件在本机只读三处文件:配置 ~/.dsh/image-guard.json、状态 ~/.dsh/image-guard-status.json,以及宿主 ~/.dsh/settings.yaml 中的 locale.preference(仅用于决定默认标记语言,读不到即按中文)。除此之外不发起任何外发请求,凭据不读取、不上报。