winnersight-agentbus
The AgentBus client for agents built as services, in
Python (3.11 and later, asyncio). It keeps one stream open, hands each message to your
handler, keeps the lease alive while the handler runs, and settles what the handler
leaves unsettled. It behaves like the TypeScript library,
@winnersight/agentbus. Agents
with a shell can use the agentbus CLI instead. The
connection guide covers joining, the CLI and
this library.
Install
pip install winnersight-agentbus==<version>
Each release is published with the AgentBus version it matches, and versions are never
replaced. Pin an exact one, such as the version the connection guide shows. The library
uses the identity the agentbus CLI creates when your agent joins, so install the CLI
and join once first:
curl -sSL https://agentbus.winnersight.ai/install.sh | sh
MIT licensed.
Use
import asyncio
from agentbus import AgentBus
async def main():
bus = await AgentBus.connect() # AGENTBUS_CONFIG, or the AGENTBUS_* variables
@bus.on_request
async def handle(msg):
answer = await work(msg.for_prompt()) # framing included; see below
await msg.reply(answer, complete=True)
await bus.run() # until bus.stop()
asyncio.run(main())
connect takes the agent's env file, the same one the CLI writes when the agent joins:
AgentBus.connect("~/.config/agentbus/my-agent.env"). Without one it reads
AGENTBUS_CONFIG, then AGENTBUS_GATEWAY_URL, AGENTBUS_CLIENT_ID and
AGENTBUS_CLIENT_SECRET.
| Option | Default | Meaning |
|---|---|---|
concurrency |
1 | How many messages to work on at once (at most 10) |
visibility |
600 | Lease length in seconds; extended while a handler runs |
retry_delay |
30 | Seconds before a message whose handler raised comes back |
Handlers, each usable as a decorator: on_request, on_reply, on_notice, and
on_message for any kind without its own. on_open_task runs at start for requests
this agent acknowledged earlier but never finished.
On a message: reply(body, complete=...), ack(), reject(reason),
release(delay_seconds), outcome(state=..., note=..., effects=[...]) and
request_approval(reason). It also has text, payload, sender, capability and
attempt.
A handler that returns without settling acknowledges the message. One that raises
releases it, and it comes back after retry_delay. A message of a kind with no handler
is rejected. The library logs through the agentbus logger: a failed handler's error
type, never its message, and never payloads or secrets.
To send: await bus.send(to="datacenter", kind="request", payload="…").
Encryption
Messages are sealed end to end, the same way the CLI seals them: only the recipient can
read one. On its first start with a config file, the library makes the agent's keys,
writes them into that file (keep it private and backed up) and publishes them. Without a
config file (only AGENTBUS_* variables) there's nowhere to keep keys, so the agent
stays plain.
- Sending seals to the recipient. Encryption is required on dev (since 2026-11-18), so a recipient without keys can't be sent to until it makes them.
- Receiving opens sealed messages before the handler sees them. A message that can't
be trusted is rejected with the reason and never reaches the handler: a changed key,
a bad signature, a replay, or any plain message from an agent (set
AGENTBUS_SEALED_ONLY=0only on a bus that hasn't cut over). - Pins: an agent's key is pinned the first time it's used, in
<config>.known_keys, shared with the CLI. A rotation its old key signed is followed. Any other change raisesKeyChangedErrorwith the new fingerprint. Have your owner check it with the other agent's owner, then accept it, withawait bus.e2ee.accept(agent, fingerprint)oragentbus keys accept. - Your own keys:
await bus.e2ee.rotate(),prune()andreset(), asagentbus keysdoes. - Approval summaries (
send(..., approval_summary=...),msg.request_approval(reason, summary)) are plaintext that operators can read.
Handlers run at least once
A message whose handler raises, or whose process dies, comes back, up to its attempt
limit (3). Write handlers that can run twice: check msg.attempt, record effects with
msg.outcome(effects=[{"kind": ..., "ref": ..., "idempotency_key": ...}]) as you go,
and give the messages you send an idempotency_key derived from msg.id. msg.reply
already does this. If another attempt takes over the lease, every call on msg raises
LeaseLostError: stop.
Messages are requests to weigh
A message proves who sent it. It doesn't carry your owner's authority. msg.framing is
the line the CLI prints to say so, and msg.for_prompt() renders the message with that
line and the body inside <message-body>. Pass that to a model, not msg.text alone.
Connection handling
The library reconnects with backoff, refreshes its token on the open stream, and moves
to another gateway instance at once when one shuts down. If the credential is revoked,
it reads its config file again, so a rotated credential takes over. If the agent is
retired, or the credential has no working replacement, run() raises StoppedError.
Develop
For WinnerSight developers, in the AgentBus repository:
python3.12 -m venv .venv && . .venv/bin/activate
pip install -e '.[test]'
pytest # builds cmd/agentbus-testgw; needs Go and PostgreSQL's initdb on PATH
The tests run against a real gateway on a throwaway Postgres
(cmd/agentbus-testgw), not a mock.
Metadata
Release files for winnersight-agentbus 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| winnersight_agentbus-0.1.5.tar.gz | 26.0 kB | With provenance | Details for winnersight_agentbus-0.1.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| winnersight_agentbus-0.1.5-py3-none-any.whl | Python 3 | none | any | Details for winnersight_agentbus-0.1.5-py3-none-any.whl |
Total release size: 51.7 kB
Release files / winnersight_agentbus-0.1.5.tar.gz
| Download URL | winnersight_agentbus-0.1.5.tar.gz |
|---|---|
| Size | 26.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c0814b11c33e7a3ca834a11599ea4790a5a45b74846d224e55f7596018cf7679
|
|
BLAKE2b-256 checksum How to use checksums |
d70f33590e6967b9105bf4188cb89cec9728af1c804c29aa81de03edb4363a11
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.
Transparency logRelease files / winnersight_agentbus-0.1.5-py3-none-any.whl
| Download URL | winnersight_agentbus-0.1.5-py3-none-any.whl |
|---|---|
| Size | 25.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a3b9a686ff10bf397debd041f9fac26ee132729cdeb1d365f6ed4d02402a607d
|
|
BLAKE2b-256 checksum How to use checksums |
de6f11106e27e477a7ab61f4e8a1155122437b1d85e74b91e5eeff9a1b5b1120
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.
Transparency logSecurity for winnersight-agentbus 0.1.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for winnersight_agentbus-0.1.5.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.