{
 "_about": "Unedited Pareto answer captured from the Unbiased API (POST https://api.unbiased.ai/v1/chat/completions, model \"pareto\", one user message, default settings) on October 20, 2026 for the Prove-It landing pages. Prompt and answer text are verbatim; usage is as the API reported it, and cost_usd is the API's reported cost (equal to the published per-token rates). Rendered by scripts/landing-pages.mjs.",
 "prompt": "Write a Python function call_with_retry(fn, max_attempts=4) for an API client. It calls fn() and returns its result. If fn() raises RateLimited (an exception class with a retry_after attribute, in seconds), it waits retry_after seconds with time.sleep and tries again. After max_attempts failed attempts it re-raises the last RateLimited. Any other exception propagates immediately. Reply with the code only.",
 "answer": "```python\nimport time\n\ndef call_with_retry(fn, max_attempts=4):\n    for attempt in range(max_attempts):\n        try:\n            return fn()\n        except RateLimited as e:\n            if attempt == max_attempts - 1:\n                raise\n            time.sleep(e.retry_after)\n```",
 "model": "pareto-26.10",
 "captured_at": "2026-10-20T14:14:08.627423+02:00",
 "usage": {
  "prompt_tokens": 92,
  "completion_tokens": 318,
  "total_tokens": 410,
  "cost_usd": 0.0010912
 },
 "checks": {
  "file": "test_retry.py",
  "source": "import time\n\nclass RateLimited(Exception):\n    def __init__(self, retry_after):\n        self.retry_after = retry_after\n\nslept = []\ntime.sleep = slept.append  # record waits instead of sleeping\n\ndef flaky(failures, result=\"ok\"):\n    calls = []\n    def fn():\n        calls.append(1)\n        if len(calls) <= failures:\n            raise RateLimited(2)\n        return result\n    return fn, calls\n\nfn, calls = flaky(2)\nassert call_with_retry(fn) == \"ok\" and len(calls) == 3 and slept == [2, 2]\n\nslept.clear(); fn, calls = flaky(9)\ntry:\n    call_with_retry(fn, max_attempts=3); assert False, \"should re-raise\"\nexcept RateLimited:\n    assert len(calls) == 3 and slept == [2, 2]\n\ndef broken():\n    raise ValueError(\"bad request\")\nslept.clear()\ntry:\n    call_with_retry(broken); assert False, \"should propagate\"\nexcept ValueError:\n    assert slept == []\n\nprint(\"all checks passed\")\n",
  "after": "all checks passed",
  "note": "We put the answer’s function right after the RateLimited class and the sleep stub, then ran the checks with Python 3. The stub records each wait instead of sleeping. The checks cover a call that succeeds on the third try, one that runs out of attempts, and an unrelated error that must not be retried."
 }
}
