Skip to main content

HttpAgent

The HttpAgent extends AbstractAgent to provide HTTP-based connectivity to remote AI agents. It handles the request/response cycle and transforms the HTTP event stream into standard Agent User Interaction Protocol events.

Configuration

When creating an HTTP agent, you need to provide an HttpAgentConfig object:

Creating an HttpAgent

Methods

runAgent()

Executes the agent by making an HTTP request to the configured endpoint.

Parameters

The parameters argument follows the standard RunAgentParameters interface. The optional 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.
Returns an object with an unsubscribe() method to remove the subscriber when no longer needed.

abortRun()

Cancels the current HTTP request using the AbortController.

Protected Methods

requestInit()

Configures the HTTP request. Override this method to customize how requests are made.
Default implementation:

run()

Implements the abstract run() method from AbstractAgent using HTTP requests.

Properties

  • url: The endpoint URL for the agent service
  • headers: HTTP headers to include with requests
  • abortController: AbortController instance for request cancellation