Platform and integration
Idempotency key
An idempotency key is a unique value attached to a write request so that if the same request is delivered twice, after a timeout or a retry, the server performs it once and returns the stored result for the repeat.
What it is
RFC 9110 calls an HTTP method idempotent when sending it several times has the same effect as sending it once. GET, PUT and DELETE are; POST is not. An idempotency key makes a non-idempotent write safe to retry. Stripe's API documentation describes the pattern: the client sends a unique key with a create or update, the server saves the result of the first request, and a retry with the same key gets the saved response instead of a second object. The IETF HTTPAPI working group drafted a standard Idempotency-Key header; that Internet-Draft has expired, but the pattern is in wide use.
Why it matters
Agents retry, and so do the layers under them. A response stream breaks, a client times out, a model calls the same tool again "to make sure". Without a key, a retried create_invoice creates a second invoice, which someone finds months later in a customer's ledger.
How it works
- The client sends a key with the write, or the server derives one from the request itself.
- The server claims the key before sending, so a concurrent duplicate waits or is refused.
- After the vendor answers, the server stores the result under the key.
- A repeat within the retention window gets the stored result without touching the vendor.
- The same key with a different payload is refused, never answered with someone else's result.
Example
An agent calls do to create an invoice. The connection drops before the response arrives, and the agent calls again with the same arguments. The second call returns the first call's invoice number. The vendor saw one request.
Common pitfalls
- A new key per attempt. A key that includes a timestamp or attempt number defeats the purpose.
- Reusing a key for a different request. Servers should refuse it; silently answering is worse.
- Unknown outcomes. If the request left and no answer came back, retrying blind may duplicate it. Hold the key and check the vendor first.
- Unordered JSON. Deriving a key from a body without canonicalising it makes the same request look different.
How actionlake handles it
Every write through actionlake is deduplicated. The key is the agent's own (idempotency_key on do), or one derived from the tenant, the connection, the action and the body in canonical JSON (RFC 8785), length-prefixed so no field can shift into another. A repeat within 24 hours replays the stored result without touching the vendor, and a replay is free. A duplicate that arrives while the first is in flight is refused with a retry hint; the same key with a different payload is refused with 422. If a write left and its outcome is unknown, after a timeout or a 5xx, it is not re-sent until the claim lapses, and the caller is told to check the vendor first. Writes are never cached, and a single do never re-sends a write on its own. See the API reference.
Questions
Why do AI agents need idempotency keys?
Agents and the transports under them retry after timeouts and dropped connections. Without a key, each retry of a write can create a duplicate record in the vendor's system.
How long should an idempotency key be kept?
Long enough to cover realistic retries. Twenty-four hours is a common window, used by Stripe's API and by actionlake.
What happens if the same key is sent with a different payload?
A careful server refuses it. Serving the first request's result for a different request would hand one caller another caller's answer.
Related terms
- Tool callingTool calling, also called function calling, is a language model's ability to answer with a structured request to run a named function with arguments, which the application executes before handing the result back to the model.
- Dry runA dry run checks whether an agent's action would succeed, whether it is allowed and what it would cost, by validating the inputs, permissions and connection without sending anything to the vendor.
- Upstream callAn upstream call is one HTTP request that actionlake sent to a vendor's API on your behalf and that returned a definitive, attributable response; it is the unit actionlake meters and bills.
- Agent planAn agent plan is a saved, versioned procedure of actions, cross-system joins, loops, waits and approval steps that an AI agent writes once and that then runs the same way on demand or on a schedule, without the model re-deciding every step.
- Rate limiting for AI agentsRate limiting for AI agents controls how many requests an agent can make in a time window, both to the platform it calls and to each vendor API behind it, so a fast or looping agent cannot exhaust a shared quota or trigger lockouts.
Sources
Connect an agent. Start free.
100,000 calls free every month. No card. Hard caps on every key.