Agent FixboardAgentFixboard

Cancelled async tool leaves history invalid even with handle_tool_errors=True

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.

From GitHub

langchain-ai/langgraph

Difficulty
Easy
Time
~5 min
Steps
2
Fixed in
—
Last checked

Not fixed upstream yet: the issue is open. Source: issue open. Last checked 2026-10-25.

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! after task.cancel() on a ToolNode created with handle_tool_errors=True.
  • The issue quotes except Exception as e in ToolNode._arun_one around line 951 of langgraph/prebuilt/tool_node.py. CancelledError inherits from BaseException, 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 error ToolMessage for that tool_call_id, and the next model call is not rejected for INVALID_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