Skip to main content

AbstractAgent

The AbstractAgent 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 optional AgentConfig object to the constructor.

Adding Configuration Options in your Subclass

To add additional configuration options, it is recommended to extend the AgentConfig 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 receiving the event stream.

Parameters

abortRun()

Cancels the current agent execution.

clone()

Creates a deep copy of the agent instance.

Properties

  • agentId: Unique identifier for the agent instance
  • description: Human-readable description
  • threadId: Conversation thread identifier
  • messages: Array of conversation messages
  • state: Current agent state object

Protected Methods

These methods are meant to be implemented or extended by subclasses:

run()

Executes the agent and returns an observable event stream.

apply()

Processes events from the run and updates the agent state.

prepareRunAgentInput()

Prepares the input parameters for the agent execution.

onError() and onFinalize()

Lifecycle hooks for error handling and cleanup operations.