VanturaAgent class
Agent that interacts with the Vantura API and uses tools.
Manages conversation memory, executes tool calls, and handles API responses.
Constructors
-
VanturaAgent({required String instructions, required VanturaMemory memory, required List<
VanturaTool> tools, required LlmClient client, required VanturaState state, String name = 'default_agent', String description = 'General assistant agent', void onToolError(String toolName, String error, StackTrace? stackTrace)?, void onAgentFailure(String error, StackTrace? stackTrace)?, void onWarning(String warning)?, bool redactPii = false, VanturaLogger? logger, List<VanturaObserver> ? observers}) - Creates an VanturaAgent with the specified components.
Properties
- client → LlmClient
-
Client for API communication.
final
- description → String
-
Clear description of what this agent does, for routing decisions.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- instructions → String
-
System instructions for the agent.
final
- logger → VanturaLogger
-
Logger instance for agent operations.
final
- memory → VanturaMemory
-
Memory storage for conversation history.
final
- name → String
-
Internal name for identifying this agent in multi-agent routing.
final
-
observers
→ List<
VanturaObserver> -
List of observers for tracing and observability.
final
- onAgentFailure → void Function(String error, StackTrace? stackTrace)?
-
Callback when the overall agent execution fails.
final
- onToolError → void Function(String toolName, String error, StackTrace? stackTrace)?
-
Callback when a tool execution fails.
final
- onWarning → void Function(String warning)?
-
Callback for non-fatal warnings during execution.
final
- redactPii → bool
-
Controls whether PII (emails, phone numbers) should be redacted before sending to LLM.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- state → VanturaState
-
State manager for UI synchronization.
final
-
tools
→ List<
VanturaTool> -
List of available tools.
final
Methods
-
addTool(
VanturaTool tool) → void - Adds a tool dynamically at runtime (e.g. injected by AgentCoordinator).
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
resume(
AgentStateCheckpoint checkpoint, {CancellationToken? cancellationToken}) → Stream< VanturaResponse> -
Resumes a previously interrupted agent run using the provided checkpoint.
Requires that
memory.persistenceis configured and chat history is loaded. -
run(
String prompt, {Map< String, dynamic> ? config, CancellationToken? cancellationToken}) → Future<VanturaResponse> -
Runs the agent with the given prompt.
You can optionally pass a
cancellationTokento stop the generation early. -
runStreaming(
String? prompt, {Map< String, dynamic> ? config, CancellationToken? cancellationToken, AgentStateCheckpoint? resumeFrom}) → Stream<VanturaResponse> -
Runs the agent with the given prompt and streams the response.
You can optionally pass a
cancellationTokento stop the generation early. IfresumeFromis provided, the loop skips adding the prompt to memory and resumes from the provided checkpoint's iteration. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- maxPromptLength → const int
- Maximum allowed length for a user prompt (100KB).