agent-tx ⚡
Deterministic ACID Transaction Engine for Autonomous AI Agents in <1µs
Built in Rust with native Python bindings. Part of the next-generation agent runtime ecosystem.
🎯 The Problem
When production AI agents execute complex multi-step workflows (30+ tool invocations, code generation, external API calls):
- Dirty State on Failure: If a tool fails at step 28, external resources (files, database records, webhooks) remain corrupted.
- Punishing Token Costs: Standard frameworks abort the run and re-prefill the entire 50k–100k token context from step 1, burning latency and GPU budget.
- Slow State Duplication: Cloning deep context arrays in Python takes 15ms–50ms and triggers stop-the-world Garbage Collection.
🚀 The Solution: agent-tx
agent-tx brings classical ACID semantics and Copy-on-Write branching directly into the agent execution loop:
- Sub-microsecond Checkpoints (~830 ns): Structural persistence (
im::Vector) allows instantaneous context branching without copying memory. - Saga Pattern Rollback (LIFO): Register compensatory actions for tools and unwind external side effects in reverse order.
- Durable Write-Ahead Log (WAL): Zero data loss across process crashes with CRC32-verified binary replay.
- Native Python Ergonomics: Drop-in
with tx.transaction():context managers and@transactional_tooldecorators.
📊 Benchmarks (Criterion, Linux x86_64)
| Operation | Latency | Complexity |
|---|---|---|
| Transaction Checkpoint (50 messages) | 830.62 ns | $O(1)$ Copy-on-Write |
| Speculative Fork from Root | 859.18 ns | $O(1)$ Pointer clone |
| Rollback & Compensation Unwind | < 2.5 µs | $O(k)$ where $k$ = depth |
📦 Installation
pip install agent-tx
🛠️ Quickstart
1. Automatic Rollback with Context Manager
from agent_tx import AgentTx
tx = AgentTx()
tx.append("system", "You are a cloud orchestration agent.", 12)
tx.append("user", "Resize cluster node pool.", 15)
try:
with tx.transaction() as tx_id:
tx.append("assistant", "Calling scale_nodes(pool='prod', count=10)...", 20)
# Register compensating undo action
tx.register_undo(lambda: print("-> Compensating: Reverting node pool back to 3"))
# Simulate business failure / validation rejection
raise RuntimeError("Cloud quota exceeded!")
except RuntimeError:
print("Execution failed. Context rolled back.")
# Context automatically pruned back to safe state (system + user only)
assert len(tx.export_context()) == 2
2. Durable Recovery via Write-Ahead Log (WAL)
from agent_tx import AgentTx
# Session persists across process restarts
tx = AgentTx.open("agent_session.wal")
tx.append("system", "Mission critical agent", 10)
tx.append("user", "Execute batch job", 12)
# If process dies here, re-opening "agent_session.wal" restores exact state
del tx
recovered_tx = AgentTx.open("agent_session.wal")
assert len(recovered_tx.export_context()) == 2
📄 License
Dual-licensed under MIT or Apache 2.0.
Metadata
Release files for agent-tx 0.1.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 | Provenance | Actions |
|---|---|---|---|---|
| agent_tx-0.1.0.tar.gz | 19.5 kB | Without provenance | Details for agent_tx-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| agent_tx-0.1.0-cp38-abi3-manylinux_2_34_x86_64.whl | CPython 3.8 | abi3 | Linux glibc 2.34+ x86-64 | Details for agent_tx-0.1.0-cp38-abi3-manylinux_2_34_x86_64.whl |
Total release size: 390.3 kB
Release files / agent_tx-0.1.0.tar.gz
| Download URL | agent_tx-0.1.0.tar.gz |
|---|---|
| Size | 19.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5f1260e179c37eae2ecfbd5baf7d7810a5bc768f939a0953a96d8890477154a2
|
|
BLAKE2b-256 checksum How to use checksums |
daed845c3071217e5905e5046519d7b5e74fd8efe2acc76c91a6e03c9ebde87e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / agent_tx-0.1.0-cp38-abi3-manylinux_2_34_x86_64.whl
| Download URL | agent_tx-0.1.0-cp38-abi3-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 370.9 kB |
| Tags | CPython 3.8 Linux glibc 2.34+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
1d2bbc7c4f1c1362a459a12e29a35afeea7c294668b9c102befee76c31256ab6
|
|
BLAKE2b-256 checksum How to use checksums |
959b619d18b15573276776c4f79878263ddf71f2014240951628ac55049e35b6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Security for agent-tx 0.1.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.