Architecture overview
Go modules under application/internal and the execution pipeline.
Architecture overview
AgentFlow ships as a Go CLI (application/cmd/agentflow) with most behavior in application/internal/ and shared contracts in application/pkg/agentflow. This split keeps the binary thin while isolating parsing, planning, investigation, costing, and storage behind explicit packages you can reason about from the filesystem layout alone.
Execution pipeline
The end-to-end path starts at the CLI, resolves intent, runs the V3 pipeline (investigation, context optimization, cost and budgets, routing), then executes the workflow stages—plan, enrich, and dev—inside a worktree before validation, optional review, and reporting.
flowchart TD
A[User intent / CLI] --> B[intent resolver + planner]
B --> C[pipeline V3]
C --> D[investigation]
D --> E[contextopt]
E --> F[cost estimate + budgets]
F --> G[routing]
G --> H[workflow: plan enrich dev]
H --> I[worktree + agent exec]
I --> J[validation]
J --> K[review + report]Internal modules
| Package | Role |
|---|---|
cli | Cobra commands, docgen, app context |
config | YAML load, defaults, path resolve |
intent | NL work/continue, hybrid resolver, executor |
workflow | State machine, plan/dev/verify/review, worktrees |
worktree | Git worktree lifecycle |
agent / agent/exec | Subprocess contracts |
source / source/notion | Spec ingestion |
contextopt | Context collect/reduce/pack |
investigation | Local grep/scan |
cost | Tokens, pricing, budgets |
routing | Step-class → agent/model |
mcp | Stdio MCP tools (optional) |
store/sqlite | Runs, tasks, metrics |
report | Run reports |
tui | Rich/plain/json UI |
rag | Chunk index (SQLite, non-vector) |
bootstrap | init, doctor |
redact | Log secret masking |
validation | External command runner |
State storage
Runs and tasks persist in SQLite at state.path (default .agentflow/state.sqlite). Artefacts for each run land under .agentflow/runs/<run-id>/, which keeps prompts, logs, and intermediate outputs addressable without rereading the database.
Extension points
You can introduce new agents through config alone; wire new quality gates via validation.commands; add routing strategies under routing.strategies; and expose optional MCP tools when mcp.enabled: true. Those hooks are intentional seams: most teams extend AgentFlow without forking the Go entrypoint.