# AX-SYS-15: Be idempotent and predictable where it matters

> Recovery and reliability · intermediate · AX-SYS-15

The same call should produce the same result, and retries must be safe, so agents can recover without causing duplicate side effects.

## Why

Agents retry. Unlike humans who notice a double-charge and call support, agents will silently retry a failed write and create a duplicate record or trigger a duplicate transaction. Speakeasy identifies Predictability as a foundational AX property. Stripe's idempotency key pattern is the industry standard: the client generates a unique key per intent, and the server returns the same result for any subsequent call with that key. This is especially critical in fintech and e-commerce where non-idempotent retries directly cause financial harm.

## Do

Use idempotency keys on writes.

## Don't

Create a new resource on every identical retry.

## Artifact

Send an `Idempotency-Key` on writes so the same key returns the same result (safe retries). See the refund example in [AX-SYS-13](ax-sys-13-consequential-actions-explicit-reversible.mdx).

## Citations

1. [Speakeasy — Designing Agent Experience](https://www.speakeasy.com/blog/agent-experience-introduction) — Predictability is a foundational AX property: agents must be able to retry safely; non-idempotent write endpoints turn retries into duplicate charges, duplicate records, or data corruption
2. [Stripe — Idempotent Requests](https://stripe.com/docs/api/idempotent_requests) — Industry-standard pattern: idempotency keys on write operations ensure the same request returns the same result regardless of how many times it is sent — essential for safe agent retries
3. [Anthropic — Building Effective AI Agents](https://www.anthropic.com/research/building-effective-agents) — Agents in automated pipelines will retry on network errors and timeouts; predictable, idempotent APIs are a prerequisite for reliable agentic operation

---
Source: Agent Experience Principles (axprinciples.com)