Quick Start
Getting Started
Install agentAssert, write a contract, and run your first check in under 60 seconds.
1 Install
Install agentAssert from PyPI with YAML and math extras.
Terminal
# Install with all extras
pip install agentassert-abc[yaml,math]
# Verify installation
python -c "import agentassert; print(agentassert.__version__)" Package agentassert-abc
License AGPL v3
Python 3.9+
2 Write a Contract
Define behavioral constraints in YAML using the ABC = {P, I, G, R} structure.
contract.yaml
name: customer-support-agent
version: "1.0"
preconditions:
- field: input.query
operator: exists
severity: hard
invariants:
- field: response.tone
operator: in
value: [professional, empathetic, neutral]
severity: hard
guarantees:
- field: response.length
operator: lte
value: 500
severity: soft
recovery:
strategy: retry
max_attempts: 3 3 Run a Check
Load the contract and validate agent behavior in Python.
check.py
from agentassert import load_contract, check
# Load the YAML contract
contract = load_contract("contract.yaml")
# Agent output to validate
agent_output = {
"input": {"query": "How do I reset my password?"},
"response": {
"tone": "professional",
"length": 142,
"text": "To reset your password..."
}
}
# Run the behavioral check
result = check(contract, agent_output)
print(f"Compliant: {result.compliant}")
print(f"Theta: {result.theta:.4f}") Next Steps
Explore contracts, benchmarks, and the full research.