Name the smallest failing boundary
The three integration paths fail in different forms, but recovery follows one rule: classify the boundary before choosing a response. A successful API call can produce a bad outcome, while a failed call can leave the workflow safe. Do not treat every symptom as "Jev is down."
API failure: an external request that does not produce a valid typed response within the workflow's operational contract. Authentication, request validation, connection failure, timeout, throttling, overload, and malformed success data belong here. A semantic failure is a structurally valid answer that disagrees with the reviewed meaning. A policy failure applies an unsuitable threshold or composition rule to a reasonable answer. A downstream failure occurs after policy, such as writing the right route to the wrong ticket.
These classes need different evidence and fixes. A 422 identifies a payload problem before normal inference. A returned billing label followed by a technical queue points to policy or mapping. A wrong label with sufficient state and clear criteria is a semantic evaluation case. A low refund probability caused by an omitted transaction message is a state-construction failure.
Trace this example from input to result
Customer choice
A customer submits a service-impact ticket while the provider is overloaded.
Request or event
The worker sends one evaluation request with an absolute workflow deadline.
Backend behavior
The service receives 529, uses one bounded delayed attempt, then preserves the ticket in general review.
Customer sees
The customer keeps a valid case and receives support later rather than an incorrect automated action.
Diagnostic reasoning
Use status, attempts, Retry-After, request ID, queue time, state version, model metadata, policy, and route-write result to isolate the boundary.
| Customer sees | Application does | Jev returns |
|---|---|---|
| A case waits in review during overload | Stops within the deadline and records a degraded reason | No usable answer because the API failed |
| A wrong queue after a valid answer | Compares raw answer, threshold, and label mapping | A typed answer that may be correct or semantically wrong |
| A clarification request | Detects required evidence was absent before evaluation | No authoritative replacement for missing application facts |
type FailureBoundary =
| "request"
| "semantic"
| "policy"
| "downstream";
function fallback(boundary: FailureBoundary) {
if (boundary === "request") return "general-review";
if (boundary === "semantic") return "labeled-evaluation-review";
if (boundary === "policy") return "policy-replay";
return "stop-writes-and-reconcile";
}
The function is intentionally conservative. A production implementation also records the original ticket, logical decision ID, and current version. A fallback is a product behavior, not an exception-swallowing technique; it needs an owner, capacity plan, and customer-visible expectation.
Retry only failures that can improve without changing meaning
transient failure: a condition that may succeed later with the same valid request, such as temporary connection loss, throttling, or overload. Native SDK defaults treat 408, 429, 5xx responses, connection errors, and timeouts as retry candidates. Authentication, permission, missing endpoint, and request validation failures require correction. A response-contract failure may require incident handling, but repeatedly requesting data until one malformed response happens to pass validation is unsafe.
Respect Retry-After or retry-after-ms when the requested wait fits the remaining workflow deadline. Otherwise take the declared fallback. Exponential backoff reduces repeated pressure, and jitter prevents many workers from returning together. A 429 indicates a rate boundary; reduce admission or concurrency as well as delaying. A 529 indicates temporary overload; immediate fan-out worsens the condition.
The three supported surfaces have different retry behavior. The native JavaScript SDK defaults to two retries, a 10-second timeout per attempt, 500-millisecond initial backoff, and no total retry budget. Its accepted server-directed delay is capped at 60 seconds. The native Python SDK also defaults to two retries and a 10-second HTTP timeout, but has a 30-second retry admission budget. Vercel AI SDK core defaults to two retries with backoff beginning at two seconds; evaluation has no dedicated timeout option in the inspected implementation, so callers provide an AbortSignal.
Do not merge those defaults into a fictional universal Jev policy. Set an application deadline that covers queue wait, state retrieval, attempts, backoff, validation, policy, and the downstream write. Decide which layer owns retries. If an SDK retries, a serverless function retries, and a queue redelivers independently, one logical ticket can create many provider calls during the incident.
Most requests succeed but customers time out
SDK attempts=3 · queue redeliveries=2 · provider success 96% · caller p95 exceeds deadlineCount logical decisions and physical API attempts separately. Disable duplicate retry ownership, propagate an absolute deadline, honor overload guidance only when time remains, and move expired work to review. Provider success rate hides results that arrived after callers abandoned them and duplicate attempts that consumed capacity.
Build a safe failure policy for each class
Authentication failures may appear as 401 or 403 across documented and observed routes. Classify the SDK exception or status family together with the structured error body rather than assuming every invalid credential uses one code. Fix secret presence, scope, or environment selection; do not retry the same invalid key. A 400 or 422 needs the offending request field corrected. Preserve the request ID when available.
Connection and timeout errors leave ambiguity about whether the server received or completed the evaluation. Evaluation itself is intended to be side-effect free, but logs, meters, and later application writes may duplicate. Use a logical operation ID and make the downstream route write idempotent. Before applying an answer, compare the current ticket version with the version used to build state; a customer reply can make a late answer stale.
Rate limits and overload need capacity responses. Bound the queue, cap concurrency, deduplicate identical in-flight work, and establish a maximum queue age. A queue absorbs a burst only when arrival eventually falls below processing capacity. Old tickets should enter review or be reevaluated from fresh state rather than applying a route based on yesterday's message.
Semantic failures belong in the labeled evaluation set. Preserve the exact state after retrieval and redaction, complete questions, requested and returned model information, and raw distribution. Policy failures can often be replayed over stored answers without another model call. Downstream failures require mapping, authorization, idempotency, and database evidence. This division lets teams repair the right system.
Safe degradation follows consequence. Reversible ticket routing can use a general queue. Optional ranking can show deterministic order. Missing evidence can trigger clarification. Refunds, access changes, deletion, and other high-risk actions should pause for deterministic checks and human authorization. Fail-open versus fail-closed for a safety gate is a product risk choice; document the harm in each direction.
Recover without recreating the incident
An operating record should include logical decision ID, attempt count, request IDs, requested and returned model metadata, state and retrieval versions, safe state hash, question version, response or error class, usage, latency, policy version, fallback action, and downstream outcome. Avoid raw customer bodies in ordinary logs. Alert on error rate, attempts per decision, queue age, fallback volume, and correction rate.
During containment, disable automatic routing while preserving ticket intake. Depending on backlog and data policy, keep shadow evaluation for diagnosis or pause calls completely. Fix credentials or request shape before a canary. For rate limits and overload, verify provider recovery, lower concurrency, and release a small cohort. Watch physical attempts, queue drain, latency, and route correction before expanding traffic.
Recovery should not apply stale successful answers from the incident window blindly. Rebuild state for tickets that changed, enforce a maximum decision age, and keep idempotent route writes. Distinguish unavailable decisions, late decisions, duplicated attempts, semantic errors, policy errors, and downstream write failures in the post-incident analysis.
Dig deeperPrevent distributed retry amplification+
Model the worst case by multiplying attempts at every layer, including client, function, workflow engine, and broker redelivery. Carry an absolute deadline and logical operation ID across services. A downstream service should refuse work that cannot finish before that deadline. Admission control protects healthy work, while a circuit breaker directs new requests to fallback during sustained failure. Recover the circuit gradually with randomized probes so the backlog does not produce another synchronized spike.
Write a failure and recovery policy
Your answers stay in this browser. Write enough that another engineer could continue the investigation.