Skip to content

💰 Cost Management ​

Ad-hoc AI usage burns tokens invisibly: developers paste whole files into chat, use frontier models for trivial edits, and let agents spin in open-ended retry loops. At the end of the month, the organization gets a single invoice with no link to what shipped.

The Agentic Software Factory turns AI spend into a governed, attributable unit cost per delivered outcome.

Why the factory lowers token spend ​

Ad-hoc AI usageThe Agentic Software Factory
Frontier model used for every chat and autocompleteRight-sized model per stage matched to the cognitive load of each task
Vague prompt sent straight to a coding agent3-step Think → Plan → Code funnel narrows scope before any code is generated
Entire repository stuffed into context windowsExplicit file scope in Plan and narrowly scoped instructions in Persistent Context
Agents retry indefinitely when checks failHard retry cap halts runaway token burn and escalates to a developer
Teams regenerate boilerplate, auth, and scaffoldingThe Forge binds pre-built, tested assets at zero generation cost
LLM asked to spot syntax, lint, or type errorsDeterministic Controls catch errors first at zero token cost
Unattributed monthly API billPer-issue, per-stage, and per-squad attribution linked to business outcomes

Optimized model selection per stage ​

Not every task needs a frontier reasoning model. Each agent primitive in Persistent Context declares the model tier suited to its job:

StageCognitive taskModel tierWhy it optimizes cost
0 — Meet & 1 — TriageTranscript structuring, quote extraction, backlog scoringFast, low-cost extraction & classification modelsHigh-volume text processing runs on lightweight models at a fraction of frontier pricing
2 — ThinkOption trade-offs, Forge discovery, blast radiusHigh-reasoning frontier modelConcentrates reasoning spend where one sound architectural choice saves tens of thousands of coding tokens
3 — PlanAtomic step breakdown, file scope, testable acceptance criteriaStructured reasoning modelConverts architecture into a bounded checklist once, rather than re-reasoning on every coding turn
4 — CodeImplementing one atomic step and surgical diffsFast, cost-efficient coding modelThe hard design decisions are already settled in Think and Plan; Code executes small, deterministic steps
5 — ProveClean CI gates, independent diff review, targeted auto-remediationZero-token deterministic checks first; review/fixer model only on diffCompilers, linters, and test runners cost zero tokens; the Prove agent reviews only changes that pass CI
7 — LearnTelemetry synthesis, outcome verdict, context proposalsLightweight analytical modelSummarizes structured production signals without heavy generation

Workflow optimization: the 3-step Think → Plan → Code funnel ​

Sending a raw feature request directly to a coding agent is the single largest source of wasted tokens: the agent scans unrelated files, guesses the architecture, breaks existing contracts, and burns tokens trying to fix its own mistakes.

The Think → Plan → Code sequence acts as a token funnel:

  1. 2 — Think eliminates redundant generation. Before planning, the Thinker agent searches the Forge and binds existing services, libraries, and templates. The cheapest code is the code you never pay an agent to generate or debug.
  2. 3 — Plan shrinks input token volume. Plan defines the exact file scope—which files the coding agent may read and touch, and which are off-limits—and breaks the change into atomic steps. Instead of feeding the whole repository on every turn, the coding agent loads only the files for the current step.
  3. 4 — Code bounds output tokens and retry loops. The coding agent applies surgical diffs (sharp-agent baseline) for one step at a time and runs that step's verification command. A hard retry ceiling stops execution when a step cannot self-heal, escalating to a developer instead of burning tokens in an infinite loop.

Preventing team token waste and AI misuse ​

Without structural guardrails, teams waste tokens in predictable ways. The factory prevents each one by design:

Common team misuseWhy it wastes tokensHow the factory stops it
Conversational trial-and-error ("vibe coding" in chat)Long back-and-forth threads re-send the entire conversation history on every messageWork runs through stage pipelines from committed specs (think.md, plan.md), not open-ended chat sessions
Repeating conventions in promptsEvery developer writes custom paragraphs explaining the same stack rules on every turnConventions live once in Persistent Context and are versioned in Git
Unscoped context loadingLoading a giant global instruction file on every request taxes every promptInstructions are small and scoped to narrow file globs
One-shot monolith generationAsking an agent to generate an entire feature at once produces truncated or broken output that must be regenerated from scratchCode enforces one atomic step per turn, verified before moving to the next step
Using LLMs as compilers or lintersPaying for reasoning tokens to find missing imports, syntax errors, or type mismatchesDeterministic Controls and local build/type/lint scripts run first at zero token cost
Solving the same agent mistake twiceFixing an issue in one chat session leaves the next squad to burn tokens hitting the exact same failureRoot-cause fixes update Persistent Context in 7 — Learn, eliminating repeat token spend across all squads

Token attribution and ROI ​

Because every agent run is triggered from the unified Git platform and linked to a work item, branch, and pull request, 100% of token consumption is attributed.

Knowing what your tokens bought ​

Every model invocation records its token count and cost against:

Attribution levelQuestion it answers
Per work itemHow much model spend did this specific backlog issue consume from 0 — Meet to 6 — Release?
Per stageWere tokens spent on upfront reasoning (Think/Plan), step generation (Code), auto-remediation, or independent review (Prove)?
Per merged changeWhat is our unit AI cost to ship a validated pull request, and is it trending down as context and Forge reuse mature?
Per squad & workflowWhich squad or pipeline is driving spend, and which workflows need optimization (Governance)?
Cost per merged change as Persistent Context and Forge mature (median per week) lower is better
051015USDtarget $514.512.29.87.66.15.24.53.9W1W2W3W4W5W6W7W8

Illustrative example data.

Measuring real AI ROI ​

Most organizations cannot calculate AI ROI because they compare a flat monthly licence or API bill against subjective developer surveys. In the Agentic Software Factory, ROI is calculated directly from engineering and business evidence:

  1. Exact cost input: you know the exact dollar cost of tokens and CI minutes consumed to deliver a feature.
  2. Attributed business return: because every feature traces from a client quote in 0 — Meet to a production outcome verdict in 7 — Learn, you compare the exact token cost of building the feature against the customer or operational value it produced.
  3. Actionable cost governance: model spend is reviewed weekly per squad (Governance). Any workflow whose token cost exceeds the value it creates is refactored—moved to a smaller model, constrained with tighter context, replaced by a zero-token deterministic script, or retired. For delivery speed, quality, and autonomy indicators, see Metrics.

Published and maintained by ALTEN