async_tool_cancellation

Constants for the built-in async tool cancellation feature.

A function registered with cancellable_by_llm=True is advertised alongside a cancel tool named for it, built here, and the instructions below are composed into the system instruction — so the LLM can drop work whose result is no longer wanted. A tool that doesn’t opt in has no cancel tool at all.

A single running call is stopped without arguments. Telling several calls of one tool apart takes the tool_call_id the conversation already carries, on the message that reported each call running.

pipecat.utils.async_tool_cancellation.cancel_tool_name(function_name: str) → str[source]

Name of the tool that cancels calls of function_name.

Parameters:

function_name – The cancellable tool.

Returns:

The built-in cancel tool’s name, e.g. cancel_write_report.

pipecat.utils.async_tool_cancellation.build_cancel_tool_schema(function_name: str) → FunctionSchema[source]

Build the cancel tool for one cancellable tool.

Which work to stop is carried by the tool the model picks, so a single running call is stopped without arguments. tool_call_id only has to be given to choose between several calls of the same tool, and the handler refuses with the ids when it is needed and missing.

Parameters:

function_name – The tool whose calls this one cancels.

Returns:

The schema to advertise alongside function_name.