ToolResult class final

What a tool call answers: content for a model to read, and the machine-readable structuredContent when the tool declares an outputSchema.

A refusal is an answer, marked isError: the agent is told to try something else. An exception is the server failing, which is reported to the host as that.

Constructors

ToolResult({List<ToolContent> content = const <ToolContent>[], Map<String, Object?>? structuredContent, bool isError = false})
ToolResult.fromJson(Map<String, Object?> json)
Reads the protocol's result object.
factory
ToolResult.text(String text, {bool isError = false})
One sentence, as most tools answer.
factory

Properties

content → List<ToolContent>
final
hashCode → int
The hash code for this object.
no setterinherited
isError → bool
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
structuredContent → Map<String, Object?>?
final
text → String
The words of every ToolText, one per line.
no setter

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() → Map<String, Object?>
The protocol's result object.
toString() → String
A string representation of this object.
inherited

Operators

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