ToolResult<Output> class sealed

The result returned by a tool's implementation function.

Construct with the dot-shorthand factories:

  • return .response(output) for a normal result.
  • return .response(output, parts: [...]) for a multipart result (images, media, etc.).
  • return .interrupt(data) to interrupt the generation loop.
Implementers

Constructors

ToolResult.interrupt([Object? data])
Interrupts the generation loop, bubbling the tool request back to the caller with the optional data payload.
factory
ToolResult.response(Output output, {List<Part>? parts, Map<String, dynamic>? metadata})
A normal tool response with structured output and optional multipart parts (images, media, etc.) and metadata.
factory

Properties

hashCode → int
The hash code for this object.
no setterinherited
hasInterrupt → bool
Whether this is a ToolInterruptResult that halted the generation loop.
no setter
hasResponse → bool
Whether this is a normal ToolResponseResult carrying structured output.
no setter
interruptData → Object?
The interrupt data payload of an interrupt result.
no setter
output → Output
The structured output of a normal tool response.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() → Map<String, dynamic>
Serializes this result to the multipart tool.v2 shape ({output, content?, metadata?} or {interrupt}). Used at the reflection boundary so the Dev UI can render tool results.
toString() → String
A string representation of this object.
inherited

Operators

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