Skip to main content

Multi-Tool Recovery Demo

This demo shows how StateBase handles a realistic production scenario: an AI travel agent that needs to call multiple external APIs (flights, hotels, weather) to complete a bookingβ€”and what happens when those APIs fail.

The Scenario

User Goal: Book a weekend trip to San Francisco Agent Tasks:
  1. Search for flights
  2. Check hotel availability
  3. Get weather forecast
  4. Confirm booking
The Problem: APIs are unreliable in production. What happens when they fail?

Without StateBase: Cascading Failures

Here’s what happens in a traditional agent when APIs fail:
User Experience:

With StateBase: Graceful Recovery

StateBase checkpoints progress after each successful step:
User Experience:

The Recovery Flow

Here’s what happens behind the scenes:

Attempt 1: Partial Success

Attempt 2: Full Success


Code Walkthrough

Let’s break down the key StateBase features used:

1. Checkpointing After Each Step

Why this matters: If the next API call fails, we don’t lose this data.

2. Checking for Cached Data

Why this matters: Saves money and time by not repeating successful operations.

3. Graceful Degradation

Why this matters: Not all data is critical. Distinguish between must-have and nice-to-have.

4. Rollback on Critical Failures

Why this matters: Prevents corrupted state from breaking the entire conversation.

Full Working Example

Here’s a complete, runnable example:
Sample Output:

Key Takeaways

  1. Checkpoint after each successful step β†’ Don’t lose progress
  2. Check cache before retrying β†’ Save money and time
  3. Distinguish critical vs optional β†’ Graceful degradation
  4. Roll back on corruption β†’ Prevent cascading failures

Try It Yourself

  1. Copy the code above
  2. Replace "your-key" with your StateBase API key
  3. Run it multiple times to see different failure scenarios
  4. Observe how StateBase preserves progress across retries

Next Steps


The Bottom Line: Production AI agents deal with unreliable external systems. StateBase ensures that one API timeout doesn’t force users to start over from scratch.