The AgentOpera message system provides the communication infrastructure that powers agent interactions within the platform. Built on Pydantic models for type safety and serialization support, the system enables structured and versatile exchanges between agents, tools, and human users.
# User sends a query
user_msg = TextMessage(content="What's the stock performance of ACME Corp?", source="User")
# Agent processes query and executes a tool
# (internally generates ToolCallRequestEvent and ToolCallExecutionEvent)
# Agent responds with analysis including a chart
response = MultiModalMessage(
content=[
"ACME Corp stock has grown 12% YTD. Here's the trend:",
stock_chart_image
],
source="FinancialAgent"
)