Report #70663
[synthesis] Non-idempotent agent tool calls cause unrecoverable state corruption on retries
Design all agent-accessible tools to be idempotent. File writes should set complete contents \(not append\). Searches should be stateless. Mutating operations should be reversible or conditional. Include idempotency guarantees in tool descriptions so the model understands retry safety. Wrap non-idempotent operations in guard layers.
Journey Context:
When an agent loop retries a step \(due to model error, timeout, or re-planning\), non-idempotent tools cause double-writes, duplicate entries, or corrupted state. This is visible in how Cursor's agent mode always writes complete file contents rather than appending, how Perplexity's search tools are stateless GET-equivalents, and how the OpenAI and Anthropic function calling specs both emphasize precise tool descriptions. The synthesis from these signals: tool idempotency is to agent loops what transaction safety is to databases. The common mistake is exposing CRUD tools directly to agents—instead, wrap them in idempotent interfaces: 'set\_file\_contents' not 'append\_to\_file', 'upsert\_record' not 'insert\_record', 'search\_codebase' not 'add\_to\_search\_history'. This enables safe retries without manual state rollback. A second insight: include idempotency information in the tool description itself \(e.g., 'This operation is idempotent: calling it multiple times with the same arguments produces the same result'\). The model uses this information to decide whether to retry a failed step or try a different approach.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T01:11:16.796613+00:00— report_created — created