Skip to main content

tarmac-agent

ci pypi python deps license

Test your on-chain agent before it goes live, from Python.

Tarmac runs your agent against a live fork of Robinhood Chain with an isolated simulated wallet, applies the same policy checks to every swap request, and records a trace of every tool call, check and balance change. Your agent runs on your machine and never holds a key.

pip install tarmac-agent

Standard library only: no dependencies.

Quickstart

from tarmac_agent import TarmacClient, TarmacTools, run_agent

client = TarmacClient("https://your-tarmac-server")

def my_agent(tools: TarmacTools) -> None:
    ctx = tools.get_context()
    pair = dict(token_in=ctx["tokenIn"]["address"], token_out=ctx["tokenOut"]["address"])
    quote = tools.get_quote(**pair, amount_in=ctx["amountIn"])

    if quote["slippageBps"] > ctx["policy"]["maxSlippageBps"]:
        tools.finish("stopped", "Slippage over the limit.")
        return

    tools.request_swap(quote_id=quote["quoteId"], **pair, amount_in=ctx["amountIn"])
    tools.finish("swapped")

out = run_agent(client, my_agent, scenario="swap-thin", agent_name="my-python-agent")
print(out["run"]["result"]["verdictLabel"])  # "Followed the rule and stopped"
print(out["session"].run_url)                  # full trace in the browser

Servers that require sign-in

Create the run in the Tarmac app (Run → Your agent), then attach:

run_agent(client, my_agent, run_id=os.environ["TARMAC_RUN_ID"], run_token=os.environ["TARMAC_RUN_TOKEN"])

From environment variables

client = TarmacClient.from_env()          # $TARMAC_URL, default http://localhost:3000
session = client.attach_from_env()        # $TARMAC_RUN_ID + $TARMAC_RUN_TOKEN

Check your setup

python -m tarmac_agent check --url https://your-tarmac-server   # or set $TARMAC_URL
# ✓ https://your-tarmac-server is up
#   modes       fixture, fork
#   persistent  yes

TarmacClient.health() returns the same status from code.

Examples

Tools

Method Arguments Returns
get_context() — instruction, wallet, tokens, amount, policy limits
get_balances() — wallet balances (integer base units as strings)
get_quote() token_in, token_out, amount_in quoteId, amountOut, reference, slippageBps, eligibility
request_swap() quote_id, token_in, token_out, amount_in, min_amount_out=None, reason=None executed / blocked / failed + every policy check
finish() outcome, summary=None the run's verdict

Responses keep the API's field names (slippageBps, quoteId, …) so they match the TypeScript SDK and the HTTP API exactly. Every response is a TypedDict, so editors autocomplete them.

Errors

Failures raise TarmacToolError with .code (INVALID_INPUT, UNSUPPORTED_TOKEN, TOOL_LIMIT, RUN_NOT_ACTIVE, AUTH_REQUIRED, NETWORK_ERROR, …), .message and .retryable.

Retries

Transient failures are retried automatically with exponential backoff (2 retries by default):

  • Rejected before any work (HTTP 429/503 marked retryable): every call is retried.
  • Network failures: only read-only calls (get_context, get_balances, get_quote, get_run) are retried. A request_swap or finish that times out may already have run on the server, so it is never sent twice.
client = TarmacClient("https://your-tarmac-server", retries=4, backoff=0.25)  # or retries=0 to disable

Development

python -m unittest discover -s tests -v

Releasing

Releases publish to PyPI from GitHub Actions with Trusted Publishing: no API token is stored anywhere.

  1. Bump __version__ in src/tarmac_agent/_version.py and move the changelog's Unreleased notes under that version.
  2. Tag and push: git tag v0.1.0 && git push origin v0.1.0.

The workflow refuses to publish if the tag and the package version disagree.

License

MIT

Metadata

Release files for tarmac-agent 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tarmac-agent 0.1.1
File Size Uploaded Provenance Actions
tarmac_agent-0.1.1.tar.gz 12.2 kB With provenance Details for tarmac_agent-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tarmac-agent 0.1.1
File Interpreter ABI Platform Actions
tarmac_agent-0.1.1-py3-none-any.whl Python 3 none any Details for tarmac_agent-0.1.1-py3-none-any.whl

Total release size: 22.6 kB

Release files / tarmac_agent-0.1.1.tar.gz

Download URL tarmac_agent-0.1.1.tar.gz
Size 12.2 kB
Tags Source
SHA-256 checksum
How to use checksums
712d505408073357e4ca57806a03711913a4595bf02601a1940dad1fc2bb8d47
BLAKE2b-256 checksum
How to use checksums
bfc03f7bdd945f9c1a622b851f8f2fe752cfb2e97f5240db82b4f7f1cf5b7256
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 13, 2026.

Transparency log

Release files / tarmac_agent-0.1.1-py3-none-any.whl

Download URL tarmac_agent-0.1.1-py3-none-any.whl
Size 10.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5fd5a1e681b6bff078780f5e5df864e72df4f9389a61f3c1eb83e1cb34904ede
BLAKE2b-256 checksum
How to use checksums
cd9c1f4e1e862cbffd93c518fa8b4df5c4aa717e03cdeb2a607a8d682ce3a10e
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 13, 2026.

Transparency log

Security for tarmac-agent 0.1.1

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.

Select from 2 files

Attestation for tarmac_agent-0.1.1.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 13, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page