crewai-sealgraf
Sealgraf spend-approval tools for CrewAI: before an agent buys anything, it checks the purchase against limits the owner set in advance; purchases above the owner's ask-line wait for the owner's own approval on Sealgraf's surface; every completed purchase is sealed into a receipt neither side can rewrite.
The spend loop
check_permission ── allow ──────────────► buy ──► complete_purchase ──► receipt
│
├── deny ────────────────────────► do not buy
│
└── needs_human_approval ──► owner approves in Sealgraf
claim_decision_token ──► buy
complete_purchase ──► receipt
get_receipt reads back either a check (by preauth_id, via
GET /v1/preauthorize/{id}) or a sealed receipt (by receipt_id,
via GET /v1/receipts/{id}) at any point.
Install
pip install crewai-sealgraf
Configure
The tools need an agent-scope Sealgraf API key. The key is host configuration, never a tool argument (tool arguments are chosen by the model and visible in prompts and logs). Pass it in code or set the environment:
export SEALGRAF_API_KEY=<redacted>
# optional; defaults to https://sealgraf.com
export SEALGRAF_BASE_URL=https://sealgraf.com
Use
from crewai import Agent
from crewai_sealgraf import sealgraf_tools
buyer = Agent(
role="Purchasing agent",
goal="Buy approved supplies within the owner's limits",
backstory="...",
tools=sealgraf_tools(), # reads SEALGRAF_API_KEY
)
# or explicitly:
tools = sealgraf_tools(api_key="see_...", base_url="https://sealgraf.com")
The four tools:
| Tool | Name for the model | What it does |
|---|---|---|
SealgrafCheckPermissionTool |
sealgraf_check_permission |
Ask before buying. Returns allow (with a single-use decision_token), deny, or needs_human_approval. |
SealgrafClaimDecisionTokenTool |
sealgraf_claim_decision_token |
After the owner approves, claim the single-use decision token. Fails with a stable code (e.g. not_approved_yet) while the owner has not decided. |
SealgrafCompletePurchaseTool |
sealgraf_complete_purchase |
After the purchase is made, report it; Sealgraf seals it into a receipt. Amounts are integer minor units (cents). |
SealgrafGetReceiptTool |
sealgraf_get_receipt |
Read a check's state (by preauth_id) or a sealed receipt (by receipt_id). |
Every tool returns the parsed Sealgraf result as JSON — the same shapes as the Sealgraf Dify plugin and MCP surfaces.
Safety behaviour
- Fail closed. Any failure — timeout, network error, non-2xx, malformed response, a token the server did not actually issue — raises and fails the tool call. A tool never renders an ambiguous answer as permission.
- Replay honesty. Repeating a check with the same idempotency key
returns the original check flagged
"replayed": true; a replayedallowdoes not re-serve the decision token ("decision_token_redelivered": false). Use the token from the first response; if it is lost, run a fresh check without the idempotency key. - Tokens are single-use and are passed through untouched; they are never logged by this package.
- The amount paid is required.
sealgraf_complete_purchaseneedscompleted_amount_minor— what was actually paid, in cents. Sealgraf seals it as the amount the agent reported; it does not see or move the payment itself. - No verification link. This package does not create a shareable check link or a receipt view. Its tools return the sealed receipt record; the owner views and shares receipts in their Sealgraf account.
- Waiting for approval. After a
needs_human_approvalcheck, the owner's decision takes human time. Pollsealgraf_get_receiptfor the preauth's state until it readsauthorized, then claim — do not callsealgraf_claim_decision_tokenrepeatedly while waiting: every early claim fails withnot_approved_yet, and an agent executor will happily retry it in a tight loop (observed live: 6 retries in one run). The refusal is harmless — no token exists before approval — but the polling pattern is cheaper and clearer.
Development
python -m venv .venv && .venv/bin/pip install -e . pytest
.venv/bin/python -m pytest tests/ # mocked HTTP only; no network
Metadata
Release files for crewai-sealgraf 0.1.1
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 |
|---|---|---|---|---|
| crewai_sealgraf-0.1.1.tar.gz | 24.9 kB | Without provenance | Details for crewai_sealgraf-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| crewai_sealgraf-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for crewai_sealgraf-0.1.1-py3-none-any.whl |
Total release size: 44.1 kB
Release files / crewai_sealgraf-0.1.1.tar.gz
| Download URL | crewai_sealgraf-0.1.1.tar.gz |
|---|---|
| Size | 24.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
40da30105018a17fab66bca04e37f300419fe0c93a8899e4a196cdea9b319b07
|
|
BLAKE2b-256 checksum How to use checksums |
8bbcd607e0fe7a8e379de705b76b5631c5387d868555b611ffde040f633daf0d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / crewai_sealgraf-0.1.1-py3-none-any.whl
| Download URL | crewai_sealgraf-0.1.1-py3-none-any.whl |
|---|---|
| Size | 19.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
460e5506bd8ebd8150a224fa982bb77cf7a415cbfbfed220e6aa90c239aa38ac
|
|
BLAKE2b-256 checksum How to use checksums |
221ca6db2a6000a0f097f0453ad6625db6672a484fe8b1bdcdeeb9914b8b6d6d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Security for crewai-sealgraf 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.
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.