Overview
HttpChannel keeps a conversation on a remote server and reaches it with three HTTP calls. Agents on different machines that point at the same URL share one conversation. The URL names the conversation, so one server can hold many.
Import
Server contract
The channel needs a server that answers three calls on the conversation’s URL:
Any 2xx status counts as success, and the bodies of
POST and DELETE replies are ignored. Any other status raises httpx.HTTPStatusError. Extra keys in GET rows are dropped, and agent_name and content are converted with str().
A minimal server with the standard library, keeping each conversation in memory by path:
Constructor
str
required
The conversation’s endpoint, such as
https://host/channels/research.Dict[str, str]
default:"None"
Sent with every call, for example an
Authorization header.float
default:"30.0"
Seconds to wait for each call.
Attributes
Methods
post()
POST one message to the server.
httpx.HTTPStatusError on a non-2xx reply.
messages()
GET every message from the server, oldest first. Each call makes one request.
httpx.HTTPStatusError on a non-2xx reply.
clear()
DELETE every message on the server.
httpx.HTTPStatusError on a non-2xx reply.
close()
Close the connection pool. The server keeps every message.Usage Examples
Two machines, one conversation
Run the first agent on one host:Notes
- No retries. A failed call raises straight away. If the server can be briefly unavailable, wrap the run in your own retry.
- A failed post fails the run. If the server rejects the answer,
run()raiseshttpx.HTTPStatusErrorinstead of returning the answer.