Claude Code one-off routine: fire one Sume run once, rerun safely

A one-off routine auto-disables after firing. If you rerun it, send the same Sume Idempotency-Key so a repeat doesn't create a second paid run.

5 min readSume
All posts

A one-off Claude Code routine fires a single time at a chosen moment and then disables itself. If it fails and you rerun it, the saved prompt runs again, so any Sume call inside needs to be safe to repeat. Sume's Format run endpoint accepts an Idempotency-Key: the same key with the same body returns 200 with idempotency_hit: true instead of creating a second run.

Routine behavior is on Anthropic's routines page, read on 2026-10-03; the key semantics are in Sume's Calling a Format.

What does one-off mean?

The routines page says a one-off run auto-disables once it fires, and that a re-run counts against the limits shared with Run now and API fires, 30 per hour per routine. Reruns are therefore normal after an infrastructure error. Also remember that a green status means the session exited cleanly, not that the task worked.

What does the key do on Sume?

POST /v1/formats/{handle}/{slug}/runs takes Idempotency-Key. A repeat with the same body returns 200 and idempotency_hit: true with the original run; a different body under the same key returns 409. Pick a key that names the job, not the attempt.

Key outcomes on a Format run (read 2026-10-03)
RequestResult
New keyRun created
Same key, same body200 with idempotency_hit: true
Same key, different body409

How do I build the key?

Derive it from the thing being made, so every attempt of the routine arrives at the same value. This helper does that and runs offline.

import hashlib, json

def run_key(product_id, brief):
    body = json.dumps({'p': product_id, 'b': brief}, sort_keys=True)
    return 'launch-' + hashlib.sha256(body.encode()).hexdigest()[:24]

k1 = run_key('sku-17', 'autumn launch, 15s')
k2 = run_key('sku-17', 'autumn launch, 15s')
assert k1 == k2
print(k1)

What else should the routine do?

Keep the saved prompt short and explicit about what counts as done: the run receipt shows status, and a Format run that finished with a degraded outcome is not the same as one that finished clean. If the routine cannot confirm the receipt, it should say so in its final message rather than report success, and leave the key unchanged for the next attempt. Retrying with the same key and body costs nothing extra; changing either can.

  • Send generation_spend_cap_usd on the run, at most $500, and never null.
  • Check the receipt and outcome before saying it worked.
  • If the run is long, stop and let a webhook or a later check pick up the result.
  • If the key returned 409, change the body back, not the key.

Sources

Related posts

More in Developers

All Developers posts

Written by Sume