Recipe catalog / retry-worthwhile
Decide whether to retry
Does failure describe a transient condition where an identical retry could succeed, given any attempt history?
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.
Explore this recipe interactively ยท Source and implementation guide
Use retry-worthwhile in TypeScript
Install with npm install jev-recipes. Requires Node.js 22.9 or newer and ES modules. Set TYPESAFE_API_KEY in your server environment for live calls, which send input to TypeSafe and use API quota. See the installation guide.
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);
Input contract
| Field | Type | Needed |
|---|---|---|
| failure | string | Required |
| attempt | string | Optional |
| minConfidence | number | Optional |
Full input and result schemas
{
"input": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"failure": {
"type": "string"
},
"attempt": {
"type": "string"
},
"minConfidence": {
"type": "number",
"minimum": 0,
"maximum": 1
}
},
"required": [
"failure"
]
},
"result": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"model": {
"type": "string"
},
"usage": {
"type": "object",
"properties": {
"input_tokens": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"output_tokens": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"input_tokens",
"output_tokens"
],
"additionalProperties": false
},
"status": {
"type": "string",
"enum": [
"ready",
"review"
]
},
"probability": {
"type": "number",
"minimum": 0,
"maximum": 1
},
"confidence": {
"type": "number",
"minimum": 0,
"maximum": 1
},
"verdict": {
"type": "string",
"enum": [
"retry",
"stop"
]
}
},
"required": [
"model",
"usage",
"status",
"probability",
"confidence",
"verdict"
],
"additionalProperties": false
}
}Saved example result
This hand-authored response demonstrates the contract. It is not a model accuracy measurement. Run it without an API key: npx jev-recipes demo retry-worthwhile.
{
"model": "demo-fixture",
"usage": {
"input_tokens": 0,
"output_tokens": 0
},
"status": "ready",
"probability": 0.95,
"confidence": 0.95,
"verdict": "retry"
}
Evaluation evidence
jev-1.13.0 / 2026-09-27 / 40 held-out cases
Scoring revision 1.
39 ready decisions, with 100% accuracy among those decisions.
95% case-level interval: 91% to 100%. Related synthetic cases are correlated.
Measured on these synthetic cases
This measurement uses an earlier or unverified recipe or evaluator version. Rerun with the current recipe and evaluator before treating these numbers as current.
Use the evaluation guide to measure this decision on your own labeled cases.
Limitations
- Judges the failure text as written. It does not know your retry budget, backoff policy, or whether the action is safe to repeat.
- Says whether an identical retry could succeed, not whether a modified attempt would. Fixing inputs or permissions is a different decision.
Related 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: Use repeated-attempt to check whether a proposed next attempt is really a fresh approach rather than the same one again.