Skip to main content

aieval

CI PyPI version Python versions License: MIT

Deterministic-first runtime validation and reliability toolkit for LLM outputs and agent actions.

Catch predictable failures (schema violations, missing required keys, JSON format errors, invalid tool call args, policy constraints) in sub-millisecond execution before spending latency and money on semantic LLM-as-a-judge scoring.


Key Highlights

  • ⚡ Deterministic First: Cheap, fast assertions run before calling model judges.
  • 📦 Zero Bloat: Minimal external footprint (pydantic>=2.0.0 as schema engine, pure Python standard library for the rest).
  • 🔄 Dual Sync & Async: Native support for synchronous scripts (evaluate()) and asynchronous pipelines (await aevaluate()).
  • 🤖 Agent Tool Call Pre-flight: Validates function names, required arguments, type safety, and stringified JSON (OpenAI tool call format).
  • 🎚️ Severity Routing: Flexible threshold routing (fail_on="error" vs strict fail_on="warning").
  • 🧪 CLI & Golden Fixtures: Run validation from the command line on JSON test fixtures (aieval run <fixture.json>).
  • 🎯 Full TypeScript Parity: Shares the exact failure taxonomy, code conventions, and golden test formats with @hamza1331/aieval.

Installation

pip install aieval-py

Behavior changes in 0.2.0

This release tightens validation behavior. Tool-call arguments not declared by required_args or the supplied schema are rejected by default; set allow_unexpected_args=True only when extra arguments are intentionally allowed. Custom checks must return None, Failure, CheckResult, or a sequence of supported failure results; unsupported values now raise EvaluationConfigError. Terminal failures also remain blocking regardless of the fail_on severity threshold. Review these changes before upgrading if your application relies on permissive argument handling or custom return values.


Quickstart

1. Synchronous Output Evaluation

from aieval import evaluate, schema_check, required_fields
from pydantic import BaseModel, Field


class AnalysisReport(BaseModel):
    summary: str
    confidence_score: float = Field(ge=0.0, le=1.0)
    tags: list[str]


llm_output = '{"summary": "All systems nominal", "confidence_score": 0.95, "tags": ["ops", "prod"]}'

result = evaluate(
    output=llm_output,
    checks=[
        schema_check(AnalysisReport),
        required_fields(["summary", "confidence_score"]),
    ],
)

if result.passed:
    print(f"Passed in {result.summary.duration_ms}ms!")
else:
    for failure in result.failures:
        print(f"[{failure.code}] {failure.message} (path: {failure.path})")

2. Pre-flight Agent Tool Call Validation

Validate tool calls before execution to avoid runtime exceptions and agent failure loops:

from aieval import evaluate, tool_call_check
from pydantic import BaseModel


class SendEmailArgs(BaseModel):
    recipient: str
    subject: str
    body: str


# Works with both native dicts and OpenAI stringified JSON arguments:
raw_tool_call = {
    "name": "send_email",
    "arguments": '{"recipient": "team@example.com", "subject": "Update"}',
}

result = evaluate(
    output=raw_tool_call,
    checks=[
        tool_call_check("send_email", schema=SendEmailArgs, required_args=["body"]),
    ],
)

print(result.passed)  # False - missing required argument 'body'

3. Asynchronous Pipeline (aevaluate)

import asyncio
from aieval import aevaluate, valid_json, regex_match


async def main():
    result = await aevaluate(
        output="Order #12345 confirmed.",
        checks=[
            regex_match(r"Order #\d+"),
        ],
    )
    print("Passed:", result.passed)


asyncio.run(main())

CLI Usage

Run Golden Test Fixtures

aieval run path/to/fixture.json

When a fixture includes an expected block, the command compares the evaluation result with that expectation and exits successfully only when they match. This allows both expected passes and expected failures to be regression fixtures.

Or output raw JSON:

aieval run path/to/fixture.json --json

Check Arbitrary Files

aieval check output.json --specs checks.json

Failure Code Taxonomy

Code Category Description
INVALID_JSON Syntax Output string is not parseable JSON
SCHEMA_VALIDATION_ERROR Schema Failed Pydantic v2 schema validation
MISSING_REQUIRED_FIELD Fields Missing expected key
UNEXPECTED_FIELD Fields Extra key outside allowed whitelist
REGEX_MISMATCH Constraints Pattern regex search failed
ENUM_MISMATCH Constraints Value not in permitted set
VALUE_CONSTRAINT_VIOLATION Constraints Range or boundary violation
LENGTH_OUT_OF_BOUNDS Constraints Length outside min/max range
TOOL_CALL_UNKNOWN_TOOL Tool Calls Unknown tool invoked
TOOL_CALL_INVALID_ARGS_JSON Tool Calls Arguments string is invalid JSON
TOOL_CALL_MISSING_REQUIRED_ARG Tool Calls Required argument missing
TOOL_CALL_ARG_TYPE_MISMATCH Tool Calls Argument schema check failed

Examples

Runnable walkthrough scripts are available in the examples/ directory:


License

MIT

Metadata

Release files for aieval-py 0.2.0

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

Source distribution (sdist)

Source distribution for aieval-py 0.2.0
File Size Uploaded Provenance Actions
aieval_py-0.2.0.tar.gz 54.3 kB With provenance Details for aieval_py-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for aieval-py 0.2.0
File Interpreter ABI Platform Actions
aieval_py-0.2.0-py3-none-any.whl Python 3 none any Details for aieval_py-0.2.0-py3-none-any.whl

Total release size: 81.9 kB

Release files / aieval_py-0.2.0.tar.gz

Download URL aieval_py-0.2.0.tar.gz
Size 54.3 kB
Tags Source
SHA-256 checksum
How to use checksums
82e3931dfd534c721292e11a0a9c951b881b77ef0333d9e6943aaf3a0cf7955a
BLAKE2b-256 checksum
How to use checksums
83d9d3c965403f9cbcb9563abb74e8f58e47eaf586abd949487932c03186cd9e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 19, 2026.

Transparency log

Release files / aieval_py-0.2.0-py3-none-any.whl

Download URL aieval_py-0.2.0-py3-none-any.whl
Size 27.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8005c6c9b6efe3a888e2f3f2a83f8c1a49158a59ba7b55d031b970d8479cb011
BLAKE2b-256 checksum
How to use checksums
fac6287587f17f5b71a2c5c58ace11e7456ba3e78b4083e2c4f3b03860d11c8f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 19, 2026.

Transparency log

Security for aieval-py 0.2.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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for aieval_py-0.2.0.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 Oct 19, 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