FunctionTool class

Wraps a Dart callable as a runtime tool.

Inheritance

Constructors

FunctionTool({required Function func, String? name, String? description, Object requireConfirmation = false, List<String>? toolContextParamNames})
Creates a function-backed tool.

Properties

customMetadata Map<String, dynamic>?
Arbitrary metadata attached to this tool declaration.
getter/setter pairinherited
defersResponse bool
Whether response event creation is handled by framework code elsewhere.
getter/setter pairinherited
description String
Human-readable purpose text shown to the model.
getter/setter pairinherited
func Function
Target function invoked when the tool is called.
final
hashCode int
The hash code for this object.
no setterinherited
isLongRunning bool
Whether the tool can outlive a single response turn.
getter/setter pairinherited
name String
Unique tool name used in function-calling payloads.
getter/setter pairinherited
requireConfirmation Object
Confirmation policy for this tool call.
final
responseScheduling FunctionResponseScheduling?
Live response scheduling policy for this tool.
getter/setter pairinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
toolContextParamNames List<String>
Named parameter candidates used for ToolContext injection.
final

Methods

detectErrorInResponse(Object? response) String?
Returns a telemetry error type when response represents a tool error.
override
getDeclaration() FunctionDeclaration?
Returns a simple declaration derived from name and description.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
processLlmRequest({required ToolContext toolContext, required LlmRequest llmRequest}) Future<void>
Mutates outgoing llmRequest before model generation.
inherited
run({required Map<String, dynamic> args, required ToolContext toolContext}) Future<Object?>
Runs the wrapped function with argument-shape fallbacks.
override
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited