RectifyFlow: Edge-Cloud Tool Agents at 39% Cost & 95% Quality

RectifyFlow (arXiv:2612.01860, Nanjing University & CityU Hong Kong) cuts tool-calling API spend by 60.6% on BFCL and 51.4% on ToolSandbox while preserving 94.6% and 91.8% of cloud-only accuracy. A cloud LLM generates an upfront dual-view dependency plan executed locally by Qwen3-8B, triggering cloud repair only on deviating subgraphs.
RectifyFlow: Edge-Cloud Tool Agents at 39% Cost & 95% Quality: RectifyFlow (arXiv:2612.01860, Nanjing University & CityU Hong Kong) cuts tool-calling API spend by 60.6% on BFCL and 51.4% on ToolSandbox while preserving 94.6% and 91.8% of cloud-only accuracy. A cloud LLM generates an upfront dual-view dependency plan executed locally by Qwen3-8B, triggering cloud repair only on deviating subgraphs. Designed as a zero-dependency, open-source TypeScript architecture under the MIT License with native Model Context Protocol (MCP) support and deterministic phase state machines.
- 94.61% Cloud Quality at 39.39% Cost (BFCL): With Qwen3-8B on the edge, RectifyFlow scores 76.72 vs 81.09 cloud-only, saving 60.61% of API spend.
- 91.76% Cloud Quality at 48.64% Cost (ToolSandbox): Reaches 64.83 vs 70.65 cloud-only across multi-turn stateful tool conversations, beating ReWOO (SM) and Plan-and-Act (SM).
- Rescues Weak Edge Models (6.88 -> 76.72): Local-only Qwen3-8B collapses to 6.88 on BFCL (8.48% of cloud), whereas RectifyFlow lifts it past every prior edge-cloud baseline.
- Dependency-Aware Subgraph Repair: Localizes exact execution deviations and patches only downstream dependent steps instead of replanning from scratch.
import { createAgent } from '@smoke-monkey/harness';// Edge worker (local Qwen3-8B via Ollama) guided by an upfront cloud dependency planconst edgeWorker = createAgent({agentId: 'rectifyflow-edge-executor',provider: 'ollama',model: 'qwen3:8b',workspacePath: process.cwd(),permissions: {read_file: 'allow',write_file: 'allow',run_command: 'ask',},});interface PlanNode {id: string;tool: string;dependsOn: string[];status: 'pending' | 'ok' | 'deviated';}function collectDownstreamSubgraph(nodes: PlanNode[], failedId: string): string[] {const impacted = new Set<string>([failedId]);let changed = true;while (changed) {changed = false;for (const n of nodes) {if (!impacted.has(n.id) && n.dependsOn.some((dep) => impacted.has(dep))) {impacted.add(n.id);changed = true;}}}return [...impacted];}async function main() {const plan: PlanNode[] = [{ id: 'n1', tool: 'lookup_order', dependsOn: [], status: 'deviated' },{ id: 'n2', tool: 'check_refund_policy', dependsOn: ['n1'], status: 'pending' },{ id: 'n3', tool: 'send_receipt', dependsOn: [], status: 'ok' },];const repairScope = collectDownstreamSubgraph(plan, 'n1');const res = await edgeWorker.run(`Execute local tool step n3 untouched; escalate only deviated subgraph [${repairScope.join(', ')}] for selective cloud rectification.`);console.log(res.summary);}main().catch(console.error);
Watch: Related Video Guides
What is Tool Calling? Connecting LLMs to Your Data
AI Agent Routing Explained | LLM Router vs Embeddings vs Rules | Agentic AI Chapter 2
How RectifyFlow Combines Upfront Cloud Plans With Edge Execution
RectifyFlow (arXiv:2612.01860) is an edge–cloud tool-use orchestration framework built around two mechanisms: Dual-View Plan Construction, where a cloud LLM generates a structured dependency-aware plan upfront, and Dependency-Aware Plan Rectification, which detects local small-model execution errors and invokes cloud repair strictly on the affected dependency subgraph.
Per-turn cloud delegation (Minions, GAPG, AIMS, Hera, HybridFlow) burns repeated cloud tokens on routine parameter extraction, while pure local small models (Qwen3-8B, MiniCPM5-2B) collapse on complex multi-step calls (6.88 and 4.38 on BFCL). By planning once and rectifying selectively, RectifyFlow achieves 94.61% of cloud-only BFCL performance at 39.39% of the API cost.
| Method | BFCL Perf (×10⁻²) | BFCL Cost (×10⁻³ $) | BFCL Perf / Cost vs Cloud | ToolSandbox Perf | ToolSandbox Perf / Cost vs Cloud |
|---|---|---|---|---|---|
| Cloud-Only | 81.09 | 5.803 | 100.00% / 100.00% | 70.65 | 100.00% / 100.00% |
| Local-Only (Qwen3-8B) | 6.88 | 0.000 | 8.48% / 0.00% | 38.26 | 54.16% / 0.00% |
| GAPG | 45.63 | 2.809 | 56.26% / 48.41% | 59.95 | 84.85% / 67.59% |
| Minions | 48.44 | 3.023 | 59.73% / 52.10% | 44.59 | 63.11% / 66.15% |
| HybridFlow | 53.13 | 2.337 | 65.51% / 40.27% | — | — |
| ReWOO (SM Edge) | 48.28 | 2.137 | 59.54% / 36.83% | 61.06 | 86.43% / 78.42% |
| Plan-and-Act (SM Edge) | 44.38 | 4.197 | 54.73% / 72.32% | 63.14 | 89.37% / 71.84% |
| RectifyFlow (Qwen3-8B) | 76.72 | 2.286 | 94.61% / 39.39% | 64.83 | 91.76% / 48.64% |
Scaling Across Edge Model Sizes (1.7B to 8B) Without Full Replanning
A key advantage of RectifyFlow is its resilience across tiny edge backbones:
- Even 1.7B Edge Models Hold >90% Quality: Swapping the local executor to
Qwen3-1.7Bstill delivers 75.63 on BFCL (93.27% of cloud at 40.07% cost) and 64.23 on ToolSandbox (90.91% of cloud at 49.93% cost). - Why Plan-and-Act Costs More Than Cloud-Only on BFCL: Naive dynamic replanners like
Plan-and-Acthit 123.61% of cloud-only cost on BFCL ($7.173e-3vs$5.803e-3) because repeated full-context replanning erases edge savings. RectifyFlow's dependency-scoped rectification keeps BFCL spend at 39.39%. - Cache-Aware Prompt Synergy: Keeping the upfront dual-view plan prefix static maximizes cloud KV prompt-cache hits during occasional subgraph rectification rounds.
Deploy With Smoke Monkey Multi-Provider Routing
Run a cloud planner once via Anthropic or OpenAI in Smoke Monkey Harness, then execute tool-call steps on local Ollama Qwen3-8B or Qwen3-4B workers, falling back to cloud only on schema or dependency deviation.
Pulling Edge Qwen3 Executors via Ollama for Hybrid Routing
To prototype RectifyFlow's edge-cloud split locally, serve qwen3:8b or qwen3:4b on Ollama for zero-cost local tool execution alongside a frontier cloud planner.
# Pull local edge small models tested in RectifyFlow (Qwen3 1.7B, 4B, 8B)
ollama pull qwen3:8b
ollama pull qwen3:4b
# Verify local tool-calling latency before wiring cloud rectification
curl -s http://localhost:11434/api/chat -d '{
"model": "qwen3:8b",
"stream": false,
"messages": [{"role": "user", "content": "Extract tool args: order_id=ORD-902, action=status"}]
}'Frequently Asked Questions
Q:How does RectifyFlow differ from ReWOO and Plan-and-Act on edge devices?
ReWOO has no dynamic recovery when a small model errs mid-plan (59.54% BFCL vs cloud), while Plan-and-Act replans globally and costs 123.61% of cloud-only on BFCL. RectifyFlow localizes deviations and rectifies only impacted subgraphs, reaching 94.61% quality at 39.39% cost.
Q:Which local edge models were benchmarked with RectifyFlow?
The paper evaluated Qwen3-1.7B, Qwen3-4B, Qwen3-8B, and Llama3-8B as edge executors, with Qwen3-8B achieving the best BFCL score (76.72) and Qwen3-4B achieving the highest ToolSandbox score (65.96).
Q:How well does RectifyFlow handle missing functions or missing parameters on BFCL?
On BFCL, local-only Qwen3-8B drops to 6.88 overall, whereas RectifyFlow recovers multi-category function calling including base, long-context, missing-function, and missing-parameter splits to reach 76.72.
Q:Can RectifyFlow work with prompt caching on cloud APIs?
Yes. Appendix C of the paper evaluates cache-aware API cost, showing that preserving the static upfront plan prefix reduces cloud rectification token spend.
Related Alternatives & Comparisons
Related Architecture Guides
View all guidesBest Open Source Coding Agents in 2026: Free, Local & Fully Hackable Harnesses
MCP Server Security Best Practices: Hardening Model Context Protocol Agents in 2026
Open Source Coding Agent Harness: Build a Forkable, Local AI Engineering Runtime
Build with Smoke Monkey Harness
Zero dependencies. 24 built-in tools. Human-in-the-loop safety. 100% open source under the MIT License.