Examples for real agent workflows

Drop-in code for the things teams are actually shipping in 2026 — code interpreters, data analysis, SQL against any file, ephemeral Postgres, Supabase previews, headless browsers, Next.js previews, PR-review bots. Grab a snippet, add your API key, ship.

Code-interpreter agents

šŸ¤–

Claude code-execution tool

Plug Podflare into Claude's native `code_execution` tool. One helper call turns every tool_use block into a sandboxed run.

PythonAnthropic
from anthropic import Anthropic
from podflare import Sandbox
from podflare.integrations.anthropic import handle_code_execution_tool_use

client = Anthropic()

with Sandbox() as sbx:
    messages = [
        {"role": "user",
         "content": "Download this CSV and summarize: https://ex.com/sales.csv"}
    ]
    while True:
        resp = client.messages.create(
            model="claude-opus-4-7",
            max_tokens=2048,
            tools=[{"type": "code_execution_20250825",
                    "name": "code_execution"}],
            messages=messages,
        )
        messages.append({"role": "assistant", "content": resp.content})
        if resp.stop_reason != "tool_use":
            break
        # run every code_execution call in our sandbox
        results = [
            handle_code_execution_tool_use(b, sbx)
            for b in resp.content
            if b.type == "tool_use" and b.name == "code_execution"
        ]
        messages.append({"role": "user", "content": results})

    print(resp.content[0].text)
⚔

Vercel AI SDK runCode tool

Drop-in tool for `generateText` / `streamText`. Works with any Vercel-AI-SDK model — OpenAI, Anthropic, Mistral, ...

TypeScriptVercel AI
import { generateText, tool } from "ai";
import { openai } from "@ai-sdk/openai";
import { z } from "zod";
import { podflareRunCode } from "podflare/ai-sdk";

const pf = podflareRunCode({ template: "python-datasci" });

const result = await generateText({
  model: openai("gpt-4o"),
  tools: {
    runCode: tool({
      description: pf.description,
      parameters: z.object({
        code: z.string(),
        language: z.enum(["python", "bash"]).optional(),
      }),
      execute: pf.execute,
    }),
  },
  prompt: "Fetch the top 5 HN stories and chart their scores.",
  maxSteps: 10,
});

await pf.close();
console.log(result.text);
🧠

Persistent REPL across chat turns

Load data once, query across many agent turns. Files and variables survive — just like a Jupyter kernel.

Pythonchat
"""Persistent Python REPL across chatbot turns.

Filesystem + variables survive between run_code() calls. The agent
can load a dataframe once, then query it across many messages
without re-uploading.
"""
from podflare import Sandbox

sbx = Sandbox(template="python-datasci", idle_timeout_seconds=1800)

# Turn 1 — load data
sbx.run_code("""
import pandas as pd
df = pd.read_parquet('https://ex.com/events.parquet')
print(df.shape)
""")

# Turn 2 — df is still there
r = sbx.run_code("print(df.head().to_string())")
print(r.stdout)

# Turn 3 — even a file is still there
sbx.run_code("df.head(100).to_csv('/tmp/sample.csv')")
sbx.run_code("import os; print(os.listdir('/tmp'))")

sbx.close()

Data & analytics

šŸ“Š

Chart → base64 for agent replies

matplotlib / seaborn chart returned as a data URL the agent can embed in a reply or Slack block.

Pythonpandas
"""Return a matplotlib chart as base64 so the agent can embed it
in its reply (e.g. markdown image or data URL in a React app).
"""
from podflare import Sandbox

sbx = Sandbox(template="python-datasci")

r = sbx.run_code("""
import matplotlib.pyplot as plt, numpy as np, io, base64
x = np.linspace(0, 4 * np.pi, 200)
plt.plot(x, np.sin(x))
plt.title('sin(x)')
buf = io.BytesIO()
plt.savefig(buf, format='png', bbox_inches='tight')
print(base64.b64encode(buf.getvalue()).decode())
""")
png_b64 = r.stdout.strip()
print(f"![chart](data:image/png;base64,{png_b64[:80]}…)")
sbx.close()
šŸ¦†

Ad-hoc SQL on any CSV / parquet (DuckDB)

Query remote files like tables — no DB server, no infra per tenant. Ideal for 'analyze this dataset' chatbots.

PythonSQL
"""Let the agent run SQL against a CSV/parquet without a DB server.
Perfect for 'analyze this file' chatbots — no infra per tenant.
"""
from podflare import Sandbox

sbx = Sandbox(template="python-datasci")

sbx.run_code("pip install duckdb -q")
r = sbx.run_code("""
import duckdb
con = duckdb.connect()
con.execute("INSTALL httpfs; LOAD httpfs;")
q = """
SELECT org, count(*) AS signups
FROM 'https://ex.com/users.csv'
WHERE created_at >= '2026-01-01'
GROUP BY org ORDER BY signups DESC LIMIT 10
"""
print(con.execute(q).df().to_string())
""")
print(r.stdout)
sbx.close()

Database work

🐘

Ephemeral Postgres per session

Fresh Postgres per sandbox for testing generated migrations, running unsafe SQL, or demo'ing schema changes.

PythonPostgres
"""Fresh Postgres per sandbox. Agent writes + tests migrations, runs
fuzzy SELECTs, inserts seed data — all isolated, all thrown away when
the sandbox ends. Great for 'test my schema' tools and AI DB migrations.
"""
from podflare import Sandbox

