Class: ToolCall
Defined in: src/lib/classes/tool_call.ts:230
An immutable, validated tool call record associated with a turn.
Remarks
Represents a completed tool invocation from the conversation history — results, completedAt, isComplete, and isError are all present and required. Temporal fields are normalised to Luxon DateTime instances at construction time.
Constructors
Constructor
new ToolCall(raw: RawToolCall): ToolCall;Defined in: src/lib/classes/tool_call.ts:312
Parameters
| Parameter | Type | Description |
|---|---|---|
raw | RawToolCall | The raw tool call input validated against rawToolCallSchema. |
Returns
ToolCall
Throws
@nhtio/adk!E_INVALID_INITIAL_TOOL_CALL_VALUE when raw does not satisfy the schema.
Properties
| Property | Modifier | Type | Default value | Description | Defined in |
|---|---|---|---|---|---|
args | readonly | Record<string, unknown> | undefined | Arguments the model supplied for this tool call, always as a plain object. | src/lib/classes/tool_call.ts:258 |
checksum | readonly | string | undefined | Integrity checksum over tool and args. | src/lib/classes/tool_call.ts:260 |
completedAt | readonly | DateTime | undefined | When the tool call completed. | src/lib/classes/tool_call.ts:293 |
createdAt | readonly | DateTime | undefined | When this tool call was first created. | src/lib/classes/tool_call.ts:289 |
fromArtifactTool | readonly | boolean | undefined | true when this tool call originated from an @nhtio/adk!ArtifactTool invocation. Used by SpooledArtifact.forgeTools(ctx) to filter out forged-tool results from the callId enum it builds. | src/lib/classes/tool_call.ts:281 |
id | readonly | string | undefined | Stable unique identifier for this tool call; correlates the request with its result. | src/lib/classes/tool_call.ts:254 |
inline | readonly | boolean | undefined | false (default) instructs LLM adapters to surface a SpooledArtifact result as a handle reference (body kept out of the prompt); true renders the result inline. See RawToolCall.inline. | src/lib/classes/tool_call.ts:287 |
isComplete | readonly | boolean | undefined | true once the tool call has finished (successfully or not). | src/lib/classes/tool_call.ts:262 |
isError | readonly | boolean | undefined | true when the tool execution produced an error; inspect results for detail. | src/lib/classes/tool_call.ts:264 |
results | readonly | ToolCallResults | undefined | Result returned by the tool, or error detail when isError is true. Remarks One of three silos — see ToolCallResults. @nhtio/adk!SpooledArtifact or SpooledArtifact[] for normal text-output @nhtio/adk!Tool calls; @nhtio/adk!Media or Media[] for tool calls whose handler returned binary modality output; @nhtio/adk!Tokenizable for @nhtio/adk!ArtifactTool calls (see ToolCall.fromArtifactTool). | src/lib/classes/tool_call.ts:275 |
tool | readonly | string | undefined | Name of the tool the model has requested. | src/lib/classes/tool_call.ts:256 |
updatedAt | readonly | DateTime | undefined | When this tool call was last modified. | src/lib/classes/tool_call.ts:291 |
schema | static | ObjectSchema<RawToolCall> | rawToolCallSchema | Validator schema that accepts a RawToolCall object. Remarks Reusable fragment for any schema that needs to validate or nest a tool call entry. | src/lib/classes/tool_call.ts:237 |
Methods
[ENCODE_METHOD]()
ENCODE_METHOD: unknown;Defined in: src/lib/classes/tool_call.ts:409
Serialise this ToolCall into an @nhtio/encoder snapshot.
Returns
unknown
A RawToolCall-shaped snapshot.
Remarks
Emits a RawToolCall-shaped object. results is the live ToolCallResults union — a @nhtio/adk!Tokenizable, @nhtio/adk!SpooledArtifact(s), or @nhtio/adk!Media(s) — which the encoder recurses into; reader-backed results round-trip as handles (and throw @nhtio/adk!E_READER_NOT_DESCRIBABLE if a backing reader cannot describe itself). The args object and the producer-supplied checksum are emitted verbatim, so the constructor's checksum re-validation passes on decode. Round-trips via ToolCall.[DECODE_METHOD].
[DECODE_METHOD]()
static DECODE_METHOD: ToolCall;Defined in: src/lib/classes/tool_call.ts:432
Reconstruct a ToolCall from a ToolCall.[ENCODE_METHOD] snapshot.
Parameters
| Parameter | Type | Description |
|---|---|---|
data | unknown | The snapshot produced by ToolCall.[ENCODE_METHOD]. |
Returns
ToolCall
A fully-validated ToolCall.
isToolCall()
static isToolCall(value: unknown): value is ToolCall;Defined in: src/lib/classes/tool_call.ts:249
Returns true if value is a ToolCall instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
value | unknown | The value to test. |
Returns
value is ToolCall
true when value is a ToolCall instance.
Remarks
Uses @nhtio/adk!isInstanceOf for cross-realm safety — instanceof would fail for instances created in a different module copy or VM context.