AgentFlow
Architecture

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

PackageRole
cliCobra commands, docgen, app context
configYAML load, defaults, path resolve
intentNL work/continue, hybrid resolver, executor
workflowState machine, plan/dev/verify/review, worktrees
worktreeGit worktree lifecycle
agent / agent/execSubprocess contracts
source / source/notionSpec ingestion
contextoptContext collect/reduce/pack
investigationLocal grep/scan
costTokens, pricing, budgets
routingStep-class → agent/model
mcpStdio MCP tools (optional)
store/sqliteRuns, tasks, metrics
reportRun reports
tuiRich/plain/json UI
ragChunk index (SQLite, non-vector)
bootstrapinit, doctor
redactLog secret masking
validationExternal 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.