Symptom
Cancelling a tool task raises asyncio.CancelledError and leaves an assistant message with tool_calls and no ToolMessage. The issue says the next model call then fails with INVALID_CHAT_HISTORY.
Evidence what you'll see
- The report's script prints
CancelledError raised - no ToolMessage created!aftertask.cancel()on aToolNodecreated withhandle_tool_errors=True. - The issue quotes
except Exception as einToolNode._arun_onearound line 951 oflanggraph/prebuilt/tool_node.py.CancelledErrorinherits fromBaseException, so that handler does not run.
Why it happens
handle_tool_errors only wraps Exception. A cancel is a BaseException, so no error ToolMessage is written and the tool call stays unmatched.
Affected versions
langgraph 1.0.7, also confirmed by the report on 0.5.4, Python 3.11. The linked issue does not name an operating system.
Fix steps
0 of 2 done
Your check marks stay in this browser only.
How to check it worked
- After the tool raises
Exception, the history contains an errorToolMessagefor thattool_call_id, and the next model call is not rejected forINVALID_CHAT_HISTORY.
If it still fails
- The linked issue does not include a released change. A cancel still skips the handler on the versions named above.
Sources and credit
Summarized in our own words from these public reports. Credit goes to their authors.
Provided as is, without warranty. Try changes in a non-production environment and back up first. Security-related steps: verify against the official docs. Terms · Request removal or attribution change
Hit an error we don't cover? Submit it