Interface IAgent
Represents an agent within the runtime that can process messages, maintain state, and be closed when no longer needed.
public interface IAgent : ISaveState
- Inherited Members
Properties
Id
Gets the unique identifier of the agent.
AgentId Id { get; }
Property Value
Metadata
Gets metadata associated with the agent.
AgentMetadata Metadata { get; }
Property Value
Methods
OnMessageAsync(object, MessageContext)
Handles an incoming message for the agent. This should only be called by the runtime, not by other agents.
ValueTask<object?> OnMessageAsync(object message, MessageContext messageContext)
Parameters
message
objectThe received message. The type should match one of the expected subscription types.
messageContext
MessageContextThe context of the message, providing additional metadata.
Returns
- ValueTask<object>
A task representing the asynchronous operation, returning a response to the message. The response can be
null
if no reply is necessary.
Exceptions
- OperationCanceledException
Thrown if the message was cancelled.
- CantHandleException
Thrown if the agent cannot handle the message.