[docs]@runtime_checkableclassAgent(Protocol):@propertydefmetadata(self)->AgentMetadata:"""Metadata of the agent."""...@propertydefid(self)->AgentId:"""ID of the agent."""...
[docs]asyncdefon_message(self,message:Any,ctx:MessageContext)->Any:"""Message handler for the agent. This should only be called by the runtime, not by other agents. Args: message (Any): Received message. Type is one of the types in `subscriptions`. ctx (MessageContext): Context of the message. Returns: Any: Response to the message. Can be None. Raises: asyncio.CancelledError: If the message was cancelled. CantHandleException: If the agent cannot handle the message. """...
[docs]asyncdefsave_state(self)->Mapping[str,Any]:"""Save the state of the agent. The result must be JSON serializable."""...
[docs]asyncdefload_state(self,state:Mapping[str,Any])->None:"""Load in the state of the agent obtained from `save_state`. Args: state (Mapping[str, Any]): State of the agent. Must be JSON serializable. """...
[docs]asyncdefclose(self)->None:"""Called when the runtime is closed"""...