Local-first workflows
Investigate and narrow context locally before calling cloud models.
Local-first workflows
Problem
Pushing an entire repository through a cloud model is slow, expensive, and often leaks more code than the task requires. Many engineering questions shrink once you search the tree, list candidate files, and apply structured packing—work that belongs on your machine with ordinary tools, not in a remote prompt.
AgentFlow approach
AgentFlow treats local investigation and context reduction as a first-class prelude. Before the expensive steps, AgentFlow can narrow what leaves the repo:
agentflow investigate <feature>— bounded grep, candidate files, large-file warnings, related testsagentflow context <feature> --optimize— collect, score, compress context into a pack- Routing — prefer Ollama or local profiles for
summarize,classify,pre_review, andcontext_selectionwhenrouting.strategies.cost_awareis in play
The flow is linear in practice: the user's intent feeds investigation, investigation feeds a context pack, routing chooses local versus cloud execution, and both paths converge on validation.
flowchart LR
A[User intent] --> B[Investigate]
B --> C[Context pack]
C --> D{Route}
D -->|local step| E[Ollama / local agent]
D -->|cloud step| F[Cursor / Codex / Claude]
E --> G[Validation]
F --> GExample
The sequence below runs investigation and context optimization for a feature, then previews a work run with local preference and estimate-only:
agentflow investigate billing-v2 --task task-003
agentflow context billing-v2 --task task-003 --optimize
agentflow work "develop billing-v2" --prefer-local --estimate-onlyTrade-offs
| Improves | Does not solve |
|---|---|
| Latency and cost for triage | Semantic understanding equal to a large cloud model |
| Repeatable investigation logs | Perfect relevance ranking (heuristic scoring) |
| Offline-capable steps with Ollama | Air-gapped compliance without your own review |
Configuration
The snippet below turns on cost-aware routing and sets shared investigation byte limits. Those limits apply even when mcp.enabled is false: they live under mcp.investigation as shared configuration for local tools.
routing:
default_strategy: cost_aware
strategies:
cost_aware:
prefer_local_for: [summarize, classify, context_selection, pre_review]
mcp:
investigation:
large_file_bytes: 524288
max_grep_output_bytes: 262144