Documentation Index
Fetch the complete documentation index at: https://simplellmfunc.cn/llms.txt
Use this file to discover all available pages before exploring further.
Abort
AbortSignal provides cooperative cancellation for running agent invocations. It cleanly terminates LLM streaming and tool execution.
Basic Usage
What Happens on Abort
During LLM Streaming
- The streaming connection is terminated
- Whatever content was received so far is preserved
- The runtime produces an internal truncation patch with:
partial_content— what was received before abortabort_reason— the reason you provided
- The ReAct loop terminates via the finalize path
During Tool Execution
- Running tools are cancelled (asyncio task cancellation)
- For each cancelled tool, the runtime produces an internal cancellation patch with:
tool_call_id— which call was cancelledtool_name— the tool that was runningabort_reason— your reason
- This ensures the transcript stays structurally valid (every tool call has a result)
The Guarantee
Abort always produces a valid final state. The transcript is never left with dangling tool calls or incomplete messages. Internal transcript patches ensure structural consistency.Abort in @llm_function
Works the same way:TUI Integration
The built-in@tui decorator handles abort automatically — Ctrl+C triggers the signal: