Software Architecture · AI Engineering Practices · 10 min read
The Human-AI-Code Triangle
Why Generative AI Is Your Design Partner, Not Your Runtime Engine
Key takeaways
- · Human judgment, AI generation, and deterministic code have wildly different cost profiles — treat them accordingly.
- · Calling an LLM on every run of a repetitive task burns tokens and introduces avoidable non-determinism.
- · The fix: use AI once, at design time, to generate the deterministic script or rule set — then let code run it at scale.
- · This isn't a blanket rule. Genuinely novel, low-volume, or fast-changing work still belongs at the AI (or human) vertex.
It is 2 a.m. and a scheduled job is quietly calling a large language model four thousand times to re-classify the same kind of support ticket it classified the same way yesterday, and the day before that. The API bill is climbing. So is the odds that, on run four thousand and one, the model formats one output field just differently enough to break a downstream parser. Nothing about this task has changed in months — only the invoice.
This is the quiet failure mode of modern AI adoption. In the rush to integrate artificial intelligence into software architecture, organizations fall into a costly trap: using AI to repeatedly solve the same deterministic problem, over and over, instead of solving it once. To build systems that are scalable, cost-effective, and predictable, we need to rethink how human intellect, AI capability, and traditional code actually interact — and, more importantly, when each one should be doing the work.
That relationship is best understood through a simple framework: the Human-AI-Code Triangle.
Figure 1
The Human-AI-Code Triangle
Cost and value hierarchy of a well-architected AI-assisted system.
HUMAN
Judgment & Taste
Defines the WHY and WHAT — domain expertise, contextual judgment, taste, requirements, guardrails. Premium, irreplaceable value.
AI
Synthesis & Generation
Design-time partner. Calibrates the recipe once: writes and tunes the script, not the runtime executor. Token cost scales with calls — carries hallucination risk.
CODE
Deterministic Execution
Runs flawlessly at scale. Same input → same output, every time. Deterministic. Auditable. Effectively free to re-run.
Anti-pattern: routing repetitive, structured tasks through the AI vertex on every run.
1. The Cost and Value Hierarchy
To optimize any system, start with the economics of its parts, not the technology. The three vertices of the triangle carry very different price tags, very different value propositions, and — this is the part teams tend to skip — very different failure modes when misused.
Human intellect — high cost, premium value
Judgment, domain expertise, aesthetic taste, and contextual understanding are the most expensive assets in any enterprise, priced by salary and calendar time rather than by the unit of work. They are also the only assets in the triangle that can define the why and the what: what "good" looks like, which exceptions matter, which trade-offs are acceptable. No amount of automation replaces that judgment — it only changes how often a human needs to exercise it.
Artificial intelligence — variable, metered cost
AI sits in the middle of the hierarchy. It mimics reasoning convincingly enough to be mistaken for judgment, but underneath, every call to a large language model consumes tokens and therefore money, at a cost that scales linearly (or worse) with volume. It is also probabilistic by construction: the same prompt can produce subtly different output on different runs, which is a feature for creative work and a liability for a financial reconciliation pipeline.
Traditional code — lowest marginal cost
Once written, deterministic code is close to free to run. A well-optimized script or compiled binary costs the electricity and CPU cycles needed to execute its instructions — a rounding error compared to either a human hour or a few thousand tokens. Its defining property is not intelligence but reliability: the same input reliably produces the same output, which is exactly what enterprise systems are built to depend on.
| Vertex | Cost driver | Scaling behavior | Failure mode | Best used for |
|---|---|---|---|---|
| Human | Salary / time — highest per-hour cost | Does not scale; one judgment call at a time | Fatigue, inconsistency, slow at volume | Setting requirements, taste, exceptions |
| AI | Tokens per call — metered, scales with volume | Scales, but cost and latency scale with it | Hallucination, format drift, non-determinism | Translating judgment into a reusable script |
| Code | CPU cycles — near-zero marginal cost | Scales close to free once written | Silent on edge cases the rules never anticipated | High-volume, repeatable execution |
2. The Mistake: Treating AI as a Constant Runtime Executor
A common anti-pattern in modern automation is routing repetitive, structured tasks through AI over and over again, on every single execution, indefinitely.
Imagine a task that regularly sorts, cleans, or classifies a 400-row dataset once a day. Run the naive way — an LLM call per row, every day, forever — and the arithmetic turns unforgiving fast:
400 rows × 1 API call each × 365 days ≈ 146,000 calls a year for a task whose underlying logic hasn't changed since the first day it ran. At even a fraction of a cent per call, that is real, recurring, indefinitely compounding spend for zero net-new value.
The dollar cost is only half the problem. AI is inherently probabilistic, so there is always a non-zero chance the model hallucinates a field, mis-categorizes an edge case, or silently changes its output format on the ten-thousandth run — after the exact same prompt sailed through the first nine thousand, nine hundred and ninety-nine times without incident. That is not a hypothetical; it is the normal, expected behavior of a system built on statistical inference rather than fixed rules.
Enterprise software demands systems that are deterministic: the same input should yield the same output, every time, auditable and reproducible on demand. A runtime architecture that re-derives the same logic from scratch on every call, at token cost, with non-zero error probability, is fighting that requirement rather than serving it.
3. The Master Chef Analogy: Scaling the Recipe, Not the Chef
Consider a catering business that suddenly receives an order for 1,000 dosas by tomorrow morning. The business employs a world-class master chef, who commands a premium salary precisely because of his refined palate, decades of technique, and instinct for when a batter needs ten more seconds on the griddle. How should the order be filled economically?
The inefficient approach: the chef stands at the stove and personally pours, flips, and plates all 1,000 dosas himself. Every one of them benefits from his skill, but the business is paying a master's hourly rate for what is, by dosa number 40, purely repetitive, mechanical labor.
The architectural approach: the chef spends the first hour designing, not cooking. He calibrates griddle temperature, locks in the batter-to-water ratio, sets the exact cook time, and configures an automated dosa machine to his standard. Once it is tuned, he hits run. The machine turns out 1,000 identical, perfectly cooked dosas at a fraction of the cost — and the chef is now free to go taste-test tomorrow's menu instead of standing at a griddle until 3 a.m.
Nothing about the chef's expertise was wasted in the second version — it was invested once, at the point of highest leverage, instead of being spent 1,000 times over on execution that did not require it. That is the entire argument of this piece, reduced to breakfast.
4. Shift from Runtime Engine to Design-Time Partner
The smart way to use AI is as a design-time partner, not a runtime engine. Instead of asking AI to perform an analysis directly, every time, on demand, ask it to write the script that performs the analysis — once, carefully, with the human in the loop to check its work.
The workflow becomes a one-directional handoff: human judgment inspires and directs → the AI engine generates and calibrates → deterministic code executes the repetitive work at scale. Concretely:
- The human provides the requirements and guardrails: what the task actually needs to do, which rules are non-negotiable, and which cases should be escalated rather than automated.
- The AI acts as an intelligent code generator, producing a precise, deterministic script — the equivalent of the chef's calibrated recipe — that encodes those requirements as fixed logic.
- The code handles high-volume execution seamlessly and cheaply, running the same input to the same output indefinitely, until the underlying requirements actually change.
Note what changed: the AI call still happens — it simply happens once (or occasionally, when requirements shift) rather than on every unit of work. The intelligence is preserved; only its billing frequency drops.
5. A Second Example: The Expense Report Auditor
The dosa machine analogy holds just as well in back-office software, where the volume is invoices instead of breakfast. Picture a finance team that manually reviews every expense report for policy violations: mismatched receipts, over-limit meals, missing manager approvals. A tempting shortcut is to hand each report to an LLM and ask, in effect, "does this comply with policy?"
That shortcut works, in the sense that it produces an answer. But it quietly re-runs the same judgment call thousands of times a month at token cost, with no hard guarantee the model applies a $75 meal cap the same way on report one as it does on report nine hundred. The design-time version looks different, and maps directly onto the three-step handoff above:
- The finance lead (human) states the actual policy in plain language: caps by expense category, receipt thresholds that trigger review, approval chains by dollar amount, and named exception rules for travel or client entertainment.
- The AI is asked once to translate that policy into a validation script — parsing line items, applying the caps, cross-checking receipts against amounts, and flagging exceptions into a structured report.
- The code runs against every incoming expense report from that point forward: free, instant, and perfectly consistent, surfacing only the genuine edge cases — an illegible receipt, a policy gap nobody anticipated — for a human to actually spend judgment on.
The chef, in this telling, is the finance lead — and he goes back to designing the menu, not standing at the griddle. When the travel policy changes next quarter, the fix is a short trip back through the human-AI step to recalibrate the script; the day-to-day volume, unaffected by the policy change, keeps running on code without interruption.
Checklist: Is This Task a Design-Time Candidate?
A task is a strong candidate for the human → AI → code pattern — rather than repeated AI calls at runtime — when most of the following are true:
- The same type of input arrives repeatedly: daily reports, recurring data pulls, routine classifications.
- The rules for handling it can be stated explicitly, even if it takes a few iterations with the AI to get them exactly right.
- You need the exact same input to produce the exact same output, every time, for audit or compliance reasons.
- Cost or latency actually matters at the volumes involved — hundreds or thousands of runs, not a handful.
- An occasional, genuinely novel or ambiguous case can be routed back to a human or a fresh AI call, rather than forcing every case through the same door.
If a task fails several of these — open-ended judgment, one-off analysis, constantly shifting inputs — it may belong at the AI vertex permanently, not just at design time. That is the subject of the next section.
6. When AI-as-Runtime Actually Makes Sense
The design-time pattern is the default for repetitive, well-defined work — it is not a universal law. There are real cases where calling AI at runtime, every single time, is the right architecture rather than a mistake, and it is worth naming them so the framework does not calcify into dogma.
- Genuinely novel inputs: customer emails, support tickets, or free-form documents where the range of phrasing and intent is too broad to encode as fixed rules without the ruleset itself becoming a second, worse AI.
- Low volume, high variance: if a task runs a handful of times a month and every instance is meaningfully different, the engineering cost of building and maintaining a deterministic script can exceed the token cost of simply asking the model each time.
- Tasks that require judgment on the spot: open-ended synthesis, first drafts, brainstorming, or anything where the "correct" output is contextual and evolving rather than a fixed rule waiting to be captured.
- Rapidly changing rules: if the underlying policy or logic changes weekly, the overhead of regenerating and re-validating a script may outweigh its benefit, at least until the rules stabilize enough to be worth locking in.
The practical test is not "AI versus code" in the abstract, but whether a task's logic is stable enough to be worth capturing. Stable, high-volume, rule-based work should graduate from the AI vertex to the code vertex. Unstable, low-volume, judgment-heavy work can reasonably stay with AI — or a human — at runtime, for now.
7. Getting Started: A Practical Rollout
Teams adopting this framework rarely need to overhaul their architecture in one pass. A narrow, low-risk rollout tends to work better than a sweeping mandate:
- Audit for repetition. Pull a list of every scheduled job or workflow that calls an LLM, and flag the ones that run against the same category of input more than a few dozen times a month.
- Pick one candidate. Choose the highest-volume, most stable offender from the checklist above — the one where the rules genuinely aren't changing week to week.
- Have the AI write the script, not run the task. Ask it to generate the deterministic logic — a parser, a rules engine, a classifier — and have a human review the generated code the way they'd review a junior engineer's pull request.
- Ship it behind a comparison window. Run the new deterministic code alongside the old runtime-AI path for a short period, diffing outputs, before fully cutting over.
- Recalibrate on a schedule, not on every run. Revisit the generated script only when the underlying policy or data actually changes — and route the true edge cases it flags back to a human, not back through the same AI call it replaced.
Repeat for the next candidate. Over a few cycles, the pattern becomes a habit: reach for AI to design the solution, and reach for code to run it.
Conclusion: Balancing the Triangle
True innovation is not about replacing traditional programming with AI; it is about knowing where to draw the lines of automation, and being willing to redraw them as a task's volume, stability, or stakes change.
Understanding the Human-AI-Code Triangle lets architects and technology leaders build guardrails that keep costs low and predictability high: reserve human capital for judgment, use AI for synthesis and generation, and let deterministic code do what it does best — run flawlessly, at scale, for next to nothing.
In one sentence
Use the chef to design the recipe once — not to stand at the stove for every single order.