Agent class

Runs a model in a loop, executing the tools it asks for.

Constructors

Agent({required ToolCallingModel model, required List<Tool> tools, String? system, int maxSteps = 8, int? maxTokens, void onStep(AgentStep step)?})
Creates an agent.

Properties

hashCode → int
The hash code for this object.
no setterinherited
maxSteps → int
Most model round trips in one run. Each round trip may call several tools; the bound is what stops a confused model from spinning.
final
maxTokens → int?
Output limit per round trip.
final
model → ToolCallingModel
The model. Must support tool calling.
final
onStep → void Function(AgentStep step)?
Called after each tool runs, for logging or a progress indicator.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
system → String?
Instructions prepended to every request.
final
tools → List<Tool>
Tools the model may call.
final

Methods

continueRun(List<ChatMessage> transcript) → Future<AgentRun>
Continues an existing transcript (e.g. from a previous AgentRun).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
run(String task, {List<ChatMessage> history = const []}) → Future<AgentRun>
Answers task, calling tools as the model asks.
toString() → String
A string representation of this object.
inherited

Operators

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