Workflow

Agent Context Bridge Workflow

Serialize daily search results to JSON for agent consumption. Bridge live SERP data into multi-step agent context windows.

Overview

This workflow serializes daily search results into compact JSON files that AI agents consume as context in their workflows. Instead of agents making real-time search calls during execution (which adds latency and cost), this pipeline pre-fetches search data for common queries and stores it in agent-optimized JSON format. Agents load the pre-fetched context at the start of their run, reducing per-execution API calls while keeping data fresh within 24 hours.

Trigger

Cron schedule (daily at 5:00 AM UTC)

Schedule

Runs daily at 5:00 AM UTC

Workflow Steps

1

Load agent query templates

Read the list of queries that agents commonly use from the agent configuration registry.

2

Execute searches and collect results

Run each query against Scavio Google search and collect organic results, AI Overviews, and PAA data.

3

Compress and serialize results

Strip unnecessary fields, truncate long text, and serialize results into compact JSON for context injection.

4

Write to agent context store

Save the serialized results to the shared context store that agents read from at execution time.

5

Log freshness metadata

Record timestamps and query counts so agents can verify context freshness before using it.

Python Implementation

Python
import requests
import json
from pathlib import Path
from datetime import datetime

API_KEY = "your_scavio_api_key"

# Queries that agents commonly use
AGENT_QUERIES = [
    "best search API for AI agents 2026",
    "web search API pricing comparison",
    "structured SERP data providers",
    "MCP search tool integration",
    "AI agent web grounding methods",
]

def fetch_and_compress(query: str) -> dict:
    res = requests.post(
        "https://api.scavio.dev/api/v1/search",
        headers={"x-api-key": API_KEY},
        json={"platform": "google", "query": query, "ai_overview": True},
        timeout=15,
    )
    res.raise_for_status()
    data = res.json()

    # Compress for agent consumption: only essential fields
    return {
        "q": query,
        "organic": [
            {"t": r.get("title", "")[:80], "s": r.get("snippet", "")[:150], "u": r.get("link", "")}
            for r in data.get("organic", [])[:5]
        ],
        "aio": (data.get("ai_overview") or {}).get("text", "")[:400],
        "paa": [q.get("question", "") for q in data.get("people_also_ask", [])[:3]],
    }

def run():
    date = datetime.utcnow().strftime("%Y-%m-%d")
    context_dir = Path("agent_context")
    context_dir.mkdir(exist_ok=True)

    results = [fetch_and_compress(q) for q in AGENT_QUERIES]
    context = {
        "fetched_at": datetime.utcnow().isoformat(),
        "date": date,
        "queries": len(results),
        "data": results,
    }

    context_path = context_dir / "latest.json"
    context_path.write_text(json.dumps(context, indent=2))
    # Also archive by date
    (context_dir / f"context_{date}.json").write_text(json.dumps(context, indent=2))

    total_chars = sum(len(json.dumps(r)) for r in results)
    print(f"Agent context bridge {date}: {len(results)} queries, {total_chars:,} chars total")
    for r in results:
        print(f"  {r['q'][:50]}: {len(r['organic'])} results, AIO={'yes' if r['aio'] else 'no'}")

if __name__ == "__main__":
    run()

JavaScript Implementation

JavaScript
const API_KEY = "your_scavio_api_key";
const QUERIES = ["best search API for AI agents 2026", "web search API pricing comparison", "MCP search tool integration"];

async function fetchAndCompress(query) {
  const res = await fetch("https://api.scavio.dev/api/v1/search", {
    method: "POST",
    headers: { "x-api-key": API_KEY, "content-type": "application/json" },
    body: JSON.stringify({ platform: "google", query, ai_overview: true }),
  });
  if (!res.ok) throw new Error(`scavio ${res.status}`);
  const data = await res.json();
  return {
    q: query,
    organic: (data.organic ?? []).slice(0, 5).map((r) => ({ t: (r.title ?? "").slice(0, 80), s: (r.snippet ?? "").slice(0, 150), u: r.link ?? "" })),
    aio: ((data.ai_overview ?? {}).text ?? "").slice(0, 400),
    paa: (data.people_also_ask ?? []).slice(0, 3).map((q) => q.question ?? ""),
  };
}

const results = [];
for (const q of QUERIES) results.push(await fetchAndCompress(q));
const totalChars = results.reduce((s, r) => s + JSON.stringify(r).length, 0);
console.log(`Agent context: ${results.length} queries, ${totalChars.toLocaleString()} chars`);

Platforms Used

Google

Web search with knowledge graph, PAA, and AI overviews

Frequently Asked Questions

This workflow serializes daily search results into compact JSON files that AI agents consume as context in their workflows. Instead of agents making real-time search calls during execution (which adds latency and cost), this pipeline pre-fetches search data for common queries and stores it in agent-optimized JSON format. Agents load the pre-fetched context at the start of their run, reducing per-execution API calls while keeping data fresh within 24 hours.

This workflow uses a cron schedule (daily at 5:00 am utc). Runs daily at 5:00 AM UTC.

This workflow uses the following Scavio platforms: google. 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 Context Bridge Workflow

Serialize daily search results to JSON for agent consumption. Bridge live SERP data into multi-step agent context windows.