Synchronous Execution
The simplest way to run an agent is using thedo() method, which executes synchronously and returns the result.
List Input (Multiple Tasks)
do(), do_async(), print_do(), and print_do_async() accept a list of strings or a list of Task objects. They run each item in sequence and return a list of string results. A single-element list returns a single string (scalar); an empty list returns an empty list. Mixed lists of str and Task are supported.
List of strings
List of Task objects
Asynchronous Execution
For concurrent operations or async applications, usedo_async() which returns a coroutine.
Streaming Text Output
For real-time output, usestream() to get responses as they’re generated.
Event Streaming
For full visibility into agent execution, useastream() (or stream() for synchronous code) with events=True to receive detailed events about every step of the pipeline.
Event Categories
Pipeline Events
| Event | Description | Key Attributes |
|---|---|---|
PipelineStartEvent | Emitted when execution begins | total_steps, is_streaming, task_description |
PipelineEndEvent | Emitted when execution ends | total_steps, executed_steps, total_duration, status, error_message |
Step Events
| Event | Description | Key Attributes |
|---|---|---|
StepStartEvent | Emitted when a step begins | step_name, step_index, step_description, total_steps |
StepEndEvent | Emitted when a step ends | step_name, step_index, status, execution_time, message |
Tool Events
| Event | Description | Key Attributes |
|---|---|---|
ToolCallEvent | Emitted when a tool is called | tool_name, tool_call_id, tool_args, tool_index |
ToolResultEvent | Emitted when a tool returns | tool_name, tool_call_id, result, result_preview, execution_time, is_error, error_message |
ExternalToolPauseEvent | Emitted when execution pauses for external tool | tool_name, tool_call_id, tool_args |
LLM Stream Events
| Event | Description | Key Attributes |
|---|---|---|
TextDeltaEvent | Text chunk during streaming | content, accumulated_content, part_index |
TextCompleteEvent | Text streaming complete | content, part_index |
ThinkingDeltaEvent | Reasoning content (for supported models) | content, part_index |
ToolCallDeltaEvent | Tool call arguments streaming | tool_name, tool_call_id, args_delta, part_index |
FinalOutputEvent | Final output ready | output, output_type |
Initialization & Model Events
| Event | Description | Key Attributes |
|---|---|---|
AgentInitializedEvent | Agent initialized for execution | agent_id, is_streaming |
StorageConnectionEvent | Storage connection established | storage_type, is_connected, has_memory, session_id |
LLMPreparedEvent | LLM manager prepared | default_model, requested_model, model_changed |
ModelSelectedEvent | Model selected for execution | model_name, provider, is_override |
ToolsConfiguredEvent | Tools configured for the task | tool_count, tool_names, has_mcp_handlers |
MessagesBuiltEvent | Request messages built | message_count, has_system_prompt, has_memory_messages, is_continuation |
ModelRequestStartEvent | Model request starting | model_name, is_streaming, has_tools, tool_call_count, tool_call_limit |
ModelResponseEvent | Model response received (non-streaming) | model_name, has_text, has_tool_calls, tool_call_count, finish_reason |
Context & Input Build Events
These fire once per run as the agent assembles the request sent to the model. Useful for inspecting what the model actually receives (history size, prompt length, attached media).| Event | Description | Key Attributes |
|---|---|---|
MemoryPreparedEvent | Memory manager preparation finished | memory_enabled, history_count |
ChatHistoryLoadedEvent | Chat history loaded; run boundary marked | history_count |
SystemPromptBuiltEvent | System prompt assembled | prompt_length, has_culture, has_skills |
ContextBuiltEvent | Task context assembled (RAG + prior outputs) | context_length, has_knowledge_base, has_prior_outputs |
UserInputBuiltEvent | User input assembled (text + media) | input_type, has_images, has_documents, input_length |
Cache Events
| Event | Description | Key Attributes |
|---|---|---|
CacheCheckEvent | Cache checked for existing response | cache_enabled, cache_method, cache_hit, similarity, input_preview |
CacheHitEvent | Cache hit occurred | cache_method, similarity, cached_response_preview |
CacheMissEvent | Cache miss occurred | cache_method, reason |
CacheStoredEvent | Response stored in cache | cache_method, duration_minutes |
Policy Events
| Event | Description | Key Attributes |
|---|---|---|
PolicyCheckEvent | Policy validation performed | policy_type, action, policies_checked, content_modified, blocked_reason |
PolicyFeedbackEvent | Policy feedback for retry | policy_type, feedback_message, retry_count, max_retries, violated_policy |
Memory, Reflection & Reliability Events
| Event | Description | Key Attributes |
|---|---|---|
MemoryUpdateEvent | Memory updated | messages_added, memory_type |
ReflectionEvent | Reflection processing applied | reflection_applied, improvement_made, original_preview, improved_preview |
ReliabilityEvent | Reliability layer processing | reliability_applied, modifications_made |
ExecutionCompleteEvent | Execution complete | output_type, has_output, output_preview, total_tool_calls, total_duration |
Run Lifecycle Events
| Event | Description | Key Attributes |
|---|---|---|
RunStartedEvent | Run started | agent_id, task_description |
RunCompletedEvent | Run completed successfully | agent_id, output_preview |
RunPausedEvent | Run paused (for HITL requirements) | reason, requirements, step_name |
RunCancelledEvent | Run cancelled | message, step_name |
Common Attributes
All events inherit fromAgentEvent and share these base attributes:
| Attribute | Type | Description |
|---|---|---|
event_id | str | Unique identifier (8 chars) |
run_id | Optional[str] | The agent run ID this event belongs to (matches Agent.run_id) |
timestamp | datetime | When the event occurred |
event_type | str | Class name of the event (property, not a field) |
event_kind | str | Event category identifier |
Synchronous Event Streaming
For synchronous code, usestream() with events=True:
stream() method returns an iterator that yields either:
strchunks whenevents=False(default) - for text streamingAgentStreamEventobjects whenevents=True- for event streaming
astream() with the same events parameter.
Tool Management
Tools can be added to agents during initialization or dynamically usingadd_tools(). Use get_tool_defs() to retrieve all registered tool definitions.

