AbstractAgent
TheAbstractAgent class provides the foundation for all agent implementations
in the Agent User Interaction Protocol. It handles the core event stream
processing, state management, and message history.
Configuration
By default, all agents are configured by providing an optionalAgentConfig
object to the constructor.
Adding Configuration Options in your Subclass
To add additional configuration options, it is recommended to extend theAgentConfig interface and call the super constructor with the extended config
from your subclass like this:
Core Methods
runAgent()
The primary method for executing an agent and processing the result.Parameters
subscriber parameter allows you to provide an
AgentSubscriber for handling events during this
specific run.
Return Value
subscribe()
Adds an AgentSubscriber to handle events across multiple agent runs.unsubscribe() method to remove the subscriber when
no longer needed.
use()
Adds middleware to the agent’s event processing pipeline.- Function middleware: Simple functions that transform the event stream
- Class middleware: Instances of the
Middlewareclass for stateful operations
abortRun()
Cancels the current agent execution.clone()
Creates a deep copy of the agent instance.Properties
agentId: Unique identifier for the agent instancedescription: Human-readable descriptionthreadId: Conversation thread identifiermessages: Array of conversation messagesstate: Current agent state object