Skip to main content

attest-ai

Test framework for AI agents. Check an agent's output, tool calls and side effects, replay recorded model responses in CI, and gate merges on the results. Deterministic checks run first; model-scored checks run last.

Current release: 1.1.1 (documentation patch on 1.1.0 "Hardened"). Requires Python ≥3.10.

Install

uv add "attest-ai>=1.1.0" pytest

With LLM provider support:

uv add "attest-ai[openai]>=1.1.0"      # OpenAI
uv add "attest-ai[anthropic]>=1.1.0"   # Anthropic
uv add "attest-ai[gemini]>=1.1.0"      # Google Gemini
uv add "attest-ai[ollama]>=1.1.0"      # Ollama (local)
uv add "attest-ai[all]>=1.1.0"         # All providers

Quick start

Save as test_refund_agent.py. This example builds a trace locally, so it needs no model or API key. The attest fixture starts the engine, and attest.evaluate(chain) runs every assertion and fails the test on a hard failure. Since 1.1.0, building a chain without evaluating it fails the test; evaluate again if you add assertions afterwards.

from attest import AgentResult, TraceBuilder, expect


def refund_agent_result() -> AgentResult:
    """Stand-in for your agent: build the trace it produced."""
    trace = (
        TraceBuilder("refund-agent")
        .add_tool_call("lookup_order", args={"order_id": "ORD-123"}, result={"status": "paid"})
        .add_tool_call("process_refund", args={"order_id": "ORD-123"}, result={"refund_id": "R-1"})
        .set_output(message="Your refund R-1 is on its way.", structured={"refund_id": "R-1"})
        .set_metadata(cost_usd=0.01, latency_ms=800)
        .build()
    )
    return AgentResult(trace=trace)


def test_refund_agent(attest):
    result = refund_agent_result()
    attest.evaluate(
        expect(result)
        # Layer 1: schema validation
        .output_matches_schema({"type": "object", "required": ["refund_id"]})
        # Layer 2: cost and latency constraints
        .cost_under(0.05)
        .latency_under(5000)
        # Layer 3: trace structure
        .tools_called_in_order(["lookup_order", "process_refund"])
        .no_tool_loops("lookup_order", max_repetitions=3)
        # Layer 4: content
        .output_contains("refund")
        .output_not_contains("sorry")
    )
uv run pytest test_refund_agent.py --attest-report=report.json

Change one assertion, for example .output_contains("refund") to .output_contains("chargeback"), and the test fails with a diagnostic for that assertion.

Helpers

  • TraceBuilder.set_metadata(...) merges: fields given in a later call are added, and fields it leaves out keep their value. set_metadata(cost_usd=0.5) followed by set_metadata(latency_ms=100) keeps both, so cost_under(0.05) fails on the cost.
  • @agent("name") wraps a function with a builder parameter that Attest injects. A string return becomes the output {"message": <str>}, so output_contains works on a plain agent; a dict return is the output as is. Positional arguments are forwarded: with def my_agent(builder, user_message), both my_agent("hello") and my_agent(user_message="hello") work. adapter= converts a provider adapter's return value and raises TypeError at decoration for an adapter that cannot convert.
  • When the engine cannot be found or downloaded (offline, or behind a blocking proxy), pytest ends the run with one error line that names ATTEST_ENGINE_PATH, without a traceback. Build an engine with make engine and point ATTEST_ENGINE_PATH at it to run offline.

Pytest integration

Attest registers as a pytest plugin automatically:

uv run pytest tests/ --attest-engine=/path/to/attest-engine

Metadata

Release files for attest-ai 1.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 attest-ai 1.1.1
File Size Uploaded Provenance Actions
attest_ai-1.1.1.tar.gz 717.8 kB With provenance Details for attest_ai-1.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for attest-ai 1.1.1
File Interpreter ABI Platform Actions
attest_ai-1.1.1-py3-none-any.whl Python 3 none any Details for attest_ai-1.1.1-py3-none-any.whl

Total release size: 871.2 kB

Release files / attest_ai-1.1.1.tar.gz

Download URL attest_ai-1.1.1.tar.gz
Size 717.8 kB
Tags Source
SHA-256 checksum
How to use checksums
57e8bdfd5d12607d889643ac025228329b561940ae21f77cb46a7f3e4182a6ed
BLAKE2b-256 checksum
How to use checksums
b53fd90dfe29ff2a7976317f19978bedb4fde2d8f87af097986afac349cb740c
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 11, 2026.

Transparency log

Release files / attest_ai-1.1.1-py3-none-any.whl

Download URL attest_ai-1.1.1-py3-none-any.whl
Size 153.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d599c93902987b6d76f06b6f33c674863ab09475bd19815a711fb127cccd765b
BLAKE2b-256 checksum
How to use checksums
d6738097365fdaa4cfe2920358748f44cb0f01737bcf611098c7b3ec49c71fa1
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 11, 2026.

Transparency log

Security for attest-ai 1.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 attest_ai-1.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 11, 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.

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