|
| 1 | +# Extended Testing And Benchmarking (Real APIs) |
| 2 | + |
| 3 | +This guide describes how to run an extended end-to-end (E2E) validation session for cascadeflow using **real provider APIs**. |
| 4 | + |
| 5 | +Goals: |
| 6 | +- Validate correctness, routing logic, and cost optimization in the ways developers actually use cascadeflow: |
| 7 | + - Apps (Next.js API routes, Vercel AI SDK `useChat`) |
| 8 | + - Agents (tools, multi-turn, structured outputs) |
| 9 | + - Routers/proxies (OpenAI-compatible HTTP, existing SDKs) |
| 10 | +- Produce numbers you can share: **accuracy**, **drafter acceptance**, **cost reduction**, latency. |
| 11 | + |
| 12 | +## Setup |
| 13 | + |
| 14 | +1. Load provider keys (repo root `.env`): |
| 15 | +```bash |
| 16 | +set -a && source .env && set +a |
| 17 | +``` |
| 18 | + |
| 19 | +2. Install deps: |
| 20 | +```bash |
| 21 | +pnpm install |
| 22 | +python3 -m pip install -r requirements-dev.txt |
| 23 | +``` |
| 24 | + |
| 25 | +## What We Measure |
| 26 | + |
| 27 | +- **Accuracy**: dataset-specific correctness (e.g. GSM8K exact match, MMLU multiple-choice, tool-call correctness). |
| 28 | +- **Drafter acceptance**: how often the cheap model is accepted without escalation. |
| 29 | +- **Cost reduction**: savings vs a verifier-only baseline. |
| 30 | +- **Latency**: end-to-end time per request (where available). |
| 31 | + |
| 32 | +## Benchmark Coverage Map |
| 33 | + |
| 34 | +Python benchmark suite (see `tests/benchmarks/`): |
| 35 | +- `run_benchmarks.py`: GSM8K + MMLU + MT-Bench (cost reduction + quality retention targets). |
| 36 | +- `run_all.py`: broad coverage: |
| 37 | + - HumanEval (code) |
| 38 | + - GSM8K (math) |
| 39 | + - MT-Bench (multi-turn) |
| 40 | + - TruthfulQA (factual) |
| 41 | + - Banking77 (classification) |
| 42 | + - Customer support (real-world Q&A) |
| 43 | + - BFCL agentic tool calling (multi-turn + dependencies) |
| 44 | + - Tool calling (single + multi-turn tool selection correctness) |
| 45 | + - Agentic multi-agent (router + tool call correctness) |
| 46 | + - Provider comparison (quality engine consistency across providers) |
| 47 | + |
| 48 | +TypeScript coverage (monorepo tests): |
| 49 | +- `pnpm test`: builds + tests all TS packages and the Next.js `useChat` example. |
| 50 | +- Vercel AI SDK handler E2E tests: |
| 51 | + - `packages/core/src/vercel-ai/__tests__/e2e.test.ts` |
| 52 | + - `packages/core/src/__tests__/vercel-ai-chat-handler.e2e.test.ts` |
| 53 | +- Optional real API smoke: |
| 54 | + - `pnpm -C packages/core run real-api:smoke` |
| 55 | + |
| 56 | +## Recommended Sessions |
| 57 | + |
| 58 | +### 1) Smoke (Fast Signal, Low Spend) |
| 59 | + |
| 60 | +One-command runner (writes logs/results under `benchmark_results/sessions/`): |
| 61 | +```bash |
| 62 | +set -a && source .env && set +a |
| 63 | +./scripts/extended-e2e-session.sh smoke |
| 64 | +``` |
| 65 | + |
| 66 | +Manual steps: |
| 67 | +```bash |
| 68 | +pnpm test |
| 69 | +python3 -m pytest |
| 70 | + |
| 71 | +pnpm -C packages/core exec vitest run \ |
| 72 | + src/vercel-ai/__tests__/e2e.test.ts \ |
| 73 | + src/__tests__/vercel-ai-chat-handler.e2e.test.ts |
| 74 | + |
| 75 | +python3 tests/benchmarks/run_benchmarks.py --quick --output benchmark_results/e2e_quick.json || true |
| 76 | +python3 -m tests.benchmarks.run_all --profile smoke --output-dir benchmark_results/smoke |
| 77 | +``` |
| 78 | + |
| 79 | +### 2) Standard (Shareable Numbers) |
| 80 | + |
| 81 | +```bash |
| 82 | +set -a && source .env && set +a |
| 83 | +./scripts/extended-e2e-session.sh standard |
| 84 | +``` |
| 85 | + |
| 86 | +### 3) Overnight (Stress + Agentic) |
| 87 | + |
| 88 | +```bash |
| 89 | +python3 -m tests.benchmarks.run_all --profile overnight --output-dir benchmark_results/overnight |
| 90 | +``` |
| 91 | + |
| 92 | +## Developer DX Validation (Out Of The Box) |
| 93 | + |
| 94 | +Minimal “does it work for users tomorrow” checks: |
| 95 | +1. `docs/guides/integrate_fast.md` paths: |
| 96 | + - Vercel AI SDK `useChat` drop-in: build the example `examples/vercel-ai-nextjs/` |
| 97 | + - Proxy: validate OpenAI-compatible endpoint behavior (see `docs/guides/proxy.md`) |
| 98 | +2. Agent tools: |
| 99 | + - Tool-call generation correctness: `python3 -m tests.benchmarks.tool_calls` |
| 100 | + - Multi-turn tool history: `python3 -m tests.benchmarks.tool_calls_agentic` |
| 101 | + |
| 102 | +## Notes / Current Limits |
| 103 | + |
| 104 | +- Tool-call *generation* is benchmarked heavily. |
| 105 | +- Full tool *execution loops* depend on the integration path: |
| 106 | + - Streaming tool execution exists via the streaming tool manager. |
| 107 | + - Non-streaming multi-step tool execution is supported for direct routing; cascade tool paths currently focus on tool-call correctness and verification. |
| 108 | + |
0 commit comments