Overview
Solace Agent Mesh agents follow a structured lifecycle from initialization through execution to shutdown. Understanding this lifecycle is essential for building robust agents and custom extensions.Lifecycle Phases
1. Initialization Phase
When an agent starts, the following initialization sequence occurs:Configuration Loading
The agent loads its YAML configuration and validates all required parameters:Service Initialization
The agent initializes core services in order:- Broker Connection: Establishes connection to Solace message broker
- Session Service: Initializes conversation history storage
- Artifact Service: Sets up file/artifact storage backend
- ADK Agent: Creates the Google ADK agent instance
Tool Registration
Tools are loaded and registered with the ADK agent:2. Running Phase
During normal operation, the agent processes incoming requests:Message Reception
The agent listens for A2A protocol messages on its request topic:Request Processing Flow
Task Execution
Each incoming request creates a task execution context:ADK Runner Execution
The core execution loop is handled by the ADK runner:3. Callback Execution
Callbacks intercept and modify agent behavior at key points:Before Model Call
After Model Call
Tool Execution
4. Context Window Management
The agent automatically manages context window limits:Auto-Summarization
When context limit is reached, the agent automatically summarizes old messages:Progressive Summarization
Each new summary incorporates the previous summary, keeping context bounded:5. Finalization Phase
After task completion or on error, the agent finalizes the task:6. Shutdown Phase
When the agent receives a shutdown signal:Error Handling
Context Limit Errors
When the LLM returns a context limit error:Task Cancellation
When a task is cancelled:LLM Call Limit Exceeded
Session Management
Persistent Sessions
For conversational agents:session_id.
Run-Based Sessions
For stateless agents:Performance Considerations
Parallel Task Execution
Agents can handle multiple concurrent requests:Streaming Optimization
Streaming responses reduce latency:Resource Cleanup
Proper cleanup prevents memory leaks:Monitoring and Debugging
Lifecycle Logging
Each phase logs detailed information:Task State Inspection
See Also
- Agent Configuration - Configure agent behavior
- Agent Callbacks - Customize lifecycle with callbacks
- Tool Development - Create tools that integrate with lifecycle