run method

Future<VanturaResponse> run(
  1. String prompt, {
  2. CancellationToken? cancellationToken,
})

Runs the overall system, routing through agents as needed.

Implementation

Future<VanturaResponse> run(
  String prompt, {
  CancellationToken? cancellationToken,
}) async {
  // Standard run using active agent
  final response = await activeAgent.run(
    prompt,
    cancellationToken: cancellationToken,
  );

  // If a transfer was requested during execution
  if (_pendingTransfer != null) {
    activeAgent = agents[_pendingTransfer]!;
    _pendingTransfer = null;

    // Optionally, we could immediately trigger the new agent to respond back
    // Since memory is shared, the new agent will see the history
    // We'll leave it simple for now: the NEXT user query goes to the new agent.
    // E.g., The original agent: "I am transferring you to X." (Tool called).
  }

  return response;
}