Skip to content
3 min read · 586 words

Class: ToolCall

Defined in: lib/classes/tool_call.ts:225

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

ts
new ToolCall(raw: RawToolCall): ToolCall;

Defined in: lib/classes/tool_call.ts:306

Parameters

ParameterTypeDescription
rawRawToolCallThe 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

PropertyModifierTypeDefault valueDescriptionDefined in
argsreadonlyRecord<string, unknown>undefinedArguments the model supplied for this tool call, always as a plain object.lib/classes/tool_call.ts:253
checksumreadonlystringundefinedIntegrity checksum over tool and args.lib/classes/tool_call.ts:255
completedAtreadonlyDateTimeundefinedWhen the tool call completed.lib/classes/tool_call.ts:287
createdAtreadonlyDateTimeundefinedWhen this tool call was first created.lib/classes/tool_call.ts:283
fromArtifactToolreadonlybooleanundefinedtrue 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.lib/classes/tool_call.ts:276
idreadonlystringundefinedStable unique identifier for this tool call; correlates the request with its result.lib/classes/tool_call.ts:249
inlinereadonlybooleanundefinedtrue (default) renders this tool call's result inline in the prompt; false instructs LLM adapters to surface the result as a handle reference. See RawToolCall.inline.lib/classes/tool_call.ts:281
isCompletereadonlybooleanundefinedtrue once the tool call has finished (successfully or not).lib/classes/tool_call.ts:257
isErrorreadonlybooleanundefinedtrue when the tool execution produced an error; inspect results for detail.lib/classes/tool_call.ts:259
resultsreadonlyToolCallResultsundefinedResult 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).lib/classes/tool_call.ts:270
toolreadonlystringundefinedName of the tool the model has requested.lib/classes/tool_call.ts:251
updatedAtreadonlyDateTimeundefinedWhen this tool call was last modified.lib/classes/tool_call.ts:285
schemastaticObjectSchema<RawToolCall>rawToolCallSchemaValidator schema that accepts a RawToolCall object. Remarks Reusable fragment for any schema that needs to validate or nest a tool call entry.lib/classes/tool_call.ts:232

Methods

isToolCall()

ts
static isToolCall(value: unknown): value is ToolCall;

Defined in: lib/classes/tool_call.ts:244

Returns true if value is a ToolCall instance.

Parameters

ParameterTypeDescription
valueunknownThe 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.