The Problem with "Always Use the Cloud"
AI agents are becoming more powerful they can summarize private documents, explain code, generate scripts, interact with files, and send messages. But most existing systems send every request to the strongest cloud model, ignoring important tradeoffs around privacy, latency, and safety.
Our project builds a lightweight runtime monitor that sits between the user and the agent, evaluating each task on four dimensions before anything is executed.
Latency Needs
Time-sensitive tasks stay local for a faster response without network delays.
Privacy Sensitivity
Private data local files, passwords, personal notes avoids external APIs when possible.
Security Risk
Risky, irreversible actions like running scripts or deleting files require user confirmation.
Task Complexity
Complex, multi-step reasoning tasks leverage stronger cloud models when needed.
Based on these scores, every task is routed to one of four execution modes. Click each mode to learn more:
Run on edge device
everything else
Cloud recommended
complexity ≥ 7
Ask user first
security ≥ 7 or privacy ≥ 7
Refuse execution
security ≥ 9
How the System Works
The system is implemented as a multi-agent pipeline built with LangGraph. The user submits a GitHub repository URL and a task description. The pipeline then runs automatically through a sequence of specialized agents, each writing to a shared state that the next agent reads from.
Here is the actual LangGraph agent graph showing how each agent connects and how the router branches into different execution paths:
The GitHub Agent clones the repository and builds a readable snapshot of up to 20 source files. The Parser Agent translates the natural language task into structured JSON, flagging ambiguities for the router. The Router Agent scores the task and makes the routing decision. Finally, the appropriate agent handles execution or the supervisor pauses for user confirmation.
The Decision-Making Core
The router agent is the decision-making part of our system. Before any task is executed, it looks at the user's request and decides how it should be handled. It scores each task on four dimensions from 0–10 and returns a structured JSON with the scores and a routing decision.
Getting the router to produce consistent, structured output required several rounds of iteration. Click each step to expand:
Simple classification prompt
›Added explicit scoring rules + JSON output format
›Edge case refinement via LangSmith testing
›How Well Does It Work?
We evaluated the system on a benchmark of 20 representative AI-agent tasks covering question answering, repository analysis, code modification, file operations, script execution, and sensitive data handling. Each task was manually labeled with the expected routing outcome.
The average routing latency was 0.8 seconds, adding minimal overhead before execution. Testing in LangSmith helped us identify misclassification cases, leading to stricter thresholds and a default confirmation policy for ambiguous tasks.
Why This Matters
Most AI agent systems today send every task to the strongest cloud model, regardless of whether that is actually needed but a simple routing layer can make a real difference.
Safer
Risky actions like running scripts, deleting files, or sending messages are paused until the user confirms giving users real control over what the agent does.
More Efficient
58% of tasks run locally instead of going through the cloud, which is faster, cheaper, and avoids unnecessary API calls. Complex tasks still use stronger models when needed.
More Private
Tasks involving personal files or sensitive data stay on the user's device by default, rather than being sent to an external API.
What's Next
When a task is routed to CLOUD, the system currently returns a recommendation message rather than executing the task. Future work would extend the pipeline to support real cloud-side code generation using a model like GPT-4o or Claude.
The GitHub Agent reads only the first 20 files it encounters, with no relevance-based prioritization. For large repositories, critical files may be missed. A smarter approach could analyze the README to identify the most important files first.
The router relies entirely on an LLM to score tasks, which means decisions can be inconsistent across runs. Combining LLM scoring with rule-based heuristics or a fine-tuned classifier could improve stability and predictability.