Skip to main content

Error Handling

StateBase is designed for reliability, but network calls, transient backend issues, and user mistakes still happen. This guide covers every error class and how to handle each one.

Error Classes

The SDKs raise typed errors:

Basic Handling


Retry with Exponential Backoff

The SDK retries transient failures automatically with jittered backoff. To tune it:

Manual Retry Pattern

When you need full control (e.g., long-running agents that shouldn’t auto-retry forever):

Idempotency Keys

To safely retry non-idempotent writes, pass an idempotency key so a retried request doesn’t double-execute:
A retry with the same key returns the original result instead of creating a duplicate turn.

Handling Partial Failures in Agents

For agent code, wrap tool calls and checkpoint around them (see Tool Calling):

Async / TypeScript


Next Steps