rea
morluto
Reverse engineer anything with agents, from app behavior down to native binaries.
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:alchemistwu/dsh-tool-call-guard
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
English | 中文
Neutralize tool calls with invalid JSON arguments before they reach the wire — so one malformed model generation cannot brick an entire session.
dsh plugin add dsh-tool-call-guard
Some models occasionally emit a tool call whose arguments string is not valid JSON — most often unescaped inner quotes:
{"queries": [""The Idiots" trailer youtube official"]}
Strict OpenAI-compatible servers (vLLM and friends) are asymmetric about this:
400 {"message": "Assistant tool call function.arguments must be valid JSON.",
"type": "BadRequestError"}
From that moment, every subsequent request in the session fails. The session is bricked until its log is surgically repaired by hand. The same failure class exists across ecosystems (openai-agents-python #2061, vLLM #41122).
Intercepts the harness's llm/stream waterfall. For every assistant tool-call block whose arguments fail JSON.parse:
[A tool call to 'web_search' was removed from history because its arguments
were malformed JSON. Original arguments as emitted: {"queries": [""The Idiots" …]}]
tool_calls entry, no orphan role:"tool" reply — each of those is itself a 400 on strict servers):[Tool Result: web_search] 10 results about The Idiots
The orphaned-result-as-user-message pattern follows the upstream serializer discussion (deepseek-harness #4668).
JSON.parse per tool-call block; messages array passes through with object identity when nothing is wrong.llm/stream, so every adapter (deepseek, community, custom) is covered.dsh plugin --profile web add dsh-tool-call-guard
# or desktop:
dsh plugin --profile desktop add dsh-tool-call-guard
Or from GitHub: dsh plugin add github:alchemistwu/dsh-tool-call-guard.
The package declares a dsh.bundle patch, so the plugin self-registers on install. Restart your dsh web / DSH Desktop host, then start a new session.
First observed with zai-org/GLM-5.3-Flash served by vLLM 0.27 (--enable-auto-tool-choice): one web_search call with unescaped quotes around a film title streamed through fine, was persisted, and permanently poisoned the session with 400 … arguments must be valid JSON on every later turn. This plugin keeps that session alive: the poisoned entry is re-expressed per-request, the session continues working, and the model sees its own mistake in context.
npm test
Nine tests cover the exact production poison, mixed valid/invalid tool calls, protocol-balance invariants (no invalid tool_calls and no orphan role:"tool" on the wire), degenerate inputs, and per-request state reset.
MIT
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: llm、model、openai。