---
name: fuelrouter-upstream-pool-failover
description: Production agent skill guide for FuelRouter (https://fuelrouter.fastmesh.dev, port 9051) — discover 5 multi-upstream capability pools, request $0 dry-run quotes, dispatch resilient calls via REST or JSON-RPC 2.0 /mcp with 3-state circuit breakers, anti-fake-200 / CAPTCHA failover, 7d-30d cross-tenant caching, $0 exhaustion traces, and zero-secret credential isolation.
---

# FuelRouter (`fuelrouter.fastmesh.dev`) — Production Agent Skill Guide

> **Operational Invariants**: `5` capability pools (`33` upstream slots, `20` free `$0` accounts) · `<= 50 ms` p95 local routing overhead · `3`-state circuit breakers (`CLOSED` / `OPEN` / `HALF_OPEN`) · Anti-Fake-200 gate with zero CAPTCHA bypass · `7d–30d` (`604,800s–2,592,000s`) cross-tenant archive cache (`100%` repeat gross margin) · Strictly **`$0` billed (`charged_micros: 0`, `billed_usd: 0.0`)** on `503` pool exhaustion and `422` validation/SSRF rejections · Strictly redacted zero-secret proxy (`reveal=false`) and `zero_customer_trace_resale: true`.

## 1. Quick-Reference Endpoint & Capability Matrix

| Pool ID | Free `$0` / Total | Outcome Price | Default Budget Cap | Cache TTL (Default / Max) | Target Availability | Target p95 | Required Output Key |
| :--- | :---: | :---: | :---: | :---: | :---: | :---: | :--- |
| `ai_chat_json` | 5 / 8 | `$0.010` (`10,000` micros) | `50,000` micros | `7d` / `30d` (`604,800s`–`2,592,000s`) | `99.6%` | `2,200 ms` | `content` |
| `embeddings_rerank` | 3 / 6 | `$0.004` (`4,000` micros) | `20,000` micros | `14d` / `30d` (`1,209,600s`–`2,592,000s`) | `99.7%` | `950 ms` | `vectors` |
| `web_search` | 3 / 6 | `$0.008` (`8,000` micros) | `40,000` micros | `7d` / `21d` (`604,800s`–`1,814,400s`) | `99.5%` | `1,800 ms` | `results` |
| `clean_scrape_extract` | 4 / 6 | `$0.012` (`12,000` micros) | `60,000` micros | `7d` / `21d` (`604,800s`–`1,814,400s`) | `99.4%` | `3,500 ms` | `markdown` |
| `b2b_domain_dns_enrichment` | 5 / 7 | `$0.020` (`20,000` micros) | `80,000` micros | `14d` / `30d` (`1,209,600s`–`2,592,000s`) | `99.6%` | `1,600 ms` | `domain` |

**Base URL (Production):** `https://fuelrouter.fastmesh.dev`  
**Base URL (Local Sandbox):** `http://127.0.0.1:9051`  
**Support Contact:** `support@fastmesh.dev` | **Operations:** `ops@fastmesh.dev`

---

## 2. Step-by-Step Agent Workflow (REST)

### Step 1: Discover Live Redacted Pools, Circuit States & Quotas
Never assume a single vendor is healthy. Query `GET /v1/router/pools` (or filter by `?pool_id=web_search`) to inspect live circuit states (`CLOSED`, `OPEN`, `HALF_OPEN`), EWMA `dynamic_health_score`, and remaining `rpm`/`rpd`/`monthly` headroom without seeing any upstream secret.

```bash
curl -fsSL "https://fuelrouter.fastmesh.dev/v1/router/pools?pool_id=web_search"
```

### Step 2: Request a `$0` Dry-Run Quote Before Spending
Call `POST /v1/router/quote` to preview whether the cross-tenant archive cache will hit (`cache_would_hit`), inspect the ranked failover route (`planned_route`), and verify `estimated_outcome_price_micros` with `quoted_charge_micros: 0` and zero upstream quota consumed.

```bash
curl -fsSL -X POST "https://fuelrouter.fastmesh.dev/v1/router/quote" \
  -H "Content-Type: application/json" \
  -d '{
    "pool_id": "web_search",
    "tenant_id": "agent_research_01",
    "inputs": {
      "query": "multi-upstream circuit breaker failover",
      "max_results": 5
    },
    "max_cost_micros": 40000,
    "force_refresh": false
  }'
```

### Step 3: Dispatch with Automatic Failover, Anti-Fake-200 & Budget Lock
Send `POST /v1/router/dispatch`. FuelRouter checks the `7d–30d` SQLite WAL archive cache first; on a miss, it sorts eligible upstreams by `(unit_cost_micros ASC, dynamic_health_score DESC, remaining_free_quota_ratio DESC, priority_rank ASC)` and fails over immediately across HTTP `429`/`5xx`, timeouts, HTML interstitials, login walls, empty SPA shells, and CAPTCHA soft-bans.

```bash
curl -fsSL -X POST "https://fuelrouter.fastmesh.dev/v1/router/dispatch" \
  -H "Content-Type: application/json" \
  -d '{
    "pool_id": "clean_scrape_extract",
    "tenant_id": "agent_research_01",
    "inputs": {
      "url": "https://example.com/pricing",
      "format": "markdown"
    },
    "max_cost_micros": 60000,
    "force_refresh": false,
    "prefer": [],
    "exclude": []
  }'
```

Key response fields to inspect:
- `served_by`: Winning upstream ID (or archive cache).
- `cache_hit` / `cache_status`: `true` (`archive_hit` -> `upstream_cost_micros: 0`, `gross_margin_pct: 100.0`) or `false` (`live`).
- `charged_micros` / `billed_usd`: Exact billed amount (`10%` on same-tenant repeat hit, `100%` on new-tenant hit or fresh verified hit).
- `receipt_sha256`: Deterministic 64-hex cryptographic receipt over the canonical result.
- `trace`: Ordered, redacted attempt log showing every upstream step, status code, latency, and circuit state.

---

## 3. Native MCP Integration (`POST /mcp`, JSON-RPC 2.0)

FuelRouter exposes 5 flat JSON-RPC 2.0 MCP tools at `POST https://fuelrouter.fastmesh.dev/mcp`:
1. `router_list_pools` — Redacted pool topology, live circuit states, dynamic health scores, and remaining quotas.
2. `router_quote` — Zero-cost (`$0`) dry-run route plan and cache hit prediction.
3. `router_dispatch` — Execute cached or live failover dispatch under a hard `max_cost_micros` lock.
4. `router_metrics` — Real-time cache hit ratio, failover counts, fake-200/CAPTCHA blocks, and saved upstream spend.
5. `router_circuit_reset` — Operator reset of a tripped upstream or pool circuit back to `CLOSED`.

```bash
# 1. Initialize MCP session
curl -fsSL -X POST "https://fuelrouter.fastmesh.dev/mcp" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{}}'

# 2. List flat tools
curl -fsSL -X POST "https://fuelrouter.fastmesh.dev/mcp" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}'

# 3. Call router_dispatch via MCP
curl -fsSL -X POST "https://fuelrouter.fastmesh.dev/mcp" \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 3,
    "method": "tools/call",
    "params": {
      "name": "router_dispatch",
      "arguments": {
        "pool_id": "b2b_domain_dns_enrichment",
        "tenant_id": "agent_enrichment_02",
        "inputs": {"domain": "fastmesh.dev", "include_dns": true},
        "max_cost_micros": 80000
      }
    }
  }'
```

MCP responses include both `content: [{"type": "text", "text": "..."}]` and machine-parseable `structuredContent`.

---

## 4. Handling `$0` Exhaustion Traces & Backoff Discipline

When every eligible upstream in a pool fails, hits a `429`/quota ceiling, trips its circuit breaker, or returns a fake-200/CAPTCHA challenge, FuelRouter returns HTTP `503` with **zero charge**:

```json
{
  "ok": false,
  "status_code": 503,
  "pool_id": "clean_scrape_extract",
  "error_code": "all_upstreams_exhausted",
  "charged_micros": 0,
  "billed_usd": 0.0,
  "upstream_cost_micros": 0,
  "backoff_advice": {
    "retry_after_s": 45,
    "recommended_action": "wait_for_cooldown_or_expand_budget"
  },
  "receipt_sha256": "<64-hex-sha256>",
  "trace": [
    {
      "step": 1,
      "upstream_id": "scrape_firecrawl_free",
      "domain_id": "www.firecrawl.dev",
      "outcome": "fake_200_captcha_soft_ban",
      "status_code": 200,
      "latency_ms": 95,
      "circuit_state": "OPEN"
    }
  ]
}
```

**Recommended Agent Backoff Algorithm:**
1. Verify `charged_micros == 0` and `billed_usd == 0.0` before logging the attempt.
2. Sleep for `backoff_advice.retry_after_s` (capped between `45s` and `900s`) so `OPEN` circuits enter `HALF_OPEN` cleanly for single-probe recovery.
3. Never attempt to bypass a `fake_200_captcha_soft_ban` upstream; if you have headroom and only `$0` free-tier nodes were eligible under a tight `max_cost_micros`, consider raising `max_cost_micros` within your policy cap so low-cost wholesale fallbacks become eligible.
4. For HTTP `422` (`invalid_input` or `ssrf_blocked`, also strictly `$0` charged), fix the malformed argument or disallowed private/metadata URL rather than retrying.

---

## 5. Verifying Zero-Secret Isolation & Security Redlines

Agents and security auditors can verify isolation directly at runtime:
1. **Health Verification (`GET /health`)**: Confirm `"zero_secret_mode": true` and `"sqlite_wal": true`.
2. **Pool Redaction Check (`GET /v1/router/pools`)**: Every upstream exposes only its redacted `domain_id` and local bridge route `http://127.0.0.1:18793/api/proxy/<domain_id>` (synced with `reveal=false`). No raw API keys, cookies, authorization headers, or account passwords ever enter router memory or responses.
3. **SSRF Boundary Check**: Submitting any private RFC-1918 IP (`10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16`), loopback (`127.0.0.0/8`, `::1/128`), cloud metadata (`169.254.169.254`), non-HTTP scheme (`file://`, `ftp://`, `gopher://`), or `.local`/`.internal` host returns HTTP `422` (`ssrf_blocked`, `$0` charged).
4. **No CAPTCHA Bypass & No Card Autofill**: Challenged upstreams are soft-ban quarantined immediately. Credit top-ups use opt-in Creem packs (Starter `$19`, Pro `$79`, Scale `$249`) verified via HMAC-SHA256 at `POST /webhooks/creem`.

---

## 6. Operator Recovery & Local Hand CLI

Reset a tripped upstream or entire pool after external maintenance:
```bash
curl -fsSL -X POST "https://fuelrouter.fastmesh.dev/v1/router/circuit/reset" \
  -H "Content-Type: application/json" \
  -d '{"pool_id": "web_search", "upstream_id": "search_tavily_free"}'
```

Inspect real-time margins, cache hits, and circuit distribution:
```bash
curl -fsSL "https://fuelrouter.fastmesh.dev/v1/router/metrics"
```

Run locally via Causal Bazaar hand entrypoint (`$0` exhaustion guarantee enforced):
```bash
python3 run_hand.py --pool web_search --inputs '{"query": "circuit breaker failover"}'
```

Support: `support@fastmesh.dev` | Operations: `ops@fastmesh.dev`
