Skip to main content
The RemoteAgent class provides a client-side proxy that mimics the local Agent interface while communicating with remote agents via HTTP. The connect() function creates these proxies easily.

Import

connect() Function

Create a connection to a remote agent, returning a RemoteAgent proxy.

Parameters

str
required
Full URL to the agent endpoint. The last part of the path is extracted as the agent_id. Examples: - “https://api.myapp.com/agents/researcher” - “https://lambda.execute-api.amazonaws.com/prod/worker
dict[str, str] | None
default:"None"
Optional HTTP headers for authentication or other purposes.

Returns

Examples


RemoteAgent Class

Constructor

Direct constructor (usually you’ll use connect() instead).

Parameters

HTTPTransport
required
HTTP transport instance for communication.
str
required
Agent ID to communicate with.

Properties

id

Returns the agent ID.

Methods

chat

Send a chat message to the remote agent.

Parameters

str
required
Chat message to send.
AbortSignal | None
default:"None"
Optional abort signal to cancel the request (not yet implemented).

Returns

Examples


stream

Stream a response from the remote agent, yielding chunks as they’re generated.

Parameters

str
required
Chat message to send.
AbortSignal | None
default:"None"
Optional abort signal (not yet implemented).

Returns

Examples


call

Returns a type-safe proxy for making fluent RPC calls to the remote agent.

Parameters

type[T] | None
default:"None"
Optional agent class for type hints. If provided, enables IDE autocomplete for that agent’s methods.

Returns

Examples


close

Close the underlying transport and clean up resources.

Examples


Complete Examples

Basic Client Usage

RPC Method Calls

Error Handling and Timeouts

Serverless Integration Examples

Streaming Example with Progress