Retrying a failed tool call is usually safe — but not always. If a "charge the customer" call actually succeeded on the server side and only the response got lost (a network blip), blindly retrying it charges the customer twice. The standard fix is an idempotency key: every logical call gets a stable key, and the runtime only ever actually executes the call the first time a given key is seen — every later retry with the same key reuses whatever the first attempt already did, rather than doing it again.
You're given the idempotency key for every attempted call, in order (a retry of the same logical call reuses the same key). Implement dedupe_idempotent_calls(call_ids). For each call, decide whether it should actually execute (True, the first time this exact key is seen) or be treated as a no-op that reuses the earlier result (False, every later occurrence of an already-seen key). Return (call_id, executed) pairs, in the original order.
One set of keys already seen is the entire piece of state you need. A key executes iff it isn't already in that set — check first, then add it to the set either way (adding an already-present key to a set is a harmless no-op).
The two occurrences don't need to be adjacent — a retry of the same key can happen after any number of other, different calls in between. Membership in the seen-set is what matters, not position in the log.
No results yet
Run your code to check it against the examples, or submit to run every test.