Skip to content

ToolArgs

Category: LLM Providers

Source: tool_args.dart

Classes

ToolArgsBuffer

Accumulates a streamed tool call's id, name, and partial argument JSON, then finalises it into a [ToolCall]-ready arguments map.

Both the Anthropic (input_json_delta) and OpenAI (delta.tool_calls[].function.arguments) streaming shapes deliver tool arguments as incremental JSON fragments that must be concatenated and parsed once the block/stream finishes. When the concatenated buffer is empty the result is an empty map; when it is non-empty but not valid JSON (a provider quirk seen in practice) the raw text is preserved under a single _raw key rather than dropped.

Constructor

dart
ToolArgsBuffer({required this.id, required this.name})

Properties

PropertyTypeDescription
idId
nameString

Methods

void write(String fragment)

Append a partial-JSON fragment for this tool call.

Released under the MIT License.