A retry limit answers “How many more attempts may this request make?” It does not answer “Should the next thousand requests still call this route?” When failures persist across requests, that second question becomes the important one.
The CometAPI error-handling guide recommends combining bounded retries with concurrency control, a circuit breaker, and monitoring for sustained fallback growth. Its circuit-breaker advice is to temporarily stop calling a repeatedly failing route—not a claim that the platform automatically isolates outages for your application.
Here is an application-owned runbook for turning that recommendation into a pause-and-recovery decision. The trip criteria and recovery policy below are design recommendations, not provider defaults.
Classify before counting a route failure
Keep status and error code together. In the guide’s classification:
- 401: fix authentication; retrying or changing models does not repair the credential.
- Path-related 404: fix the endpoint. A model-unavailable response needs its own verified signal before it becomes a fallback condition.
- 500 with
invalid_requestorinvalid_request_error: fix the payload, rather than repeatedly sending it elsewhere. - 429 or a temporary 500/503/504/524: consider bounded retries with backoff and jitter, within the request’s total latency budget.
Do not mix malformed requests and invalid credentials into a “provider is unhealthy” counter. Stop those affected requests and route the problem to configuration or request-validation repair. Otherwise, a breaker can conceal a deployment bug while removing a usable model route.
Decide when retries are no longer enough
A practical trip policy should combine persistence, scope, and pressure, rather than opening the breaker after one isolated error.
| Signal to inspect | Policy decision to make |
|---|---|
| Retryable failures across independent requests | Define a rolling observation window, failure threshold and minimum sample count appropriate to this workload. |
| Repeated 429s and high in-flight concurrency | Reduce bursts; decide when continued attempts warrant a temporary pause rather than more waiting workers. |
| Sustained fallback growth | Investigate the primary route even if fallback keeps end-user completion rates acceptable. |
| Failures across several routes | Investigate shared dependencies before assuming each model has an independent outage. |
Record the scope of the pause explicitly: which configured route stops receiving normal traffic, which observations triggered it, and who owns escalation. A model label alone should not be treated as proof of the failure boundary.
The inference behind this policy is straightforward: individually bounded requests can still produce substantial aggregate retry traffic. A route-level pause addresses admission of new work, which a per-request retry cap does not.
Make recovery an explicit state transition
Use a small state machine whose parameters are chosen and tested for the application:
- Closed: admit normal traffic with bounded concurrency and one total retry/fallback deadline. Account for SDK retries as well as application retries.
- Open: stop normal calls to the affected route for a configured cooldown. Allow only a previously tested compatible fallback, or return a controlled failure. Opening the breaker must not start an unbounded fallback chain.
- Half-open: after cooldown, admit a capped set of safe probes—not every waiting request. Define what counts as recovery and what sends the route back to open.
- Resume gradually: restore traffic under concurrency limits while watching transient failures and fallback rate. Escalate repeated reopenings rather than cycling silently forever.
There is no universal trip count or cooldown established by the cited guide. A sparse batch workload and a high-volume interactive service need different observation windows; neither should infer recovery merely from elapsed time.
Fallback also needs a stop condition. The source requires tested input/output and capability compatibility and warns about tool actions, writes and partial streams. If replay could duplicate an action, resume from an application checkpoint or fail in a controlled way instead of blindly starting over on another model.
Verify the runbook before enabling it
In staging, inject classified failures and check that configuration errors fail without retries, sustained transient errors stop normal route admission, cooldown permits only capped probes, and failed probes reopen the breaker. Test that recovery does not release all queued work at once.
Log status, error code, request ID, model, attempt, delay and fallback reason without secrets. Add application records for breaker transitions and probe outcomes so an operator can explain why a route was paused and why it resumed.
The useful success criterion is not “fallback returned something.” It is that unhealthy-route traffic stops under a defined policy, recovery is tested under controlled load, and an exhausted deadline or unsafe replay produces an explicit failure rather than another attempt.