Who it is forA backend developer whose network calls to agent tasks sometimes time out and get retried.
The problemA retried request can start the same agent task again, which wastes model spend and can repeat side effects.
The outcomeBoth requests return the same response id, and the session contains one turn.
What you need first
- Docker installed
- About 4 GB of free disk space
- A provider API key for at least one supported model provider
- Python 3 if you use the Idempotency-Key example
Steps
- Complete the first use case so the API key and base URL are set
- Run
IDEMPOTENCY_KEY=$(python3 -c 'import uuid; print(uuid.uuid4())')to create one key for the logical request - Send the same POST to /v1/responses twice with the header Idempotency-Key set to that value
- Compare the two returned id values
- Use a new key for each new logical request and do not reuse a key with a different body
Prompt for your agent
Using the HarnessRouter repo at https://github.com/HarnessRouter/harnessrouter, send the same POST to <base-url>/v1/responses twice with one Idempotency-Key header. Expected output: both responses have the same id and the session has one turn. Verify that a second request with the same key but a different body returns 409 before reporting success.
Caveat. Changing only the stream value still counts as the same request, so a retry that changes stream will return the first result.
Use this in your AI agent
Ask your agent
Using the Deduped MCP, get the setup steps for HarnessRouter/harnessrouter and "Retry agent tasks without running them twice"
Add Deduped to Claude Code once
claude mcp add --transport http deduped https://dedupedai.com/mcp
Every Monday: the 5 hottest repos and exactly how to use them. Free, one email a week, unsubscribe anytime.
Get them freeShare: X LinkedIn Hacker News Email Copy link
Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer