Architecture
~9 min readUpdated: December 2026

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

RectifyFlow Dual-View Edge-Cloud Tool Execution and Selective Rectification

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.

Technical Review: Smoke Monkey Core Architecture Team
Tested on Node.js 18+ & BunTypeScript 5.x
Quick Answer & Executive Definition

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.

Key Architectural Takeaways
Quick Implementation Examplerectifyflow-edge-cloud-router.ts
rectifyflow-edge-cloud-router.tstypescript
import { createAgent } from '@smoke-monkey/harness';
// Edge worker (local Qwen3-8B via Ollama) guided by an upfront cloud dependency plan
const 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);
Video Guides

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.

MethodBFCL Perf (×10⁻²)BFCL Cost (×10⁻³ $)BFCL Perf / Cost vs CloudToolSandbox PerfToolSandbox Perf / Cost vs Cloud
Cloud-Only81.095.803100.00% / 100.00%70.65100.00% / 100.00%
Local-Only (Qwen3-8B)6.880.0008.48% / 0.00%38.2654.16% / 0.00%
GAPG45.632.80956.26% / 48.41%59.9584.85% / 67.59%
Minions48.443.02359.73% / 52.10%44.5963.11% / 66.15%
HybridFlow53.132.33765.51% / 40.27%——
ReWOO (SM Edge)48.282.13759.54% / 36.83%61.0686.43% / 78.42%
Plan-and-Act (SM Edge)44.384.19754.73% / 72.32%63.1489.37% / 71.84%
RectifyFlow (Qwen3-8B)76.722.28694.61% / 39.39%64.8391.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:

  1. Even 1.7B Edge Models Hold >90% Quality: Swapping the local executor to Qwen3-1.7B still 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).
  2. Why Plan-and-Act Costs More Than Cloud-Only on BFCL: Naive dynamic replanners like Plan-and-Act hit 123.61% of cloud-only cost on BFCL ($7.173e-3 vs $5.803e-3) because repeated full-context replanning erases edge savings. RectifyFlow's dependency-scoped rectification keeps BFCL spend at 39.39%.
  3. 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.

bash
# 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"}]
}'
Google Search Questions & Answers

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 guides

Build with Smoke Monkey Harness

Zero dependencies. 24 built-in tools. Human-in-the-loop safety. 100% open source under the MIT License.

npm install smoke-monkey-harness