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})
An answer of content and, when the tool declares an output schema, structuredContent, both copied unmodifiable. isError marks a refusal.
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>
What a model reads, in order: words, pictures, sounds, resources.
final
hashCode → int
The hash code for this object.
no setterinherited
isError → bool
Whether the answer is a refusal, which tells the agent to try something else, rather than a result.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
structuredContent → Map<String, Object?>?
The machine-readable answer, which fits the tool's outputSchema; null for a tool that answers in content alone.
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