AgentsMiddleware class

Middleware that enables delegating tasks to registered sub-agents.

A fresh instance is created per generate() call, so the mutable state (delegation count, invocation sequence, captured conversation, task caches) is naturally scoped to a single generation.

Concurrency note: unlike the Go port this needs no mutex. Dart runs one isolate, so the shared counters mutate atomically between await points; parallel tool calls interleave only at those points, and the reserve/release bookkeeping is written to be correct across them.

Constructors

AgentsMiddleware(AgentsOptions options, GenkitAI _ai)

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
tools → List<Tool>
Middleware can act as a "kit" by providing tools directly. These tools will be added to the tool list of the generate call.
no setter

Methods

generate(GenerateTurnState envelope, ActionFnArg<ModelResponseChunk, GenerateActionOptions, void> ctx, Future<GenerateResult> next(GenerateTurnState envelope, ActionFnArg<ModelResponseChunk, GenerateActionOptions, void> ctx)) → Future<GenerateResult>
Middleware for the top-level generate call.
model(ModelRequest request, ActionFnArg<ModelResponseChunk, ModelRequest, void> ctx, Future<ModelResponse> next(ModelRequest request, ActionFnArg<ModelResponseChunk, ModelRequest, void> ctx)) → Future<ModelResponse>
Middleware for the raw model call.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
tool(ToolRequestPart request, ActionFnArg<void, dynamic, void> ctx, Future<ToolResult> next(ToolRequestPart request, ActionFnArg<void, dynamic, void> ctx)) → Future<ToolResult>
Middleware for tool execution.
inherited
toString() → String
A string representation of this object.
inherited

Operators

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