Idempotency Failure
Agent repeats a write action and creates duplicates.
12 patterns for this goal
Tool invocation fails when agents pass wrong arguments, use wrong ID or key formats, misunderstand tool semantics, fail to page results, or retry non-idempotent operations without side-effect awareness. The 12 invocation patterns documented here cover the challenge of calling tools correctly β from parameter validation through pagination, query scoping, timezone handling, and understanding when operations are idempotent. Invocation failures are particularly common because agents must understand and respect tool contracts (what parameters it accepts, what they mean, what side effects occur), and misunderstanding any part of that contract leads to failed or incorrect tool calls.
The 12 invocation patterns describe systems where tool semantics are implicit: agents guess what parameters mean, whether operations are idempotent, whether queries are scoped correctly, without explicit validation or documentation. Tool documentation exists but is incomplete, and agents must infer semantics from example usage or error messages. Most teams discover invocation failures only after agents start calling tools incorrectly and cascading failures reveal the misunderstandings. The mitigation that recurs across nearly every pattern is explicit contract validation: use API contracts to specify required parameters and their formats, document idempotency and side effects explicitly, test tool invocation with correct and incorrect parameters, and add agent-level validation before calling tools.
Per Wrong Argument Format, validate argument types and formats before calling tools: check that IDs are strings not integers, dates are ISO 8601 not user-locale format, amounts are in correct currency. Use API contracts (OpenAPI, schema) to specify expected formats and validate against them.
Per Pagination Failure, agents should check for pagination metadata (e.g., has_next, next_token), and iterate through all pages rather than assuming first page is complete. Test pagination by requesting large result sets and verifying all results are retrieved.
Per Idempotency Failure, ask the tool documentation: is calling this operation twice with same parameters safe? If yes, idempotent; if no, non-idempotent. Never retry non-idempotent operations automatically β log the failure and require manual intervention or explicit retry logic that accounts for side effects.
Partially β per Over Broad Query, agents should scope queries before calling (filter by date range, category, etc.) rather than retrieving everything and filtering client-side. Over-broad queries waste resources and cost; filter server-side first.
| Pattern | Mechanism |
|---|---|
| Idempotency Failure | Non-idempotent operation is retried; retries cause duplicate writes or state corruption |
| Missing Required Parameter | Tool requires a parameter; agent doesn’t provide it; call fails |
| Over Broad Query | Query is not scoped; returns expensive results; agent wastes resources and cost |
| Over Narrow Query | Query is over-scoped; misses relevant results; agent gets incomplete data |
| Pagination Failure | Results are paginated; agent doesn’t iterate through pages; misses data |
| Partial Result Misuse | First page of paginated results is used as if it’s complete; missing data treated as not-found |
| Rate Limit/Timeout Mishandling | Tool returns rate-limit or timeout error; agent doesn’t backoff appropriately |
| Side Effect Misunderstanding | Agent doesn’t understand or underestimates operation side effects; cascading failures result |
| Wrong Argument Format | Argument format is wrong (string vs integer, ISO date vs locale date); tool parsing fails |
| Wrong Date Range/Timezone | Date range is wrong timezone; agent retrieves data from wrong time period |
| Wrong ID/Key Usage | Agent uses wrong ID format or references wrong ID; retrieves wrong record |
| Wrong Units/Currency | Units or currency are mismatched; calculations are incorrect |
Total: 12 patterns
Agent repeats a write action and creates duplicates.
Agent omits ID, date range, filter, auth scope, or tenant.
Agent retrieves too much data and reasons over irrelevant records.
Agent misses correct data due to overly strict filters.
Agent Reads Only the First Page of a Paginated or Length-Capped Tool Response and Proceeds as if That Page Were the Complete Result Set
Agent treats partial/incomplete output as complete.
Agent fails silently or retries destructively after API limit/timeout.
Agent misses that a tool sends email, bills, deploys, or notifies.
Agent sends invalid JSON, enum, type, or schema.
Agent queries or schedules using incorrect date/time boundaries.
Agent uses customer ID as account ID, message ID as thread ID, etc.
Agent sends cents vs dollars, UTC vs local, kg vs grams.