Skip to main content

Module cancellation

Module cancellation 

Source
Expand description

Keeps a turn that the client abandoned from losing what it had already streamed.

Structs§

GuardedStream 🔒
Ties a turn’s cancellation guard to its response stream, so cleanup runs when the client drops the stream rather than whenever the turn’s driver function returns.
RequestCancelledGuard 🔒

Functions§

clean_up_abandoned_turn 🔒
Cleans up after a turn the client abandoned mid-stream: answers the tool calls it left without an output, then deletes the response message if it never received any text, or saves the text it did receive as its (incomplete) answer.
save_partial_answer 🔒
Saves text as the (incomplete) answer of the message message_id already names, billed for used_tokens.