sbx = Sandbox(template="python-datasci")

sbx.run_code("""
import subprocess
subprocess.run(['apt-get','install','-y','-qq','postgresql'], check=True)
subprocess.run(['service','postgresql','start'], check=True)
subprocess.run(['sudo','-u','postgres','psql','-c',
                "CREATE USER agent SUPERUSER PASSWORD 'dev';"], check=True)
""")

r = sbx.run_code("""
import psycopg, os
conn = psycopg.connect('postgresql://agent:dev@localhost/postgres')
cur = conn.cursor()
cur.execute("""
CREATE TABLE IF NOT EXISTS users (id serial primary key, email text);
INSERT INTO users(email) VALUES ('alice@ex.com'), ('bob@ex.com');
""")
conn.commit()
cur.execute("SELECT count(*), max(id) FROM users")
print(cur.fetchone())
""")
print(r.stdout)
sbx.close()
🟢

Local Supabase for AI app testing

Full Supabase (Postgres + PostgREST + Auth) in one sandbox. Test generated RLS policies against a real stack.

BashSupabase
#!/usr/bin/env bash
# Spin up a local Supabase (Postgres + PostgREST + Auth) inside a
# sandbox so an AI agent can test generated queries, RLS policies,
# and migrations without touching the production project.
set -euo pipefail

# Supabase CLI
curl -sSL https://github.com/supabase/cli/releases/latest/download/supabase_linux_amd64.tar.gz \
  | tar xz -C /usr/local/bin
# Docker is already available in the podflare base image
supabase init --yes
supabase start

# Run the agent's generated SQL against the fresh DB
psql "postgresql://postgres:postgres@localhost:54322/postgres" \
     -f /tmp/agent-generated-migrations.sql

# Capture PostgREST response on a test query
curl -sS "http://localhost:54321/rest/v1/users?select=*" \
  -H "apikey: anon-key" | head -100

supabase stop

Web automation

šŸ•·ļø

Headless browser + screenshots

Playwright in Chromium — scraping, screenshots, form-filling. Clean browser per agent task, no cross-contamination.

PythonPlaywright
"""AI-driven web scraping / screenshot tool. Playwright in a sandbox:
each agent task gets a clean Chromium, no cross-contamination.
"""
from podflare import Sandbox
import base64

sbx = Sandbox(template="python-datasci", idle_timeout_seconds=900)

sbx.run_code("pip install -q playwright && playwright install chromium")

r = sbx.run_code("""
from playwright.sync_api import sync_playwright
import base64
with sync_playwright() as p:
    br = p.chromium.launch()
    page = br.new_page()
    page.goto('https://news.ycombinator.com')
    titles = page.locator('.titleline > a').all_inner_texts()[:5]
    print('\n'.join(titles))
    img = page.screenshot()
    print('SCREENSHOT_B64:' + base64.b64encode(img).decode())
    br.close()
""")
print(r.stdout.split("SCREENSHOT_B64:")[0])
sbx.close()
🌐

Next.js dev server + screenshot

Boot agent-generated code as a live Next.js site, then screenshot it. For v0.dev-style builders.

PythonNext.js
"""Boot a Next.js dev server inside a sandbox, screenshot the running
page. Works for 'AI-generated websites' apps (v0.dev-style) where
you want to show the user a live preview of what the agent built.
"""
from podflare import Sandbox

sbx = Sandbox(idle_timeout_seconds=1800)

# 1. Scaffold a Next.js app from agent-generated files
sbx.run_code("""
mkdir -p /tmp/site && cd /tmp/site
cat > package.json <<'PKG'
{"dependencies":{"next":"^15","react":"^19","react-dom":"^19"}}
PKG
mkdir -p app
cat > app/page.tsx <<'TSX'
export default function P() { return <h1>hi from sandbox</h1> }
TSX
cat > app/layout.tsx <<'TSX'
export default function L({children}:{children:React.ReactNode}) {
  return <html><body>{children}</body></html>
}
TSX
npm install --silent
""", language="bash")

# 2. Start dev server in background
sbx.run_code("cd /tmp/site && nohup npx next dev -p 3000 > /tmp/next.log 2>&1 &",
             language="bash")

# 3. Screenshot
sbx.run_code("""
pip install -q playwright && playwright install chromium -q
""")
r = sbx.run_code("""
from playwright.sync_api import sync_playwright
import base64, time
time.sleep(3)  # give next a beat
with sync_playwright() as p:
    br = p.chromium.launch()
    page = br.new_page()
    page.goto('http://localhost:3000')
    img = page.screenshot()
    print('B64:' + base64.b64encode(img).decode()[:120] + '…')
    br.close()
""")
print(r.stdout)
sbx.close()

Dev environments

🌿

Branch preview / PR review bot

Clone a branch, run tests, return results. Drop-in for 'AI reviewer' agents that open PRs.

PythonGit
"""Review agent: checkout a git branch, run tests, summarize failures.
"""
from podflare import Sandbox

sbx = Sandbox(idle_timeout_seconds=1800)

# Mount a real branch of the customer's repo
r = sbx.run_code("""
git clone --depth 1 --branch feat/new-billing https://github.com/acme/app /tmp/app
cd /tmp/app && npm ci --silent && npm test 2>&1 | tail -40
""", language="bash")

print("exit:", r.exit_code)
print(r.stdout)
sbx.close()

Need a template we don't have?

Email us at hello@podflare.ai with the use case — if it's common we'll add it here.