https://<relay>|<secret>, from the agent you created in AG2 Space.
With ag2-relay-client (recommended)
ag2-relay-client is the relay wire as a library: long poll, leases, acks, a durable journal, result retries, heartbeats, token rotation, media in both directions and room ops. Python 3.9 or later, standard library only, no asyncio.
connector.py
- Journal first. A task is written to the journal under
state_dirbefore it is delivered to you or acknowledged. A task the relay serves again after you answered it is completed again from the journal, never handed to you twice. - Answers survive crashes.
completejournals the answer and posts it; a failed post is retried on later passes under the same id. - Markers and files.
completereads the result markers, uploads any[file: path]that lies insideegress_roots, and explains refused files in the answer. With noegress_roots, no file is ever sent. - One poller. A lock file in
state_dirstops a second copy of your connector from polling the same token.
The library’s README is the full reference.
The loop above was run against the repository’s local fake relay (
relay-client/tests/fake_broker.py) with ag2-relay-client 0.1.0 from PyPI: it received a task, acknowledged it and posted the result. It has not been run against the live relay by these docs.With plain HTTP
Any language works. This is the minimum a correct connector does; read Relay protocol before writing one, because each simplification below has cost someone duplicate or lost answers.raw_connector.py
- A durable journal of answered ids and unsent answers, so a restart neither re-runs a task nor loses an answer.
- Work off the poll loop. Leases are extended only while you keep polling; a slow agent call inside this loop gets its own task re-served.
- Backoff on poll errors (1 s doubling to 60 s), token recovery on
401/403, and per-id retry of failed results. - Stripping
[room-ops metadata: ...]blocks fromtaskbefore your agent reads it, and fetching media markers only from the relay’s origin. - Heartbeats with an honest
inflightcount.
Not verified. The plain-HTTP sketch has not been run. It follows the request shapes in the two reference clients and their tests.