runAgentLoop function
Future<List<Message> >
runAgentLoop({
- required List<
Message> prompts, - required Context context,
- required AgentLoopConfig config,
- required StreamFunction streamFunction,
- required ToolExecutor toolExecutor,
- required AgentEventSink emit,
- CancelToken? cancelToken,
Starts an agent loop with new prompt messages, delivering events to
emit and resolving with the messages produced by the run.
This is the emit-based core beneath agentLoop (pi's runAgentLoop);
use it when events must be awaited as part of the run (the stateful
Agent does this for its listeners). Unlike agentLoop, exceptions
from emit or a TransformContextHook propagate to the caller instead
of being swallowed into a closed stream.
Implementation
Future<List<Message>> runAgentLoop({
required List<Message> prompts,
required Context context,
required AgentLoopConfig config,
required StreamFunction streamFunction,
required ToolExecutor toolExecutor,
required AgentEventSink emit,
CancelToken? cancelToken,
}) {
return _runAgentLoop(
prompts: prompts,
context: context,
config: config,
emit: emit,
streamFunction: streamFunction,
toolExecutor: toolExecutor,
cancelToken: cancelToken,
);
}