# Decide whether to retry

<!-- BEGIN GENERATED: usage -->

Does failure describe a transient condition where an identical retry could succeed, given any attempt history?

Use when: You need a yes/no decision after a tool call or request fails and the error text, not a status code, is the only signal you have.

Install `jev-recipes` and set `TYPESAFE_API_KEY` in your server environment. See the [quick start](https://github.com/agencyenterprise/jev-recipes/blob/main/README.md#use-a-recipe).

```ts
import { retryWorthwhile } from 'jev-recipes/retry-worthwhile';

const result = await retryWorthwhile({
  failure: 'HTTP 429 Too Many Requests: rate limit exceeded for this API key. Retry-After: 30.',
  attempt:
    'First attempt, issued immediately after a batch of 50 similar calls to the same endpoint.',
  minConfidence: 0.8,
});
console.log(result);
```

Try the saved example without an API key: `npx jev-recipes demo retry-worthwhile`.

<details>
<summary>Illustrative result from the offline fixture</summary>

```json
{
  "model": "demo-fixture",
  "usage": {
    "input_tokens": 0,
    "output_tokens": 0
  },
  "status": "ready",
  "probability": 0.95,
  "confidence": 0.95,
  "verdict": "retry"
}
```

This saved response illustrates behavior; it is not a model accuracy measurement.

</details>

Related recipes:

- [`failure-kind`](https://jev-recipes.com/recipes/failure-kind/): Use failure-kind to place the failure in one of your own categories when you need more than a retry or stop answer.
- [`repeated-attempt`](https://jev-recipes.com/recipes/repeated-attempt/): Use repeated-attempt to check whether a proposed next attempt is really a fresh approach rather than the same one again.

<!-- END GENERATED: usage -->

## Input

<!-- BEGIN GENERATED: input -->

| Field           | Required | Shape                        |
| --------------- | -------- | ---------------------------- |
| `failure`       | Yes      | string                       |
| `attempt`       | No       | string                       |
| `minConfidence` | No       | number; minimum 0; maximum 1 |

This table is generated from the input schema. Additional text, uniqueness, and policy checks are described below and in the shared options.

<!-- END GENERATED: input -->

See [shared options and behavior](https://github.com/agencyenterprise/jev-recipes/blob/main/recipes/README.md#shared-options-and-behavior) for client configuration, validation, and errors. Types are inferred from this folder's Zod 4 schemas. `attempt` is optional and is omitted from the request when absent.

## Result

`verdict` is `retry` when Jev's yes probability is at least 0.5 and `stop` otherwise. `probability` is that yes probability. `confidence` is the probability of the chosen side, so a 0.1 yes probability yields `stop` with 0.9 confidence.

A result is `ready` when `confidence` meets `minConfidence`. Otherwise it is `review`. Treat a review result as unknown and fall back to your safe default, such as a single bounded retry or surfacing the failure to the user.

## Reuse and calls

Uses the shared gate helper, a single yes/no question. This folder owns the question wording, the outcome descriptions, and the review policy. A live invocation makes one logical Jev request.

## Limits

The recipe reads the failure as text and asks only whether repeating the same attempt could succeed. It does not know your retry budget, backoff policy, or whether the action is idempotent, and it does not say whether a modified attempt with corrected input or permissions would work. Supply prior attempts in `attempt` so repeated identical failures lower the answer. Use [`failure-kind`](https://jev-recipes.com/recipes/failure-kind/) to sort failures into your own categories and [`repeated-attempt`](https://jev-recipes.com/recipes/repeated-attempt/) to check that a proposed next try is actually different.

## Example input

[demo.json](https://github.com/agencyenterprise/jev-recipes/blob/main/recipes/retry-worthwhile/demo.json) contains editable input and a hand-authored response. After installing `jev-recipes`, `npx jev-recipes demo retry-worthwhile` shows an offline illustration, not an accuracy measurement. Use `npx jev-recipes describe retry-worthwhile` to inspect the input and result schemas.

## Measured accuracy

<!-- BEGIN GENERATED: accuracy -->

**Current synthetic measurement; experimental.**

Measured on 60 golden cases against `jev-1.13.0`: **100% accurate** overall.

Recorded 2026-10-04 with package 0.9.12, on the **development** split. Recipe fingerprint: `4325f3b69b7412e092d660cb8a88b35faf53642a1310dff64aabd0557ca88f46`.

Scoring revision: 2.

60/60 cases correct; 60 ready, 0 review, 0 failed. Accuracy among ready cases: 100%.

Latency: p50 95.01 ms, p95 142.84 ms. Usage: 28263 input tokens and 1200 output tokens across 60 logical requests.

Labels: author-synthetic (60 cases): AI-authored synthetic boundary cases for jev-recipes; labels have not had independent human review.

These authored cases are not independent human validation. Related variants are correlated; case-level confidence intervals can overstate independent evidence.

95% case-level accuracy interval: 94% to 100%.

| `minConfidence` | Deferred to review | Accuracy of ready results |
| --------------- | ------------------ | ------------------------- |
| 0.5             | 0%                 | 100%                      |
| 0.6             | 0%                 | 100%                      |
| 0.7             | 0%                 | 100%                      |
| 0.8             | 0%                 | 100%                      |
| 0.9             | 7%                 | 100%                      |
| 0.95            | 33%                | 100%                      |

The lowest threshold reaching 95% accuracy on ready results is 0.5.

Run `npm run eval -- retry-worthwhile` to save new results and update this guide. The full report, including misses, is in [evals/results/retry-worthwhile.json](https://github.com/agencyenterprise/jev-recipes/blob/main/evals/results/retry-worthwhile.json). Accuracy on your own data may differ.

<!-- END GENERATED: accuracy -->

Canonical guide: https://jev-recipes.com/recipes/retry-worthwhile/
Evidence: Current synthetic measurement. Last updated 2026-10-04.
