AgentLlmProvider class
Bridges an AIAgent into the chat UI's LlmProvider contract.
The provider keeps a lightweight UI transcript while sending agent-native
ai.ChatMessage values to the underlying agent.
When the agent's tool-approval middleware pauses a run on a
ai.ToolApprovalRequestContent, the request surfaces through
pendingToolApproval and the run resumes via sendToolApprovalStream.
- Inheritance
-
- Object
- LlmProvider
- AgentLlmProvider
- Implemented types
- Mixed-in types
Constructors
-
AgentLlmProvider({required AIAgent agent, AgentSession? session, AgentRunOptions optionsBuilder()?, ValueListenable<
String?> ? toolActivity, AppActivityMonitor? activity, AgentRunTelemetryStore? runs, Future<AgentRunHandle> beginRun(AgentRunTelemetryStore runs)?, Iterable<ChatMessage> ? history}) -
Creates a provider backed by an
AIAgent.
Properties
- activity → AppActivityMonitor?
-
Optional app-wide idle monitor; brackets each model turn so background
work can tell when a generation is in flight.
final
- agent → AIAgent
-
The core agent used to generate responses.
final
-
beginRun
→ Future<
AgentRunHandle> Function(AgentRunTelemetryStore runs)? -
Opens a run record for a turn about to start.
final
- currentRunId → String?
-
The id of the run in flight, or null between turns.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
-
history
↔ Iterable<
ChatMessage> -
Returns an iterable of
ChatMessageobjects representing the chat history.getter/setter pairoverride - isBusy → bool
-
Whether a turn is streaming or paused awaiting tool approval.
no setter
- optionsBuilder → AgentRunOptions Function()?
-
Optional factory for per-run options.
final
- pendingToolApproval → ToolApprovalRequest?
-
The unresolved approval request, if the last run stopped on one.
no setteroverride
- runs → AgentRunTelemetryStore?
-
The run ledger, when telemetry is enabled for this conversation.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- session → AgentSession?
-
Optional session to use for stateful agent runs.
final
-
toolActivity
→ ValueListenable<
String?> ? -
Live tool-activity label, when the app tracks it.
final
Methods
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
dispose(
) → void -
Discards any resources used by the object.
override
-
generateStream(
String prompt, {Iterable< Attachment> attachments = const []}) → Stream<String> -
Generates a stream of text based on the given prompt and attachments.
This method does not interact with a chat or build on any chat history.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
sendMessageStream(
String prompt, {Iterable< Attachment> attachments = const []}) → Stream<String> -
Generates a stream of text based on the given prompt and attachments.
Interacts with a chat and builds on the history of the chat associated
with the provider.
override
-
sendToolApprovalStream(
ToolApprovalDecision decision) → Stream< String> -
Answers pendingToolApproval with
decisionand resumes the run, streaming the continuation of the response text.override -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited