Agent Contracts

Agent Contracts

How to prevent $47K API bills and infinite loops. Resource governance for autonomous AI systems.

Autonomous agents without resource limits are a liability. Contracts turn them into controlled, predictable systems.

The $47K Problem

A startup deployed an autonomous AI agent to handle customer support. The agent worked great—until it didn't.

One bug caused the agent to enter an infinite loop. It made 2.3 million API calls in 6 hours. The bill: **$47,000**.

This isn't rare. It's the default outcome when you give agents unlimited resources. The paper "Agent Contracts: Resource-Bounded Autonomous AI Systems" solves this through **formal resource governance**.

What Are Agent Contracts?

An agent contract is a formal agreement that defines:

Resource Limits

Maximum API calls, compute time, memory usage, token consumption. Hard limits that cannot be exceeded.

Behavioral Constraints

What the agent can and cannot do. Which APIs it can access. What actions require human approval.

Success Criteria

What "done" looks like. When to stop. When to escalate. Clear exit conditions.

Failure Handling

What happens when limits are hit. How to recover. Who gets notified. Graceful degradation paths.

The contract is **enforced at runtime**. The agent cannot violate it, even if it wants to. This is safety through formal verification, not trust.

The Three Types of Contracts

1. Resource Contracts

Hard limits on consumption. Examples:

  • Maximum 1000 API calls per task
  • Maximum $10 in API costs per hour
  • Maximum 60 seconds of compute time
  • Maximum 2GB of memory usage

When limits are hit, the agent stops immediately. No exceptions.

2. Behavioral Contracts

Rules about what the agent can do. Examples:

  • Cannot delete data without human approval
  • Cannot access production databases
  • Cannot send emails to more than 10 people
  • Must verify facts before making claims

Violations trigger immediate escalation to a human operator.

3. Outcome Contracts

Success and failure conditions. Examples:

  • Task must complete within 5 minutes
  • Must achieve 95% accuracy on validation set
  • Must get human approval before proceeding to next phase
  • Must produce output in specified format

If success criteria aren't met, the agent reports failure and stops.

How ArmadaOS Uses Contracts

Every agent in ArmadaOS operates under a contract. This is non-negotiable. Here's how it works:

1

Contract Definition

When you create an agent, you define its contract. Resource limits, behavioral rules, success criteria.

2

Runtime Enforcement

The orchestration layer enforces the contract. Every API call, every action, every resource allocation is checked against the contract.

3

Violation Handling

If the agent tries to violate the contract, it's stopped immediately. No $47K bills. No infinite loops. No surprises.

4

Observability

You can see contract status in real-time. How much of the budget is used. How close to limits. When violations occur.

This is how we run autonomous agents in production without fear. The contract is the safety net.

Frequently Asked Questions

How do I set resource limits for my agents?

Start conservative. Set limits based on your expected usage, then add 50% buffer. Monitor actual usage for a week, then adjust. It's easier to increase limits than to explain a $50K bill.

What happens when an agent hits its limit?

The agent stops immediately. It logs the violation, notifies the operator, and enters a safe state. No partial work. No undefined behavior. Clean stop.

Can agents request more resources?

Yes, but only through human approval. An agent can signal that it needs more resources to complete its task, but it cannot self-approve. This prevents runaway scenarios.

Do contracts slow down agents?

Negligible overhead. Contract checking adds microseconds per operation. The safety is worth it. You're trading 0.01% performance for 100% cost control.

How do I know if my contracts are too restrictive?

Monitor violation rates. If agents frequently hit limits but don't complete tasks, your contracts are too tight. If agents never hit limits, they might be too loose. Aim for 5-10% violation rate.

Can I use contracts with existing AI agents?

Yes. Contracts are implemented at the orchestration layer, not in the agent itself. You can wrap any agent with a contract without modifying the agent's code.

Implementation Checklist

Before deploying autonomous agents to production:

Source Research

This analysis is based on the paper "Agent Contracts: Resource-Bounded Autonomous AI Systems" published on arXiv.

Read Full Paper →

Related Papers