The 400 Million Token Epiphany: Why AI Coding is an Organizational Architecture Problem
What HaloWarden learned while transitioning from individual coding assistants to an agent-first engineering organization—and why the next frontier in AI engineering is not about code generation, but about designing systems that remember.

Most engineering teams today are adopting artificial intelligence from the bottom up. The journey usually begins innocently enough: an individual engineer installs a local coding agent in their IDE to help scaffold boilerplate or debug a tricky function. Soon after, the team might introduce cloud-based agents, AI-assisted pull request reviews, or a handful of automated workflows handling issue triage and unit testing. In isolation, each of these incremental steps makes perfect sense, and each undeniably yields a tangible boost in local productivity.
But as AI usage scales across a broader engineering organization, an entirely different class of problems begins to emerge.
At HaloWarden, our trajectory mirrored this familiar pattern. We started with the same fundamental model: a coding agent running locally, executing relatively well-defined, tightly scoped tasks. A human engineer would review the output, provide feedback, and ultimately merge the pull request. Seeking greater throughput, we progressively shifted toward cloud agents, experimenting with autonomous execution, multi-agent code reviews, specialized codebase scanners, and eventually, workflows where AI agents participated in far more than just writing code.
Then came the turning point. At one stage, a deep, multi-agent review of our entire codebase consumed approximately 400 million tokens.
Our codebase is not a sprawling, legacy enterprise monorepo. It is a focused, modern architecture. That staggering token count forced a profound shift in how we conceptualized AI engineering.
The immediate, reflexive reaction to such a metric is purely financial: How much did those tokens cost? Could a cheaper, smaller model have accomplished the same task? Could we have aggressively compressed our prompts? While those are necessary operational questions, they distract from a much more fundamental architectural issue.
We eventually arrived at the only question that actually mattered: What exact durable knowledge did our organization retain after those 400 million tokens were spent?
If the answer is simply "a list of code findings" or "a merged pull request," then the vast majority of the expensive reasoning generated by those models simply evaporated into the ether. The next agent assigned to the project will inevitably need to reconstruct the exact same mental model of the architecture. Another automated reviewer will inspect the same unchanged modules. Another engineer will ask a different model the exact same contextual questions. Ultimately, the organization pays a steep computational and financial price for understanding it already purchased once before.
That was the moment AI coding stopped looking like a localized developer productivity tool. It started looking like a complex problem of organizational architecture.
The Illusion of the Local Agent
Our earliest workflows were straightforward and highly synchronous. A coding agent operated locally on an engineer's machine, acting as a hyper-fast implementation assistant. We would feed it a relatively small task; it would inspect the relevant slice of the codebase, implement the requested change, and present it back to the human. The human remained the absolute arbiter of context, architectural priorities, and the final merge decision.
This model worked well, but it was inherently bottlenecked by human bandwidth. The next logical evolution was moving more of this execution into the cloud. Cloud agents unlocked asynchronous workflows, allowing multiple tasks to be processed concurrently. Throughput undeniably improved. However, after operating this way for a while, we realized that the underlying engineering paradigm hadn't actually evolved.
The workflow was still fundamentally linear: Human → Task → Agent → Code → Human
We had successfully optimized the speed of execution, but we hadn't improved the intelligence of the organization itself. The system was fast, but it had no memory.
The Temptation (and Trap) of the Super-Agent
Once you have agents capable of asynchronous work, the most seductive next step is to grant them sweeping autonomy. The vision is compelling: an agent reads a GitHub issue, autonomously investigates the repository, selects a technical approach, implements the feature, writes the corresponding tests, reviews its own output, patches any edge cases it finds, merges the pull request, and seamlessly picks up the next ticket.
It is a beautiful idea. In our practical experience, it is also highly unreliable.
Modern foundational models are exceptionally capable, but they still fail in critical, often insidious ways. They can subtly misunderstand business requirements, completely miss overarching architectural constraints, or confidently hallucinate a dependency that doesn't exist. Most dangerously, an agent that has just committed to a flawed architectural assumption is rarely the best independent reviewer of its own flawed logic.
Human engineering organizations solved this exact problem decades ago through the separation of concerns. We enforce independent peer reviews. We separate the roles of architecture, implementation, and quality assurance. We deliberately avoid making a single entity responsible for both writing the code and validating its absolute correctness.
Instead of chasing the mythical, increasingly massive "Super-Agent," we pivoted. We began designing something entirely different: an engineering organization composed of specialized, interacting agents.
Designing Agentic Roles and Strict Boundaries
Today, our AI engineering process at HaloWarden is rigidly structured. When a sufficiently complex issue enters the pipeline, we don't just hand it to a coding model and hope for the best.
Several independent planning agents investigate the problem and propose competing solutions. Crucially, they do not see each other's initial reasoning. This enforced independence is incredibly valuable; different models (and different inference providers) often highlight entirely different trade-offs.
Following this, a synthesis agent evaluates the competing proposals and drafts a comprehensive implementation plan. This plan is not a vague directive like "implement feature X." It is a strict definition of boundaries:
- Which specific modules should be modified?
- Which adjacent systems must remain untouched?
- What architectural constraints must be respected?
- What defines a successful state?
Only after this strict boundary-setting phase does an implementation agent begin its work. To manage concurrency, each implementation agent operates within its own isolated Git worktree. While this might sound like a minor operational detail, isolation is absolutely essential when orchestrating multiple autonomous workers. Without it, agents begin reading and modifying unstable, intermediate repository states, quickly cascading into chaotic merge conflicts and broken builds.
Once implementation concludes, the primary agent reviews the changes. Subsequently, an entirely independent agent handles the pull request review. CI/CD pipelines provide the final layer of objective validation—running tests, static analysis, formatting checks, and security scanners. If meaningful discrepancies are found, the work is routed back to the implementation agent for correction.
We intentionally route these distinct roles across models from different vendors. Our objective is not to declare one AI provider universally superior; rather, it is to acknowledge that different models possess different failure modes. A genuinely independent reasoning engine is an invaluable asset in a peer-review system. Furthermore, this architectural choice ensures we avoid vendor lock-in. The underlying models should always be commoditized and replaceable. The engineering system built around them is what holds the true value.
Why Adding More Agents is Not the Answer
One of the most pervasive fallacies in agentic engineering is the assumption that adding more AI reviewers automatically yields higher quality software. In reality, it often does the opposite.
Every additional agent produces an output that must be either trusted blindly or manually verified by a human. We experimented extensively with lightweight AI reviewers that were configured to scan pull request diffs without deep contextual grounding. While they occasionally caught an obvious syntax error or a missing null check, they generated an overwhelming volume of false positives.
A naive AI reviewer might flag a piece of code as "inefficient" because it doesn't utilize a modern, high-level framework abstraction. What that agent doesn't know is that the implementation was deliberately written that way to bypass a known memory constraint on an embedded IoT device. It might recommend an architectural design pattern that the team already tested and explicitly rejected months ago. It might flag a "bug" that is, in fact, a carefully engineered fallback behavior.
When a false positive is generated, it inevitably consumes more tokens and more human time. Another agent (or a human) has to investigate the flag. More files are read. More historical context is retrieved. Eventually, the system concludes that the original AI review was completely wrong. At that point, the reviewing agent didn't improve code quality—it simply manufactured busywork.
This realization led us to a non-negotiable operational rule:
An agent must consistently reduce more uncertainty than it creates.
If it fails to do so, removing that agent from the pipeline will simultaneously improve your software quality and reduce your inference costs. Agent count is a fundamentally flawed metric for measuring AI maturity. A tightly orchestrated system with five deeply contextualized agents will infinitely outperform a chaotic swarm of thirty poorly prompted ones.
The Economics of Compounding Inference
This brings us back to the 400 million tokens.
During that massive codebase review, the agents were doing much more than just pattern matching. They were actively reconstructing our architecture, investigating memory allocation behaviors, tracing convoluted dependency trees, and deducing why certain modules were written in highly specific ways.
Some of the knowledge they generated was genuinely novel and actionable. But a massive percentage of it was knowledge the organization had already acquired in the past.
If every single AI interaction—every PR review, every feature implementation, every debugging session—starts with an empty context window, your organization is hemorrhaging its AI budget on repeated understanding. Imagine a company with hundreds of developers. Each developer has a local agent. Each agent reads the same core services. The PR reviewing agents read them again. The security scanning agents read them a third time.
Every individual interaction might feel productive to the developer staring at the screen. Globally, however, the company is paying over and over again for the exact same cognitive labor.
This systemic waste led to the core philosophical principle that now dictates how we build systems at HaloWarden:
Never pay a model to think a thought your organization has already paid for.
The industry's default approach to cost optimization is simply migrating to a cheaper, faster model. While that is a valid tactic, it is vastly inferior to structural optimization. If switching providers reduces a task's cost from $10 to $5, you’ve saved 50%. But if your engineering system is smart enough to realize that the question was already deeply investigated last week and the cached result remains architecturally valid, the cost of that task drops to zero.
The most cost-effective token is the one you never have to generate. Inference, like interest, must be forced to compound.
Transforming GitHub into an Agentic Memory Architecture
To make inference compound, we had to radically change how we interacted with GitHub. Initially, GitHub was just a place where our code lived and where human engineers managed their tickets. Over time, we transformed it into a structured, persistent memory system for our agents.
A product feature now strictly maps to a project. Projects cascade into detailed issues. Those issues are no longer just task descriptions; they are living documents that capture competing approaches, rejected hypotheses, architectural constraints, and implementation plans. Pull requests explicitly link the final code back to those foundational issues.
The result is not just a repository of code. It is a highly navigable graph of engineering context.
An agent can traverse this graph forward: Product Requirement → Feature → Issue → Pull Request → Deployed Code
More importantly, it can traverse the graph backward: Deployed Code → Pull Request → Issue → Architectural Decision → Original Requirement
That backward traversal is where the true value lies. The raw source code tells an agent what the system does. The contextual engineering history tells the agent why it does it. Both are required to make intelligent, safe modifications to a live system.
Closing an Issue is Where the Work Begins
In this new paradigm, we had to redefine the concept of "done."
When an implementation is merged to main, the issue is not simply closed and forgotten. The coordinating agent is required to return to the original issue and formally record reality.
- Which initial architectural assumptions proved incorrect during development?
- What edge cases were discovered in the wild?
- Why did the final, merged implementation deviate from the original approved plan?
This reconciliation step is critical because theoretical plans and production reality rarely align perfectly. If only the initial plan is preserved in your documentation, future AI agents will inherit a distorted, incorrect version of history. Completed issues must become immutable engineering records—not overwhelming transcripts of every LLM prompt, but refined, distilled logs of what the organization actually learned.
When Mistakes Become Immutable Architecture
This persistence of memory is particularly vital for HaloWarden, given our work involves bridging the gap between web platforms and embedded hardware.
Resource constraints in the physical world are unforgiving. We have encountered severe memory bottlenecks. We have made implementation choices that looked elegant on a local simulator but caused catastrophic failures on an ESP32 microcontroller. We have learned the hard way that a data-streaming pattern that works flawlessly on a scalable cloud server can quickly brick a resource-constrained RF device.
In an immature AI workflow, an agent fixes the memory leak, merges the PR, and moves on. Six months later, a different agent—unaware of the past—makes the exact same architectural mistake in a new module.
That is not an intelligent system.
Today, when a failure reveals a hard hardware constraint, that outcome is formalized into an architectural rule. Instead of injecting a generic, easily ignored instruction like "be careful with memory management" into a system prompt, we provide concrete, evidence-backed guardrails. The system dictates: "Do not use this specific allocation pattern in the RF ingestion subsystem. Avoid this framework feature because historical defects (linked here) demonstrate it creates unacceptable memory pressure on ESP32 devices."
The organization accumulates operational scars, and those scars are meticulously documented. This prevents future agents from walking into the same traps.
The New Definition of Token ROI
This structural evolution completely changes how engineering leaders should evaluate their AI investments.
Imagine an agent spends 200,000 tokens investigating a highly complex concurrency bug. There are two potential outcomes.
In the first scenario, the agent successfully patches the bug, the PR is merged, and the context window is cleared. A year later, a similar concurrency issue arises, and a new agent starts the investigation completely from scratch. Those 200,000 tokens were entirely consumed—burned as an operational expense.
In the second scenario, the deep investigation is automatically synthesized into a durable architectural note. The root cause is documented. A regression test is permanently added to the CI suite. The identified constraint is dynamically injected into the system prompts of any future agent modifying that specific module.
In this scenario, the next agent begins its work from an elevated baseline. Those same 200,000 tokens weren't just consumed; they were converted into a permanent organizational asset.
Moving forward, the defining metric for AI maturity won't be how many lines of code your agents generated this week. The metric that will define industry leaders is this: How much durable, reusable engineering knowledge does your organization create per million tokens consumed?
The Future of the Principal Engineer
As AI agents take over the mechanics of implementation, testing, and initial code review, the role of the human engineer does not disappear. Instead, the point of leverage shifts dramatically upward.
If a swarm of specialized agents can write the code, manually typing out functions is no longer the most valuable use of a Principal or Staff Engineer's time. The high-value work transitions entirely to systems design and boundary management.
- Where do we establish rigid architectural boundaries?
- Which subsystems require absolute reliability over speed?
- What data privacy constraints must be hardcoded into the agentic validators?
- How do we structure our semantic caching so agents seamlessly reuse past reasoning?
These are no longer just technical questions; they are organizational architecture questions. The modern Principal Engineer in an agent-first company operates less like a senior developer and more like the architect of a vast, highly capable, but easily confused workforce. You are designing the environment, the constraints, and the memory systems that allow your digital workers to succeed.
Beyond Code Generation
We are still in the early innings of this transition at HaloWarden.
We have experienced spectacular successes, watching parallel agents tear through refactoring tasks that would have taken a human team weeks. We have also experienced spectacular failures, watching uncontrolled parallel agents create massive merge conflicts and confidently hallucinate entirely new APIs. We've built highly effective context pipelines, and we've built bloated prompt architectures that cost more to run than they were worth.
But one truth has become abundantly clear: Local productivity is not the same thing as organizational intelligence.
An AI coding assistant can make a single developer incredibly fast. But an organization only becomes smarter when the knowledge generated by that speed survives the individual task. The true paradigm shift occurs when one agent's deep investigation prevents ten future investigations, when a recurring codebase review intelligently builds on the cached reasoning of last week's review, and when you can swap out foundational models without losing your company's deeply embedded architectural understanding.
The most interesting question in software engineering is no longer, "How much code can AI write?"
The defining question of the next decade is: What happens when your company has 1,000 AI workers interacting with your codebase every single day?
Will they start from absolute zero every morning, forcing you to pay for the exact same reasoning on an endless loop? Or will you build an architecture where every bug fixed, every PR merged, and every token spent makes your entire system permanently smarter?
HaloWarden Engineering Team
HaloWarden builds Unfollow, personal safety technology protecting survivors of relationship violence and stalking. We write about threat modeling, agentic engineering organizations, and privacy-preserving systems.