Workflow

Agent Search Fallback Chain Workflow

Workflow that monitors search provider health and automatically switches to fallback providers when primary fails. Zero-downtime search for production agents.

Overview

Production AI agents cannot tolerate search downtime. This workflow runs a health check every 5 minutes against the primary search provider. If the primary fails or returns degraded results, it automatically routes agent search requests to the fallback provider. Logs all fallback events for post-incident review.

Trigger

Health check every 5 minutes. Fallback routing triggered on primary failure.

Schedule

Every 5 minutes (health check)

Workflow Steps

1

Run Primary Provider Health Check

Send a canary query to the primary search provider. Check response time, status code, and result quality (minimum 3 organic results).

2

Update Provider Status Registry

Write the health check result to a status registry. Track consecutive failures to avoid flapping between providers.

3

Route Agent Requests Based on Status

Agent search requests check the status registry. If primary is healthy, route there. If degraded or down, route to fallback.

4

Log Fallback Events

Record every fallback event with timestamp, reason, and query. Generate a daily digest of fallback incidents for the ops team.

Python Implementation

Python
import requests, os, json, time
from datetime import datetime

API_KEY = os.environ["SCAVIO_API_KEY"]
STATUS_FILE = "provider_status.json"

def health_check() -> dict:
    try:
        start = time.time()
        resp = requests.post(
            "https://api.scavio.dev/api/v1/search",
            headers={"x-api-key": API_KEY, "Content-Type": "application/json"},
            json={"query": "test query", "country_code": "us"},
            timeout=10,
        )
        latency = time.time() - start
        data = resp.json()
        healthy = resp.status_code == 200 and len(data.get("organic_results", [])) >= 3
        return {"healthy": healthy, "latency": round(latency, 2), "timestamp": datetime.now().isoformat()}
    except Exception as e:
        return {"healthy": False, "error": str(e), "timestamp": datetime.now().isoformat()}

status = health_check()
print(f"Provider healthy: {status['healthy']}, latency: {status.get('latency', 'N/A')}s")

JavaScript Implementation

JavaScript
const H = {'x-api-key': process.env.SCAVIO_API_KEY, 'Content-Type': 'application/json'};
async function healthCheck() {
  try {
    const start = Date.now();
    const r = await fetch('https://api.scavio.dev/api/v1/search', {method:'POST', headers:H, body:JSON.stringify({query:'test query', country_code:'us'})});
    const d = await r.json();
    return {healthy: r.ok && (d.organic_results||[]).length >= 3, latency: Date.now()-start, timestamp: new Date().toISOString()};
  } catch (e) { return {healthy:false, error:e.message, timestamp:new Date().toISOString()}; }
}
const s = await healthCheck();
console.log('Healthy: '+s.healthy+', Latency: '+s.latency+'ms');

Platforms Used

Google

Web search with knowledge graph, PAA, and AI overviews

YouTube

Video search with transcripts and metadata

Reddit

Community, posts & threaded comments from any subreddit

Frequently Asked Questions

Production AI agents cannot tolerate search downtime. This workflow runs a health check every 5 minutes against the primary search provider. If the primary fails or returns degraded results, it automatically routes agent search requests to the fallback provider. Logs all fallback events for post-incident review.

This workflow uses a health check every 5 minutes. fallback routing triggered on primary failure.. Every 5 minutes (health check).

This workflow uses the following Scavio platforms: google, youtube, reddit. Each platform is called via the same unified API endpoint.

Yes. Scavio's free tier includes 250 credits per month with no credit card required. That is enough to test and validate this workflow before scaling it.

Agent Search Fallback Chain Workflow

Workflow that monitors search provider health and automatically switches to fallback providers when primary fails. Zero-downtime search for production agents.