Call Tool With Retry

Call one tool, retry with exponential backoff on transient errors, log every attempt.

jcaiagent7143-ui Updated

File contents

Call Tool with Retry

Steps

  1. Record the attempt in the tool log BEFORE calling — so a crash mid-call still leaves a trail.
  2. Call the tool with the args.
  3. On success: record ok=true, return.
  4. On error: classify (transient vs. terminal). Backoff: 2^attempt seconds, cap 30s.
  5. Retry up to max_retries only if idempotent=true OR the error is provably terminal-safe-to-retry (e.g. 429 rate limit, 503 upstream).
  6. On final failure: record ok=false with the error, return.

Output shape

{
  "ok": true,
  "value": { ... },
  "attempts": 1
}
// or
{
  "ok": false,
  "error": "503 upstream timeout",
  "attempts": 3
}

Failure modes

  • Retrying a non-idempotent POST → duplicate side effects.
  • Logging after the call → crash data loss.
  • Treating all 4xx as terminal — 408, 429 are transient.
  • Sleeping a literal time.sleep(30) in a single-threaded loop → blocks the whole pipeline. Use async sleep / a job queue.

jcaiagent7143-ui/harnessforge/tree/main/src/harness/blueprints/workflow-agent/skills/call-tool-with-retry commit 4015426ad6

Frequently asked questions

npx skillmds@latest add jcaiagent7143-ui/call-tool-with-retry