agentraas (Python SDK)
Exactly-once execution for AI agents — a thin, dependency-light wrapper around AgentRaaS's SDK-style REST gateway. If your agent code calls Stripe, Twilio, HubSpot, or any other API directly, wrap it with this client so a retry — yours, your framework's, or a flaky network — never becomes a duplicate charge, a duplicate contact, or a duplicate message.
Works against any AgentRaaS deployment: self-hosted (./install.sh,
free and unlimited on every tier) or AgentRaaS Cloud.
Install
pip install agentraas
Library mode: no server needed
Wrap any function that has a side effect (charging a card, sending an email, creating a CRM record) so retries and concurrent duplicates run it exactly once. Nothing to deploy: state lives in a local SQLite file by default, or in your own Redis.
from agentraas.local import exactly_once, RedisStore
@exactly_once() # SQLite file, one machine
def charge(customer, amount):
return stripe.Charge.create(customer=customer, amount=amount).id
charge("cus_1", 4200) # runs for real
charge("cus_1", 4200) # retry: returns the cached id, no second charge
# Across machines, with your own idempotency key and window:
@exactly_once(store=RedisStore("redis://localhost:6379/0"),
key=lambda order: order["id"], ttl=3600)
async def ship(order):
...
- If the function raises, nothing is cached and a retry runs it again.
- A duplicate that arrives while the first call is still running waits for
its result (up to
wait=30seconds, thenInFlightError). - Results must be JSON-serializable (return ids or dicts, not SDK objects).
RedisStoreneedspip install redis.
When you want a dashboard, audit trail, human approval or circuit
breaking on top, point the same calls at an AgentRaaS server with the
Client below.
Quickstart
- Connect an agent from your AgentRaaS dashboard (+ Connect Agent) —
this gives you an
agentraas_key, plus yourorg_idandagent_id. - Add credentials for the service you're calling (Credentials panel) — AgentRaaS forwards to the real API using those, you never pass a raw upstream API key through this SDK.
import agentraas
client = agentraas.Client(
agentraas_key="ar_live_...",
org_id="acme-corp",
agent_id="billing-bot",
base_url="http://localhost:13000", # or your Cloud/self-hosted URL
)
result = client.call("stripe", "charge.create", {"amount": 5000, "currency": "usd"})
Or with dot-notation sugar:
stripe = client.service("stripe")
result = stripe.charge.create({"amount": 5000, "currency": "usd"})
Calling a Custom Action you've registered:
result = client.custom("my-internal-webhook", {"foo": "bar"})
Why org_id / agent_id matter
Omit them and every untagged SDK caller shares one unenforced identity server-side — your per-agent rate limit and audit trail won't tell your traffic apart from anyone else's. Set them once you've connected an agent from the dashboard; it takes two extra kwargs.
Retries are safe
AgentRaaS claims an atomic dedup slot server-side before forwarding
anything. If client.call(...) raises because of a timeout or a dropped
connection, calling it again with the same payload is safe — it either
completes normally or returns the cached result from the call that
actually went through. This SDK doesn't retry automatically; your own
retry logic (or your agent framework's) can be as aggressive as you want.
Error handling
from agentraas import AgentRaaSError
try:
client.call("stripe", "charge.create", {"amount": 5000, "currency": "usd"})
except AgentRaaSError as err:
print(err.status_code, err.req_id, str(err))
License
MIT — see LICENSE. (The AgentRaaS server itself is open-core; see the main repo for its licensing.)
Release files for agentraas 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| agentraas-0.3.0.tar.gz | 9.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| agentraas-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.5 kB
Release files / agentraas-0.3.0.tar.gz
| Download URL | agentraas-0.3.0.tar.gz |
|---|---|
| Size | 9.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4675efc91635b5d588a9f34a4cf98983e6fc803634402c6166c7de74bd281673
|
|
BLAKE2b-256 checksum How to use checksums |
23d946a298a69cd99007281bd21ea7c3e93b7a40b3dff4cdb48a20bf138b8e4e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / agentraas-0.3.0-py3-none-any.whl
| Download URL | agentraas-0.3.0-py3-none-any.whl |
|---|---|
| Size | 10.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
212ece23f14e16f1cc070646560ff4c24c1fb02cc93fb92fa24aa336c55af127
|
|
BLAKE2b-256 checksum How to use checksums |
ebbe1a2ef84be2c92603c211ec1947d7e0810c32e36a8e77c3d81290f09f7ce2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|