Bug + tested fix: truncated tool-call arguments permanently poison a session (llm-deepseek serializer) #1519
Replies: 2 comments
|
截断在 tool-call arguments 中间 → 永久污染会话——和 #739(reasoning 序列化省略)、#725/#1405(空 delta 覆盖)都是 llm-deepseek 序列化层的边界问题,rc 期这层 bug 集中爆发。 你带了测试修复很好,建议和 #739 合并成一份序列化层 bug 汇总给官方。手册侧我们把这批序列化坑都收进第 6 章坑位 + FAQ:https://github.com/Electricitysheep/dsh-handbook/blob/main/docs/06-advanced.md |
|
Confirmed against master, and your fix targets the right spot. This is the second distinct poisoning path in the same file — worth bundling with #1449. Source confirmation
const toolCalls = message.content
.filter(block => block.type === 'tool-call')
.map(block => ({
id: block.id,
type: 'function' as const,
function: { name: block.name, arguments: block.arguments },
}))
Same file, second poison pathThe same
Both are "content the server rejects → durably in the log → every later turn fails" — the same family as #1337's dangling On the fix
|
Uh oh!
There was an error while loading. Please reload this page.
The bug: when a tool call'''s generation is truncated mid-arguments (or the model emits malformed JSON),
serializeAssistantinpackages/llm/llm-deepseek/src/serialize.tsreplaysblock.argumentsverbatim on every subsequent turn. Servers that re-parse tool calls while rendering the chat template then reject every later request of that session — vLLM withExpecting '\'','\'' delimiterand llama.cpp with[json.exception.parse_error.101]— so no retry can ever succeed and the session is permanently stuck in an error loop. Observed in production with a ~13.6k-char subagent tool call truncated mid-string.The fix (tested): validate arguments with
JSON.parseat serialization and substitute"{}"when unparsable; valid arguments pass through untouched. The paired tool result already records what happened, and previously-poisoned sessions become usable again on their next request.Since PRs and issues appear to be closed on this repo, the full change (plus a regression test in
tests/serialize.spec.ts; suite passes 28/28) is on this branch:https://github.com/brianmswheart/deepseek-harness/tree/fix/sanitize-replayed-tool-call-arguments — happy to reformat it however contributions are meant to flow.
Written with assistance from Claude Code.
All reactions