Repository navigation
Session permanently poisoned after a tool-dispatch crash: dangling tool_calls make every later request fail with 400 "insufficient tool messages"
#571
FIRST-1-CAT
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Session permanently poisoned after a tool-dispatch crash: dangling
tool_callsmake every later request fail with 400 "insufficient tool messages"Summary
In the web profile, when tool dispatch fails for any reason, the persisted conversation keeps the assistant message that contains
tool_callsbut no correspondingtoolresult. From then on, every request against that session is rejected by the API with HTTP 400INVALID_REQUEST:There is no self-healing: the session is permanently unusable and must be abandoned (new session required).
Environment
@deepseek-ai/dsh@0.1.0-rc.6(npm install)127.0.0.1:3080), bundles:@deepseek-ai/dsh-base,@deepseek-ai/dsh-web-app, plus community pluginsdsh-agent-loop@0.1.0-rc.6,dsh-tools@0.1.0-rc.6,cordis@4.0.1,cosmokit@1.8.2,schemastery@3.18.1deepseek-v4-flash)What happens (observed event sequence from a session log)
nocturne_boot+nocturne_search); anassistant/messagecontaining 2tool-callblocks is persisted (seq 258).tool/callfor the first call (seq 259).turn/end:{"reason":{"kind":"error","error":{"message":"Cannot read properties of undefined (reading 'prepare')","code":"UNKNOWN"}}}tool/resultis ever written for either call id.Root cause
The
tool/callrecord is appended to the session before dispatch begins (dsh-agent-loop/lib/index.js:191), and on a terminal scheduler failure (preparethrowing at:193, ordispatchrejecting) the loop throws without ever appending atool/result. In the current code this is a documented design choice β the module docblock states that "a terminal scheduler failure preserves already-recordedtool/callevents without fabricating results" β but its consequence is that the persisted conversation permanently violates the API's message invariant, and the session becomes unrecoverable: there is no repair or retry path.Note that the abort path does the opposite: skipped calls get synthetic error results (
"Error: tool call aborted before dispatch",appendSkippedToolCall,:257β290) specifically so replay stays valid. Mirroring that behavior for the terminal-failure path β synthesize an errortool/resultfor every started-but-unanswered call before throwing β or offering a repair/truncation path for danglingtool_calls, would resolve this. (Verified against the installed engine source:dsh-agent-loop/lib/index.js:88β106,:191β193,:252β290.)Important: this is independent of the duplicate-copy issue
This defect is not specific to the crash we report separately β ToolRuntime scheduler lookup silently returns
undefinedwhen multiple physical copies of@deepseek-ai/dsh-toolsexist in one process (Symbol-key mismatch) (companion post). Any dispatch failure β whatever the reason β leaves the session poisoned the same way, because the cleanup path is missing regardless of the failure cause.Expected behavior
tool/resultwhose content reports the failure), or otherwise repair the persisted history so the next request is valid.Impact
Permanent loss of a session (context lost, must create a new one). In the GUI, retrying in the poisoned session fails every time with no explanation or guidance.
Evidence
Affected sessions (web profile):
68d5a535,4d74d165,d73793d6,e371ca13,41b9c9d7,8ab28246β triggered byread,pwsh,skilland nocturne tools alike (not tool-specific). Full logs (zstd-framed JSONL,~/.dsh/sessions/) available on request.Workaround
Start a new session. Do not keep retrying in a poisoned one β it cannot recover.
All reactions