Ask a question to get started
Enter to send•Shift+Enter new line
ToolCallBuffer( self, name: str | None = None, tool_id: str | None
The tool name, once a chunk has supplied it.
The tool-call id, once a chunk has supplied it.
A fully materialized arguments value delivered by a single chunk (dict or, rarely, a scalar). Mutually exclusive with args_parts (see __post_init__ and ingest).
args_parts
__post_init__
ingest
JSON string fragments accumulated across chunks, reassembled by parse_args once the payload looks complete. Mutually exclusive with args (see __post_init__ and ingest).
parse_args
args
One-shot latch guarding the single "Calling tool" console line (used only by the headless surface).
One-shot latch so a malformed-but-complete payload is logged at most once, even though parse_args re-runs on every later chunk for the retained buffer.
Fold one streamed tool-call chunk's fields into the buffer.
A dict args replaces any accumulated fragments (the provider delivered the whole value at once); a string args is appended as a fragment; any other non-None value is stored as-is.
None
Return the tool-call args once enough data has arrived, else None.
A non-object JSON value (a bare scalar or list — rare for tool calls) is wrapped as {"value": ...} so a caller's tool_args is always an object.
{"value": ...}
tool_args
In-progress state for a single streamed tool call.
args and args_parts are two representations of the arguments used one at a time, depending on whether the provider delivers the value whole or in JSON string fragments.