Agent Idempotency Key Enforcement
Ensure agentic tool calls are execution-safe by preventing duplicate operations during retries.
Steps
- Generate a unique `idempotency_key` for every distinct tool-call intent.
- Attach the key to the request header (e.g., `X-Idempotency-Key`).
- Store the key in the database alongside the initial request payload.
- Check for existing keys on the server-side before executing any 'write' operation.
- Return the original cached response if a duplicate key is detected.
- Set a TTL (Time-to-Live) for keys to prevent database bloat.