Skip to main content

Module helpers

Module helpers 

Source
Expand description

Miscellaneous helper functions.

Structs§

FinalizedToolCall
Finalized tool call with result.

Functions§

create_tool_result_message
Create a tool result message from a finalized tool call.
extract_tool_calls
Extract tool calls from an assistant message.
sanitize_orphaned_tool_results
Remove orphaned ToolResult messages and orphaned ToolCall blocks from Assistant messages.
should_stop_after_turn
Check if the loop should stop after a turn due to external cancellation.
should_terminate_batch
Check if a batch of finalized tool calls should terminate the loop. pi-mono: ALL finalized results must have terminate === true for the batch to terminate. This is the unanimous consent pattern.