r/Python • • 25d ago

Showcase Showcase Thread

Post all of your code/projects/showcases/AI slop here.

Recycles once a month.

32 Upvotes

176 comments sorted by

View all comments

2

u/tom_mathews 14d ago

Attest: pytest plugin for testing AI agents on what they did, not just what they said

Source: https://github.com/attest-framework/attest (Apache-2.0, I'm the author)

Web Page: https://attest-framework.github.io/

What My Project Does

Attest is a testing framework for LLM agents. In Python it's a pytest plugin with an attest fixture and a chainable expect() API; evaluation runs in a small Go engine the SDK starts as a subprocess. Checks run cheapest first: JSON schema, cost/token/latency limits, which tools ran, in what order and with which arguments, content patterns. All of those are deterministic and free. Embedding similarity and LLM judges come last and are optional.

# refund_run: a fixture returning a recorded agent trace
def test_refund(attest, refund_run):
    chain = (
        expect(refund_run)
        .output_matches_schema({"type": "object", "required": ["refund_id"]})
        .cost_under(0.01)
        .tools_called_in_order(["lookup_order", "issue_refund"])
        .tool_cardinality("issue_refund", per="order_id", at_most=1)
    )
    attest.evaluate(chain)

attest capture -- python my_agent.py records a real run (model calls, trace, secrets redacted). Tests then replay the agent's current code against it, so CI makes zero model calls. 1.1 came out on November 10; it also fails any expect() chain you built but forgot to evaluate, and pytest-xdist runs now produce a complete report.

Try it, no API key needed:

uv init --bare demo && cd demo
uv add attest-ai pytest
uv run attest init
uv run pytest

Target Audience

Teams putting agents into production or CI, in Python 3.10+ (a TypeScript/Vitest SDK exists too). The capture/replay merge gate and behavior contracts are marked stable; several other features are beta or experimental, and the README labels each one. It has no external users yet, so expect rough edges.

Comparison

DeepEval and promptfoo are strong at scoring outputs with metrics and rubrics. Attest focuses on the trace and its side effects: per-key call counts, effects on a simulated backend, record/replay with no model calls, and mutation testing that tells you what your suite misses. Compared with vcrpy or pytest-recording, the recorder understands model APIs (streaming, templated ids, redaction) and drafts contracts from the run. Most of the code was written with coding agents (Claude Code, Codex) from plans I wrote and reviewed.