> ## Documentation Index
> Fetch the complete documentation index at: https://agent-contracts.relari.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Why Use Agent Contracts?

> Understanding why Agent Contracts are essential for building reliable AI agents

## The Fundamental Challenge with AI Agents

AI agents offer powerful automation through their ability to reason, plan, and use tools. However, they create a fundamental challenge:

**We lack a structured way to specify agent behavior and ensure reliability.**

Unlike traditional software with explicit code, AI agents powered by LLMs operate on natural language prompts, creating critical gaps:

* **Imprecise specification**: Prompts are ambiguous and can't cover all scenarios
* **Limited reliability**: There's no built-in way to verify if LLM-powered agents follow instructions
* **Flexibility-control tradeoff**: Detailed prompts reduce adaptability; general prompts reduce predictability

<img className="block dark:hidden" src="https://mintcdn.com/relari-4243c669/irmqsITvT7Za5SKl/images/tradeoff.svg?fit=max&auto=format&n=irmqsITvT7Za5SKl&q=85&s=566ffccfdc24beb2b8cba6dd8bcb7f8d" alt="Prompting Tradeoff Light" width="960" height="540" data-path="images/tradeoff.svg" />

<img className="hidden dark:block" src="https://mintcdn.com/relari-4243c669/irmqsITvT7Za5SKl/images/tradeoff.svg?fit=max&auto=format&n=irmqsITvT7Za5SKl&q=85&s=566ffccfdc24beb2b8cba6dd8bcb7f8d" alt="Prompting Tradeoff Dark" width="960" height="540" data-path="images/tradeoff.svg" />

This forces developers to choose between agents that are too rigid or too unpredictable. Neither option works well for production, business-critical systems, which require both reliability and flexibility.

## The Solution: Agent Contracts

Agent Contracts provide a structured framework that addresses these challenges by complementing (not replacing) prompts with scenario-based specifications:

<img className="block dark:hidden" src="https://mintcdn.com/relari-4243c669/irmqsITvT7Za5SKl/images/role-of-contracts.png?fit=max&auto=format&n=irmqsITvT7Za5SKl&q=85&s=7345f02716de4ddaf17fe96f0aad6c4b" alt="Role of Contracts Light" width="2832" height="1031" data-path="images/role-of-contracts.png" />

<img className="hidden dark:block" src="https://mintcdn.com/relari-4243c669/irmqsITvT7Za5SKl/images/role-of-contracts.png?fit=max&auto=format&n=irmqsITvT7Za5SKl&q=85&s=7345f02716de4ddaf17fe96f0aad6c4b" alt="Role of Contracts Dark" style={{ backgroundColor: 'white   ' }} width="2832" height="1031" data-path="images/role-of-contracts.png" />

### How Agent Contracts Work

Agent Contracts follow a three-part approach:

1. **Define** – Specify expected behavior through contracts
   * Write natural language contracts for specific scenarios
   * Express business logic as verifiable conditions
   * Complement general prompts with precise requirements

2. **Verify Offline** – Test agent traces against contracts offline
   * Analyze execution traces to verify contract compliance
   * Measure performance across test scenarios
   * Debug and improve contracts before deployment

3. **Certify in Runtime** – Apply contracts during runtime execution
   * Check agent behavior against contracts in real-time
   * Enforce contract conditions when violated
   * Generate execution traces for continuous improvement

This structured approach bridges the gap between natural language instructions and reliable execution, addressing both specification and reliability challenges simultaneously.

## Next Steps

**Want to dive deeper? Check out the [Agent Contracts Whitepaper](https://cdn.prod.website-files.com/669f7329c898141d69e16698/67cf788d56ca9dcf0b88e8d0_1859d1de14107778dccb73c5291f1d5d_Agent%20Contracts%20Whitepaper.pdf)**

Try for yourself? Start with our [Installation](/installation) or explore [Core Concepts](/core-concepts) to learn more.
