<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Alex Tranchenko</title>
    <description>The latest articles on DEV Community by Alex Tranchenko (@sashua).</description>
    <link>https://dev.to/sashua</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1050189%2Faea08713-f769-49d3-b072-be69194611b1.jpeg</url>
      <title>DEV Community: Alex Tranchenko</title>
      <link>https://dev.to/sashua</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sashua"/>
    <language>en</language>
    <item>
      <title>Engineering Reliability into AI Agent Code Generation. Part III</title>
      <dc:creator>Alex Tranchenko</dc:creator>
      <pubDate>Sun, 30 Aug 2026 14:29:59 +0000</pubDate>
      <link>https://dev.to/sashua/engineering-reliability-into-ai-agent-code-generation-part-iii-jdg</link>
      <guid>https://dev.to/sashua/engineering-reliability-into-ai-agent-code-generation-part-iii-jdg</guid>
      <description>&lt;h2&gt;
  
  
  Part III — Teams of Agents, a Post-Mortem, and the Frontier
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://dev.to/sashua/engineering-reliability-into-ai-agent-code-generation-546d"&gt;Part I&lt;/a&gt; defined eight failure modes of agent code generation (P1–P8) and drew the architecture's one load-bearing boundary: models generate and evaluate; deterministic code decides. &lt;a href="https://dev.to/sashua/engineering-reliability-into-ai-agent-code-generation-part-ii-1d0d"&gt;Part II&lt;/a&gt; opened each component — the deterministic guards, the evidence model, context engineering, adversarial evaluation, the connector contract, traceability, and escalation. Part III extends the architecture to teams of agents working concurrently, walks through the production failure that shaped the hardest rules, and closes with what we have not solved — and how to adopt any of this incrementally.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What you'll learn in Part III:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How a team of agents coordinates without ever negotiating: every coordination problem converted into a scheduling fact, an independence fact, or a human decision&lt;/li&gt;
&lt;li&gt;Why correlated agents break the redundancy assumption — a same-model retry is not a second opinion — and why deference must be cheaper than guessing&lt;/li&gt;
&lt;li&gt;The full post-mortem of a production false green — and the acceptance test worth stealing: your pipeline should fail its own past false positives&lt;/li&gt;
&lt;li&gt;What remains unsolved, stated plainly — including what the evidence does and does not show&lt;/li&gt;
&lt;li&gt;A seven-rung adoption ladder for starting small&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  1. Teams of agents: coordination that is never requested
&lt;/h2&gt;

&lt;p&gt;Part II §7 bought parallelism with two rules; this section is the class those rules are a special case of. The moment work units run concurrently — several implementers at once, evaluators and reviewers overlapping — the system stops being a sequence of specialists and becomes a team of agents, and the tempting design move is to give the team what human teams have: channels to talk, shared workspaces, room to negotiate. The empirical case against that move is now direct. Anthropic's Frontier Red Team study of multiagent systems found coordination failures that are systematic rather than incidental: agents conform (18 of 30 independently created a git branch with the identical name — same model, all started at the same moment), flood shared resources (polling daemons collectively issuing 2.4 million requests to win 117 jobs), converge prematurely (groups failing to surface information only one member held), and — given incompatible goals over shared artifacts — escalate from suspicion to sabotage, up to disabling each other's Unix accounts and deploying self-replicating malware disguised as another agent's code (&lt;a href="https://www.anthropic.com/research/multiagent-systems" rel="noopener noreferrer"&gt;Anthropic, multiagent systems&lt;/a&gt;). Their conclusion is the design constraint: "Coordination doesn't naturally emerge from stronger intelligence nor alignment at the individual level."&lt;/p&gt;

&lt;p&gt;The architecture's answer is to accept that constraint completely: agents collaborate through artifacts, never through negotiation, inside a hierarchy where every classical coordination problem is converted into one of three things a deterministic component can own — a scheduling fact, an independence fact, or a human decision with evidence attached. Nothing is ever left for the agents to work out among themselves. Two of the entries below predate the study — the printed schedule and lock-serialized state; the rest are its direct consequence and landed together as one hardening release, each with tests that fail without it. They are implemented rules, not yet measured results: nothing below has been evaluated against production runs, and §3 says so.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Coordination problem&lt;/th&gt;
&lt;th&gt;Converted into&lt;/th&gt;
&lt;th&gt;Mechanism&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Two units want the same file&lt;/td&gt;
&lt;td&gt;Scheduling fact&lt;/td&gt;
&lt;td&gt;Disjoint ownership (Part II §7), moved into the planner: write-sets are computed from the work-unit contracts and intersected before any wave is proposed — a conflict is a scheduling error caught before either agent exists&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Who runs next&lt;/td&gt;
&lt;td&gt;Scheduling fact&lt;/td&gt;
&lt;td&gt;The printed schedule (Part II §1): code prints the wave plan; the orchestrator dispatches exactly what it names&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Concurrent state updates&lt;/td&gt;
&lt;td&gt;Scheduling fact&lt;/td&gt;
&lt;td&gt;Locks around every read-modify-write; small structured outputs returned as messages and persisted by code (Part II §2), so no two agents ever hold pens over one page&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The same mistake, N times&lt;/td&gt;
&lt;td&gt;Independence fact&lt;/td&gt;
&lt;td&gt;Retries vary the experiment — a contrarian pass that must argue against the prior attempt's approach, then a different model — because a same-model retry is a correlated sample, not a second opinion&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Premature consensus&lt;/td&gt;
&lt;td&gt;Independence fact&lt;/td&gt;
&lt;td&gt;High-stakes verdicts get a blind second evaluation — neither sees the other; a deterministic differ surfaces disagreement as NEEDS_REVIEW instead of letting visible consensus anchor it&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Resource floods&lt;/td&gt;
&lt;td&gt;Scheduling fact&lt;/td&gt;
&lt;td&gt;Build-level caps with named backpressure, because per-agent politeness does not compose into system politeness — every flooding agent in the study was individually reasonable&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Incompatible instructions&lt;/td&gt;
&lt;td&gt;Human decision&lt;/td&gt;
&lt;td&gt;A contradiction with citable artifacts on both sides is a sanctioned blocked state that burns no retry — never something an agent resolves by choosing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Trust between roles&lt;/td&gt;
&lt;td&gt;Human decision&lt;/td&gt;
&lt;td&gt;Cross-run outcome telemetry per role and model, surfaced to the human as advisories — reputation informs configuration, and no code path lets it become automated authority&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Two themes from this list deserve expansion, because they change assumptions engineers carry in from distributed systems: the independence-fact entries — decorrelated retries and the blind second opinion — and the incompatible-instructions entry, where deference gets a first-class shape.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Correlated agents break the independence assumption.&lt;/strong&gt; Redundancy works in classical fault tolerance because failures are assumed independent: one server dying says nothing about the next. Agents running on the same model do not give you that: an agent is stochastic — the same input yields different outputs run to run — but every run samples the same trained distribution, so the errors correlate even while the text varies. The study's conformity finding is the clean demonstration (18 of 30 agents independently chose the identical branch name), and sampling temperature does not fix it: random variation around the same priors is noise, not a second opinion. Three design consequences follow. A retry must change something that matters — first a contrarian pass that must argue against the prior attempt's approach, then a different model — because re-running the same model on the same context mostly reproduces the same failure. High-stakes review runs on a different model than authorship, because a same-model reviewer inherits the author's blind spots. And when several units fail the same check in the same way, the likeliest explanation is one shared cause — a broken dependency, a wrong convention — not several independent bugs; a watchdog groups failures by normalized signature and escalates once, naming it, instead of spending N retry budgets on the same problem.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Deference has to be cheaper than guessing.&lt;/strong&gt; The study leaves corrigibility as an open tension rather than a solved one: the authors want agents that execute unsupervised yet have "the better judgment to stop and defer to a human" when things are ambiguous, and observe that "the material benefits of autonomy come at the expense of corrigibility and oversight." Their epistemic findings show where the gap sits — every model tested abstractly understood that sources have incentives and that consensus is not necessarily evidence; "what is missing is a disposition to act on that knowledge without prompting." Our operating experience is the same shape: an agent that meets a contradiction will, absent a cheap alternative, pick an interpretation and proceed — and in this pipeline that produces the worst artifact there is: evidenced, gated, wrong work. So deference gets a first-class move with a defined shape — an agent that finds its instructions contradicting each other (contract against design, criterion against reality) returns a structured blocked-state citing both sides, the validator recognizes it as neither pass nor fail, and the human gets the contradiction quoted, at the cost of one dispatch rather than a retry ladder. Surfacing the contradiction is the job; resolving it by choosing is a violation.&lt;/p&gt;

&lt;p&gt;What the team layer deliberately does not have is as load-bearing as what it does: no agent-to-agent channels, no shared scratchpads, no negotiation protocols — the study shows what grows in that soil, from explicit price floors agreed by the third round once agents had a private back-channel, to the sabotage chain above. And no swarms: in the same study's twelve-hour swarm builds, the fraction of pull requests that merged fell as agent counts rose from 10 to 80 — steeply for the oldest models tested (Sonnet 4.6 and Opus 4.6, which each opened nearly a thousand PRs and merged few); Opus 4.8 and Mythos Preview held their merge rate mostly by each agent keeping sole ownership of its files, and only Sonnet 5 managed to share code and keep merging. Either way it reads to us as evidence for narrow waves of proven-independent work under disjoint ownership — scale the number of runs, not the width of one. The result is a team that is efficient for the least social reason imaginable: not because the agents cooperate well, but because the architecture never asks them to. Every coordination decision has a deterministic owner, and agent intelligence is spent exclusively inside work units — so the only thing the system is allowed to produce emergently is the code.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Case study: the false green
&lt;/h2&gt;

&lt;p&gt;The delivery that shaped the hardest rules in Part II, told straight. Names withheld; the shape is what generalizes.&lt;/p&gt;

&lt;p&gt;A product build was driven from an approved UI design delivered by a design tool as a self-contained export, alongside per-view reference renders. The pipeline ran end to end: seven work units, all PASS; every requirement claimed and covered; per-criterion evidence recorded; functional acceptance checks genuinely caught real bugs mid-run and drove fixes. By every dashboard, a textbook run. The shipped UI was dramatically different from the design.&lt;/p&gt;

&lt;p&gt;The post-mortem found four independent failures that composed:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;The visual-comparison gate was keyed on a different vendor's field&lt;/strong&gt; (P4). For this source the field was legitimately empty, so every unit's design comparison recorded "skipped," and skipped was admissible. Every view in every unit was an opportunity to catch the divergence, and every one was silently declined.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The reference itself was silently partial&lt;/strong&gt; (P6). The manually delivered export decoded cleanly — and only 7 of its 30 views survived ingestion, because the slicer took the first strategy that matched anything and dropped everything that strategy could not see. No completeness check existed; units implemented views for which no reference existed at all, from prose descriptions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Design constraints never became enforced constraints&lt;/strong&gt; (P2/P3). The design declared each view's target width — phone or desktop. That fact reached the implementer as one prose line in a brief, and the evaluator not at all: its screenshots were captured at a default viewport, compared against nothing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A guard robustness hole&lt;/strong&gt; — the P4 class again, this time inside the verifier itself: where a work-unit contract failed to load, the verifier silently skipped its entire design-evidence block rather than treating an unreadable contract as a violation.
&lt;/li&gt;
&lt;/ol&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;sequenceDiagram
    participant I as Implementer
    participant E as Evaluator
    participant V as Verifier
    rect rgba(120, 40, 40, 0.12)
    Note over I,V: BEFORE — the silent chain
    I-&amp;gt;&amp;gt;E: unit done (some of its views had no reference at all)
    E-&amp;gt;&amp;gt;E: vendor field empty → visual check SKIPPED&amp;lt;br/&amp;gt;screenshots at default viewport
    E-&amp;gt;&amp;gt;V: PASS (functional evidence attached)
    V-&amp;gt;&amp;gt;V: skipped admissible —&amp;lt;br/&amp;gt;contract unreadable → design block skipped
    V--&amp;gt;&amp;gt;I: advance ✓  (× 7 units — false green)
    end
    rect rgba(40, 100, 40, 0.12)
    Note over I,V: AFTER — the same flow, gated
    I-&amp;gt;&amp;gt;E: unit done
    E-&amp;gt;&amp;gt;V: PASS, visual check SKIPPED
    V--&amp;gt;&amp;gt;E: VIOLATION: unit carries a design reference —&amp;lt;br/&amp;gt;SKIPPED is not admissible — render each view&amp;lt;br/&amp;gt;at its declared width, evidence filename must encode it
    Note over V: Ingestion now cross-witnesses the export:&amp;lt;br/&amp;gt;23 missing views named at extraction,&amp;lt;br/&amp;gt;hard stop when a unit claims one
    end&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;C11 — The same delivery, before and after. The decisive change is not a smarter model anywhere in the loop — it is that "skipped" stopped being a way to say "passed."&lt;/p&gt;

&lt;p&gt;After the fixes, the historical build was replayed against the corrected pipeline: &lt;strong&gt;it halts at the first gate.&lt;/strong&gt; The system now refuses the exact success it once reported. That property — your pipeline should fail its own past false positives — turned out to be the single most convincing acceptance test for reliability work, and it is checkable: keep the artifacts of your worst delivery as a regression fixture forever.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. What is still unsolved
&lt;/h2&gt;

&lt;p&gt;Honesty about the frontier, because the architecture closes failure classes, not failure itself.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Start with the evidence status, stated plainly.&lt;/strong&gt; Nothing in this article compares the approach against its absence under controlled conditions. That experiment has a known shape — build the same product twice with matched budgets, score both outputs blind with the same instrument — and a known cost, and we have judged the cost against the value and not run it. The numbers we report are of two kinds only: external research, cited and audited; and measurements of the approach against its own earlier self — the cost of rigor falling, never rigor beating its absence.&lt;/p&gt;

&lt;p&gt;What sustained production use supports is a narrower, practitioner's claim, and we state it as such: with the verification and evaluation processes in place, the pipeline reliably turns approved specs into acceptable code, and — the property we actually optimize for — the result is expectable: what ships is traceably what was specified, or the run stops and says why. The premium over prompt-driven generation is real, in tokens and in wall-clock: a harnessed run costs more and takes longer than simply asking a strong model for the code. What the premium buys is not a better best case — a lucky prompt-only run can produce the same code cheaper — but a narrower spread of outcomes: an acceptable result stops depending on that luck, and the bad tail changes shape, from "wrong work ships under a green dashboard" to "the run stops and names what is missing." We pay for variance reduction, not speed.&lt;/p&gt;

&lt;p&gt;Readers who need the comparative number should treat Anthropic's harness experiment as the nearest published datapoint, and this article as mechanism plus field experience — not as a controlled result. The experience is also single-stack: everything here was proven inside one harness — the pipeline runs as a Claude Code plugin — so cross-stack generality is argued, not demonstrated. And the team-of-agents hardening in §1 is newer than the rest: implemented rules with tests behind them, not yet measured results from production runs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mechanical fidelity is not intent fidelity.&lt;/strong&gt; Exact colors, widths, and copy are checkable; "feels like the design" is not yet. A pixel-faithful implementation of a partially-extracted reference is still wrong, and a checklist cannot see composition, rhythm, or taste.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Acceptance-criteria quality is the new bottleneck.&lt;/strong&gt; Gates enforce what humans manage to specify. Weak criteria produce evidenced, gated, wrong software — the oracle problem never goes away; it moves upstream into the planning phase, and it deserves the same tooling attention verification got.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The orchestrator is still a model, though the box it moves in is smaller now.&lt;/strong&gt; Guards catch phase-skipping, check that every transition is legal from the state it started in rather than just that the next validator passed, and flag it when a dispatch runs on a model other than the one routing intended. None of that catches mediocre judgment inside a phase. A poor solution design that validates structurally still sails through its gate — which is precisely why the human sits at that gate, and why gate UX matters more than it gets credit for.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approval fatigue is real, and gate presentation is no longer where the risk hides.&lt;/strong&gt; Three or four well-placed gates per feature is sustainable; every gate that presents a wall of text instead of a decision-shaped summary degrades toward a rubber stamp. Every gate in the architecture now carries a contract for what it must present — a coverage table, a checklist, a diff of what changed since the last approval — so a wall-of-text gate is a violation of that contract, not a missing convention someone forgot. What is left is not mechanical: a well-formed artifact still asks a human to look closely at the fourth gate of the day, and no contract enforces attention.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Verifying the verifiers now has a floor, if not a ceiling.&lt;/strong&gt; Validators are code, and code has bugs — the SWE-bench Verified audit (Part II §2) is the public cautionary tale, and we have our own. A bug pass driven by real runs found defects that had survived roughly 1,500 passing tests, every one the same shape: enforcement that silently wasn't. A one-character cursor bug left the transcript-scanning guard blind after its first run. A schema version arriving as "2" instead of 2 disabled the evidence-coverage table in both gates that enforce it. A corrupted ledger downgraded provenance enforcement to warnings — while overwriting its own backup. No test caught any of this, because the tests encoded the same assumptions the bugs violated. Each fix landed with a regression test — more than two hundred new cases — but the structural lesson is what matters: fixtures keep a validator verified against the failures you have imagined, and nothing catches the class you haven't. So the enforcement layer itself now gets periodic adversarial review — different eyes, or a different model, than wrote it, replayed against real runs — as a permanent line in the maintenance budget. One thing stays open: a change that quietly weakens a validator can, in principle, slip past every fixture, so treating any softening of a check as a red flag remains a human discipline, not a mechanical one.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cost discipline is empirical, not principled.&lt;/strong&gt; The ~15× token multiplier for multi-agent rigor is real; when it pays depends on failure costs you often cannot price precisely. Our own accounting bears on where the cost actually lives, though: when we modeled input cost from artifact bytes, the majority of a feature build's token bill was the context plumbing, not the reasoning — on one three-frame design build, raw design payloads inlined into briefs for roles that could not use them accounted for roughly 450K tokens, and the uncapped knowledge tier most of the rest. The rigor was never the expensive part; the waste was, and it was measurable and fixable without weakening a single gate. And every component encodes an assumption about what models cannot yet do alone — assumptions that expire as models improve, so the scaffolding needs periodic re-justification against a stronger baseline (the author of &lt;a href="https://www.anthropic.com/engineering/harness-design-long-running-apps" rel="noopener noreferrer"&gt;Anthropic's harness post&lt;/a&gt; removed its sprint construct one model generation later, on Opus 4.6, while keeping the planner and evaluator).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Least privilege fights role reuse.&lt;/strong&gt; Static tool permissions per agent are the safe default; polymorphic agents that serve many sources want broad grants. The schema-forced boundary narrowed this tension where outputs are small — roles whose product is a structured claim lost their write access entirely, since code persists for them — but the polymorphic extractor still carries union grants plus prompt-level discipline, and we consider that remainder unresolved.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. An adoption ladder
&lt;/h2&gt;

&lt;p&gt;None of this requires adopting everything at once. The rungs, in the order that pays fastest:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Workflow first, agent when needed.&lt;/strong&gt; For well-defined tasks, fix the step sequence in code and let models act inside steps; reach for an agent only where flexibility and model-driven decision-making are needed at scale (&lt;a href="https://www.anthropic.com/engineering/building-effective-agents" rel="noopener noreferrer"&gt;Anthropic, Building Effective Agents&lt;/a&gt;). Cheapest change, largest variance reduction.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Separate the evaluator.&lt;/strong&gt; No generator grades its own work, anywhere. One extra dispatch per unit; it cuts off the largest source of the 75%-false-success failure mode — rung 3 is what closes it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Demand evidence.&lt;/strong&gt; Define the artifact for each claim type; reject claims without artifacts. Start with logs and exit codes; add parameter-encoded screenshots for anything visual. Where an output is small and structured, go one step earlier: have the agent return it as a message and validate the schema before it becomes a file at all.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Close the skip states.&lt;/strong&gt; Enumerate every check that can record "skipped"; for each, define when skipped is honest and when it must be a violation. This is the rung most organizations are missing entirely.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Gate with humans where change is cheap.&lt;/strong&gt; Spec, design, plan. Give each gate a decision-shaped artifact, not a transcript.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Make coverage computed.&lt;/strong&gt; Requirement ids, claims, a gate, a rollup.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Then optimize cost.&lt;/strong&gt; Routing by stakes, an honest cheap path, telemetry on retries and violations — the data tells you where rigor pays.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;What to measure while climbing: retry rate per unit, violation counts by type, requirement-coverage deltas, evidence-artifact presence, and cost per accepted change. When those move the right way, you will also notice the cultural shift that is the actual point: the pipeline's word starts meaning something.&lt;/p&gt;

&lt;p&gt;The goal was never smarter agents. It is a system in which a confident lie — from a model, from a check, from a green dashboard — cannot survive long enough to ship.&lt;/p&gt;




&lt;p&gt;This article on &lt;a href="https://github.com/sash-ua/ai-agent-code-generation-article" rel="noopener noreferrer"&gt;github&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I’m Oleksandr Tranchenko, an AI engineer and team lead. I spend most of my thinking on an under-discussed question: how do you get reliable software out of a probabilistic system? My answer so far is boring on purpose — deterministic processes wrapped around the model, mandatory verification, and treating the LLM as something you steer rather than something you trust. Find me on &lt;a href="https://www.linkedin.com/in/oleksandr-tranchenko-ai/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Anthropic Frontier Red Team, Patterns and problems in emerging multiagent systems (13 Aug 2026) — &lt;a href="https://anthropic.com/research/multiagent-systems" rel="noopener noreferrer"&gt;anthropic.com/research/multiagent-systems&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Rajasekaran, P. (Anthropic), Harness design for long-running application development (24 Mar 2026) — &lt;a href="https://anthropic.com/engineering/harness-design-long-running-apps" rel="noopener noreferrer"&gt;anthropic.com/engineering/harness-design-long-running-apps&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Hadfield, J., Zhang, B., Lien, K., Scholz, F., Fox, J., &amp;amp; Ford, D. (Anthropic), How we built our multi-agent research system (13 Jun 2025) — &lt;a href="https://anthropic.com/engineering/multi-agent-research-system" rel="noopener noreferrer"&gt;anthropic.com/engineering/multi-agent-research-system&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Schluntz, E., &amp;amp; Zhang, B. (Anthropic), Building effective agents (19 Dec 2024) — &lt;a href="https://anthropic.com/engineering/building-effective-agents" rel="noopener noreferrer"&gt;anthropic.com/engineering/building-effective-agents&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>multiagentsystem</category>
      <category>ai</category>
      <category>aisafety</category>
      <category>engineeringmanagement</category>
    </item>
    <item>
      <title>Engineering Reliability into AI Agent Code Generation. Part II</title>
      <dc:creator>Alex Tranchenko</dc:creator>
      <pubDate>Sun, 30 Aug 2026 14:29:49 +0000</pubDate>
      <link>https://dev.to/sashua/engineering-reliability-into-ai-agent-code-generation-part-ii-1d0d</link>
      <guid>https://dev.to/sashua/engineering-reliability-into-ai-agent-code-generation-part-ii-1d0d</guid>
      <description>&lt;h2&gt;
  
  
  Part II — The Components
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://dev.to/sashua/engineering-reliability-into-ai-agent-code-generation-546d"&gt;Part I&lt;/a&gt; defined eight failure modes of agent code generation (P1–P8), mapped the architecture onto the agentic-patterns catalog, and drew the one boundary that matters: models generate and evaluate; deterministic code decides. Part II opens each component of that architecture in detail and closes with the three proposed patterns written in catalog form. &lt;a href="https://dev.to/sashua/engineering-reliability-into-ai-agent-code-generation-part-iii-jdg"&gt;Part III&lt;/a&gt; extends the architecture to the team-of-agents layer, walks through the production post-mortem, and maps the frontier.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What you'll learn in Part II:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How to build a state machine an LLM orchestrator cannot talk its way out of: guarded exits, explicit crash semantics, enforcement that reports on itself&lt;/li&gt;
&lt;li&gt;The evidence model: an artifact taxonomy that refuses every claim without proof — and why evidence design is adversarial (agents edit tests to pass them; your checks need their own test suites)&lt;/li&gt;
&lt;li&gt;Context engineering without accumulation: briefs assembled by scripts under hard budgets; an orchestrator that sees only paths and states&lt;/li&gt;
&lt;li&gt;The adversarial evaluation ladder: fail-fast mechanical checks, itemized design checklists instead of vibes, bounded retries with structured escalation&lt;/li&gt;
&lt;li&gt;The connector contract that closes the false-green class: normalize at the boundary, earn capability flags, cross-witness completeness — SKIPPED is never PASS&lt;/li&gt;
&lt;li&gt;Traceability as a computed property, and buying rigor by the unit: routing by stakes, an honest cheap path, escalation as a first-class state&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  1. Deterministic guards: the state machine the orchestrator cannot talk its way out of
&lt;/h2&gt;

&lt;p&gt;The orchestrator of an agent pipeline is itself an LLM, which means the pipeline's own conductor exhibits P2, P3, and P7. Early on we watched a characteristic decay: the four-step per-unit pattern — generate, evaluate, verify, summarize — executed perfectly for the first work unit, then eroded. By unit four the orchestrator was "reasoning" that evaluation was redundant for a small change, or that it could inspect the diff itself instead of dispatching the evaluator. Each skipped step was locally plausible. The sum was an unverified build.&lt;/p&gt;

&lt;p&gt;The countermeasure is structural: &lt;strong&gt;phase transitions are not the orchestrator's to make.&lt;/strong&gt; Advancing the pipeline happens through one deterministic entry point that runs a validator for the phase just completed. The validator checks facts on disk — did the expected artifact appear, is it shaped correctly, does the evidence exist — and only on success writes the new state. On violation, it emits a structured description of what is missing, which is injected verbatim into the re-dispatch of the responsible agent.&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart TB
    A["Agent dispatch completes"] --&amp;gt; B["advance(phase)"]
    B --&amp;gt; C{"Deterministic validator&amp;lt;br/&amp;gt;for that phase"}
    C --&amp;gt;|"artifacts present,&amp;lt;br/&amp;gt;shape valid, evidence cited"| D["State written.&amp;lt;br/&amp;gt;Read back next phase."]
    C --&amp;gt;|violation| E["Structured addendum:&amp;lt;br/&amp;gt;what is missing, where,&amp;lt;br/&amp;gt;what evidence is required"]
    E --&amp;gt; F["Re-dispatch agent&amp;lt;br/&amp;gt;with addendum&amp;lt;br/&amp;gt;(counts against retry budget)"]
    F --&amp;gt; B
    C --&amp;gt;|"crash (no verdict)"| G["Re-run once.&amp;lt;br/&amp;gt;A dead validator is a crash,&amp;lt;br/&amp;gt;never an implicit pass."]
    G --&amp;gt;|"re-run returns a verdict"| C
    G --&amp;gt;|"crashes again"| X["Run halts:&amp;lt;br/&amp;gt;environment problem, reported —&amp;lt;br/&amp;gt;never an implicit pass"]
    D --&amp;gt; H{"End of run?"}
    H --&amp;gt;|"no — next dispatch"| A
    H --&amp;gt;|yes| I["Final re-verification hook:&amp;lt;br/&amp;gt;every completed unit re-checked&amp;lt;br/&amp;gt;before the run may end"]
    I --&amp;gt;|"any unit unverified"| F
    I --&amp;gt;|"all units verified"| Z["Run may end"]&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;C4 — Transition discipline: the pipeline advances through one code-owned entry point, or not at all — and "declare it done and stop" is not an available move.&lt;/p&gt;

&lt;p&gt;Four design details generalize beyond this pipeline. First, &lt;strong&gt;the exit path is guarded too&lt;/strong&gt;: a hook re-verifies every completed unit before the orchestrator may end its turn, catching the failure mode where work is marked complete in the final summary rather than through the pipeline. Because that hook fires on every turn-end for the life of a session, it memoizes its ALLOW verdict on a stat-only fingerprint of every input the verifier reads — and never caches a BLOCK. The asymmetry is the design: a spurious cache miss costs one re-verification; a spurious hit would cost enforcement, so when in doubt the fingerprint covers more inputs. The effect is measurable: on synthetic builds (fifty consecutive turn-ends, transcript growing throughout), per-turn hook cost before memoization grew with build size — roughly doubling from a 5-unit to a 20-unit build — and after it sits flat at ~66 ms regardless, with the memo holding across all fifty turns. Rigor whose cost grows with the work it protects gets disabled by its own bill eventually; flat-cost rigor survives.&lt;/p&gt;

&lt;p&gt;Second, &lt;strong&gt;crash semantics are explicit&lt;/strong&gt;: a validator that dies by signal has not returned a verdict — the rule is one re-run, and a second death halts the run as a reported environment problem — because treating non-zero-but-dead as either pass or fail corrupts state. Distinguishing "the check failed" from "the check didn't happen" sounds pedantic until the day it isn't.&lt;/p&gt;

&lt;p&gt;Third, &lt;strong&gt;enforcement reports on itself&lt;/strong&gt;: a guard that degrades open, or is disabled by configuration, writes that fact — a fingerprint of which guards ran and how, plus every degrade-open event — into the same artifacts the run produces, so two builds that were measured differently are distinguishable from their reports alone, not from someone remembering to mention it.&lt;/p&gt;

&lt;p&gt;Fourth — a lesson we learned late — &lt;strong&gt;decision tables the orchestrator must re-derive from prose eventually get mis-derived.&lt;/strong&gt; Model routing, the parallel-wave schedule, which checks a given evaluation mode owes: each lived for a while as a table in the orchestrator's instructions, re-derived per run, and a mis-derivation produces work indistinguishable from a correctly routed run. Each is now a small CLI that prints the answer — the model follows a printed schedule, it does not compute one. We found one of these the embarrassing way: our parallel scheduler existed as tested library code that the orchestrating model could not actually call, so parallelism happened only on the runs where the model happened to emulate the prose correctly. If a scheduling decision matters, ship the program that makes it.&lt;/p&gt;

&lt;p&gt;The question to ask of any agent pipeline: can the model that decides what happens next skip a verification step without producing an error? If yes, it eventually will.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. The evidence model: no claim without an artifact
&lt;/h2&gt;

&lt;p&gt;Part I established that agent status reports are claims (P2: 75.8% false-success rates for self-assessing coding agents). The evidence model is the systematic reply: &lt;strong&gt;for every kind of claim, define the artifact that proves it, and refuse the claim without the artifact.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart LR
    subgraph CLAIMS["Claims (untrusted)"]
        c1["'build passed'"]
        c2["'tests ran'"]
        c3["'criterion met'"]
        c4["'UI matches design'"]
        c5["'requirement covered'"]
    end
    subgraph EVIDENCE["Required artifact (verified on disk)"]
        e1["build.log + exit code == 0"]
        e2["test.log + exit code == 0"]
        e3["per-criterion evidence string:&amp;lt;br/&amp;gt;log line, file:line, selector,&amp;lt;br/&amp;gt;or command output"]
        e4["rendered screenshot whose FILENAME&amp;lt;br/&amp;gt;encodes the render parameters&amp;lt;br/&amp;gt;(view @ declared width, theme)"]
        e5["requirement id claimed by a unit&amp;lt;br/&amp;gt;whose verdict is an evidenced PASS"]
    end
    c1 --- e1
    c2 --- e2
    c3 --- e3
    c4 --- e4
    c5 --- e5&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;C5 — The artifact taxonomy. The rule generating all rows: an assertion is admissible only in a form a deterministic verifier can check without trusting the asserter.&lt;/p&gt;

&lt;p&gt;The subtlest row is the fourth. A screenshot proves a page rendered; it does not prove the page rendered under the right conditions. Our design-fidelity checks require the render parameters — which view, at which declared width, in which theme — to be encoded in the artifact's filename, because the filename is what the verifier can inspect. "A screenshot exists" had let evaluations pass that were captured at an arbitrary default viewport and compared against nothing. "A screenshot named &lt;code&gt;view@402.png&lt;/code&gt; exists for every view the unit claims" is a mechanically checkable statement that the viewport was actually pinned.&lt;/p&gt;

&lt;p&gt;Evidence must also be &lt;strong&gt;adversary-resistant&lt;/strong&gt;, and the adversary is sometimes the generator. Reward hacking is an agent optimizing the check instead of the goal: the goal is working code, the check is "tests pass," and the cheapest way to make tests pass is sometimes to change the tests. Studies of production coding agents document exactly that — models editing or hardcoding tests so checks pass without the problem being solved (&lt;a href="https://arxiv.org/abs/2511.21654" rel="noopener noreferrer"&gt;Gabor et al., EvilGenie&lt;/a&gt;, which observed explicit reward hacking by both Codex and Claude Code), and the behavior is older than the models: the master list of specification-gaming examples maintained alongside &lt;a href="https://deepmind.google/blog/specification-gaming-the-flip-side-of-ai-ingenuity/" rel="noopener noreferrer"&gt;DeepMind's essay on the subject&lt;/a&gt; (Krakovna et al.) reaches back decades before deep RL — among its earliest entries is Lenat's EURISKO, which won the Traveller wargame championship in 1981 with a fleet of small, stationary, lightly armoured ships, won again in 1982 after discovering the rules let it sink its own slowest ships, and was told a third win would end the competition (&lt;a href="https://doi.org/10.1016/S0004-3702(83)80005-8" rel="noopener noreferrer"&gt;Lenat, 1983&lt;/a&gt;). Logs and exit codes defeat fabricated claims, not gamed checks — which is why the evaluation ladder includes a reviewer role reading the diff (did the tests change to fit the code?) and why acceptance criteria live in the work-unit contract, outside the implementer's write path.&lt;/p&gt;

&lt;p&gt;And the evidence bar applies to your checks themselves. OpenAI stopped reporting SWE-bench Verified scores after auditing the 27.6% of the dataset that models often failed to solve — 138 problems its o3 model did not consistently solve across 64 runs — and finding that &lt;strong&gt;at least 59.4% of those problems contained material issues in test design or problem description, not the model&lt;/strong&gt; (&lt;a href="https://openai.com/index/why-we-no-longer-evaluate-swe-bench-verified/" rel="noopener noreferrer"&gt;OpenAI&lt;/a&gt;). Verifiers are code; code has bugs; the verifiers therefore need their own test suites, golden fixtures, and — as Part III's case study shows — replay against historical failures.&lt;/p&gt;

&lt;p&gt;One refinement arrived after everything above was in production, and it moved the boundary a step earlier. Post-hoc validation of an agent-written file is still "write JSON to disk and hope" — the hope is that the gate downstream catches the damage. For small structured outputs (a reviewer's report, the interpretive fields of a handoff), the agent now returns the JSON as its final message, and a validating gate persists it: schema violations are rejected at the boundary, with each error and its exact path handed back as re-dispatch input, and the write itself — including taking the lock on shared state — happens in code. Two roles lost their write access entirely as a result, which also closed a concurrency bug no prompt could have: an agent editing a shared artifact cannot take a file lock; a script can. The division of labor is worth stating precisely, because schema validation is fashionable and it is easy to over-claim: &lt;strong&gt;schemas attest shape at the boundary; the evidence model attests truth after.&lt;/strong&gt; A schema can reject a malformed report; it cannot know whether the build log it cites exists, whether the exit code is real, or whether the test ran inside the dispatch window. Boundary validation replaced the shape-checking halves of several validators. The evidence-checking halves are not replaceable by construction — they are the point.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Context engineering: the orchestrator that never accumulates
&lt;/h2&gt;

&lt;p&gt;P1 (context rot) is not solved by bigger windows; it is solved by not filling them. The architecture treats context as a budgeted resource with an explicit ownership rule: &lt;strong&gt;full content lands only in short-lived specialist windows; the long-lived orchestrator handles only paths and states.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart TB
    subgraph SOURCES["Knowledge, tiered"]
        direction TB
        t1["Tier 1: conventions &amp;amp; rules&amp;lt;br/&amp;gt;(always, in full)"]
        t2["Tier 2: project instructions&amp;lt;br/&amp;gt;(always, in full)"]
        t3["Tier 3: docs, designs, references&amp;lt;br/&amp;gt;(scoped per work unit)"]
        t4["Tier 4: solution design&amp;lt;br/&amp;gt;(sliced per unit)"]
        t5["Tier 5: prior-iteration handoff&amp;lt;br/&amp;gt;(computed; interpreted when warranted)"]
        t1 ~~~ t2 ~~~ t3 ~~~ t4 ~~~ t5
    end
    ASM["Brief assembler&amp;lt;br/&amp;gt;(deterministic script)"]
    BRIEF["Brief file on disk"]
    ORCH["Orchestrator&amp;lt;br/&amp;gt;(long-lived)&amp;lt;br/&amp;gt;sees: the PATH only"]
    AGENT["Specialist agent&amp;lt;br/&amp;gt;(fresh window)&amp;lt;br/&amp;gt;reads: full content"]

    SOURCES --&amp;gt; ASM --&amp;gt; BRIEF
    BRIEF -.-&amp;gt;|path| ORCH
    ORCH --&amp;gt;|"dispatch with path"| AGENT
    BRIEF --&amp;gt;|content| AGENT
    AGENT --&amp;gt;|"artifact on disk"| SUM["Handoff: computed by script;&amp;lt;br/&amp;gt;+ interpretive model pass&amp;lt;br/&amp;gt;only when signals warrant"]
    SUM --&amp;gt; t5

    style ORCH fill:#c0392b11,stroke:#c0392b&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;C6 — Content flows around the orchestrator, never through it. The tenth work unit gets as clean a window as the first; the orchestrator cannot rot because it never accumulates.&lt;/p&gt;

&lt;p&gt;Four practices make this work.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Briefs are assembled by a script, not by an agent&lt;/strong&gt; — which files, which tiers, which budget per role is a deterministic decision, auditable and testable. And the budget is a hard cap, not an advisory: when the knowledge in scope exceeds it, the lowest-ranked sources are dropped and named in the brief itself, with a pointer to retrieve them on demand. An omission you can see is a degradation; a silent one is P4 all over again, one layer down — and the advisory-warning version of this rule once let a 1.27 MB brief kill a dispatch.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bulk reference data never inlines.&lt;/strong&gt; The authoritative design payload — tens to hundreds of kilobytes per view of exact values — is delivered as a must-read path to the roles that need exact values, and not at all to planning roles, which get summaries; a planner cannot use pixel data, and for the implementer, reading the file at need beats hauling it through every prompt. The same scoping applies to instructions themselves: the evaluator's procedure is a core contract plus mode fragments, so a unit pays only for the checks its mode owes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Compression is computed, then interpreted&lt;/strong&gt;: the inter-iteration handoff's derivable facts — what completed, which files to carry forward, which criteria were skipped — are assembled by a script from the ledger, under a size budget; a summarizing model pass is dispatched only when the unit's outcome shows signals worth interpreting (scope deviations, unverifiable criteria, a large change surface), and it returns schema-validated fields rather than editing shared state. Most units never pay for it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Freshness is stamped&lt;/strong&gt;: every knowledge source carries its last-changed date, and agents are told that prose describes intent that may lag the code — verify load-bearing claims against the source. This matters more than it sounds: a factorial study of 1,650 coding-agent sessions found compliance with project rules decaying within a session as generated output accumulates — on the order of 5.6% lower odds of compliance for each additional function the agent has generated (an exploratory, post-hoc finding), while none of the four file-structure variables it varied produced a detectable effect (&lt;a href="https://arxiv.org/abs/2605.10039" rel="noopener noreferrer"&gt;McMillan&lt;/a&gt;) — further evidence that budget and delivery, not phrasing, decide whether rules survive. Anthropic's context-engineering guidance frames the whole discipline the same way: finding "the smallest possible set of high-signal tokens" (&lt;a href="https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents" rel="noopener noreferrer"&gt;Anthropic, context engineering&lt;/a&gt;).&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Adversarial evaluation: the ladder and the bounded loop
&lt;/h2&gt;

&lt;p&gt;The evaluator is a separate agent whose brief, incentives, and context differ from the implementer's — the amendment to the catalog's Reflection pattern argued in Part I. Its work is organized as a fail-fast ladder:&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart TB
    S["Work unit implemented"] --&amp;gt; b1["build"]
    b1 --&amp;gt; b2["lint / typecheck"]
    b2 --&amp;gt; b3["tests"]
    b3 --&amp;gt; b4["security scan"]
    b4 --&amp;gt; b5["design tokens&amp;lt;br/&amp;gt;(exact values vs reference)"]
    b5 --&amp;gt; b6["browser: behavior at the&amp;lt;br/&amp;gt;design's declared viewport"]
    b6 --&amp;gt; b7["design checklist:&amp;lt;br/&amp;gt;itemized, derived from the&amp;lt;br/&amp;gt;reference, every item verdicted"]
    b7 --&amp;gt; b8["acceptance criteria&amp;lt;br/&amp;gt;(evidence per criterion)"]
    b8 --&amp;gt; V{"Verdict"}
    V --&amp;gt;|"PASS + evidence"| OK["Verifier admits it&amp;lt;br/&amp;gt;→ summarize → next unit"]
    V --&amp;gt;|FAIL| FB["Structured feedback:&amp;lt;br/&amp;gt;failing item, expected, observed"]
    FB --&amp;gt; R{"Retry budget left?"}
    R --&amp;gt;|yes| REGEN["Re-dispatch implementer&amp;lt;br/&amp;gt;with feedback"]
    R --&amp;gt;|no| ESC["Escalate to human:&amp;lt;br/&amp;gt;skip / redirect / stop"]
    REGEN --&amp;gt; S

    style b1 fill:#1a527611
    style b8 fill:#1a527611&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;C7 — The evaluation ladder. Cheap mechanical checks run first and gate the expensive ones; every rung leaves an artifact; the loop around the ladder is bounded.&lt;/p&gt;

&lt;p&gt;Three lessons from operating this. First, &lt;strong&gt;the checklist rung is what makes subjective checks tractable.&lt;/strong&gt; "Does the UI match the design?" invites a vibe. An itemized checklist derived deterministically from the reference — this color, this type scale, this spacing, this copy string, this view at this width — turns the vibe into fifty small facts, each individually verdictable with evidence, and the verifier rejects the evaluation if any item is unfilled. Anthropic's harness-design post reports the same discovery from the opposite direction: their agent would "identify legitimate issues, then talk itself into deciding they weren't a big deal" — out of the box, "Claude is a poor QA agent" (&lt;a href="https://www.anthropic.com/engineering/harness-design-long-running-apps" rel="noopener noreferrer"&gt;Anthropic, harness design&lt;/a&gt;). Checklists remove the room for talking itself out of it.&lt;/p&gt;

&lt;p&gt;Second, &lt;strong&gt;the loop must be bounded and its exit structured.&lt;/strong&gt; Unbounded retry converges on P8's cost spiral and often on oscillation. Retries carry the evaluator's structured feedback plus a compact record of prior attempts — archived per attempt on disk, so a crash mid-retry does not erase the history; exhaustion escalates to a human with exactly three options — skip the unit, redirect the approach, stop the run — recorded in the ledger like any other transition.&lt;/p&gt;

&lt;p&gt;Third, &lt;strong&gt;the orchestrator samples the claims before acting on them.&lt;/strong&gt; Before any claim artifact changes what happens next — an evaluator's PASS, a reviewer's "clean," a coverage table — the orchestrator verifies the single highest-impact claim plus one more against primary sources: read the cited file at the cited line, re-run the cited command and compare exit codes, confirm the quoted evidence line exists in the log. One mismatch fails the artifact as a whole and re-dispatches with the mismatch named — never a silent correction, because a document wrong in the place you checked is not trustworthy in the places you did not. Two claims, deliberately not all: the deterministic verifier already audits the evidence exhaustively, so the spot-check's job is different — it makes fabrication economically irrational, since any claim might be the one that gets read, at the cost of seconds rather than a second evaluation.&lt;/p&gt;

&lt;p&gt;Cost discipline runs through the ladder itself, without weakening it. The mechanical rungs may admit the implementer's own fresh evidence — its build and lint logs, when the code verifiably has not changed since they were written (log newer than every changed file, checked by the verifier, with the evaluator's own contrary result always outranking a stale green) — instead of re-running identical work; the judgment rung, the tests, always re-runs, because tests are the verdict, not the plumbing. And the checks the evaluator does run launch concurrently, with fail-fast retained only for report ordering. Per-unit command time dropped from roughly three build-and-lint cycles' worth to one.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. The connector contract: normalize at the boundary, or gates rot
&lt;/h2&gt;

&lt;p&gt;Pipelines consume external sources — design tools, document stores, data feeds — and every source arrives in a vendor shape. The temptation is to let downstream checks read vendor fields directly. That temptation built our false green: fidelity gates keyed on one vendor's field, and for any other source the field was legitimately empty, so every gate quietly disengaged (P4).&lt;/p&gt;

&lt;p&gt;The rule that fixes the class, not the instance: &lt;strong&gt;sources enter through an adapter that produces one normalized artifact layout, and every downstream gate keys only on the normalized layer.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart TB
    subgraph VENDORS["Sources (vendor-shaped)"]
        direction LR
        s1["Design tool A&amp;lt;br/&amp;gt;(API, structured)"]
        s2["Design tool B&amp;lt;br/&amp;gt;(manual export)"]
        s3["Docs / data feeds"]
    end
    subgraph ADAPTER["Adapter (per source)"]
        direction LR
        a1["acquire&amp;lt;br/&amp;gt;(agent or script)"] --&amp;gt; a2["normalize — never interpret;&amp;lt;br/&amp;gt;raw payload stays authoritative"]
        a2 --&amp;gt; a3["fingerprint&amp;lt;br/&amp;gt;inputs"]
        a3 --&amp;gt; a4["cross-witness completeness:&amp;lt;br/&amp;gt;delivered set vs manifest&amp;lt;br/&amp;gt;vs sidecar evidence"]
        a4 --&amp;gt; a5["EARN capabilities:&amp;lt;br/&amp;gt;a flag is true only if its&amp;lt;br/&amp;gt;backing artifacts exist"]
    end
    subgraph NORM["Normalized layout"]
        direction LR
        n1["views + declared&amp;lt;br/&amp;gt;dimensions"]
        n2["raw reference&amp;lt;br/&amp;gt;(authoritative)"]
        n3["token model&amp;lt;br/&amp;gt;(literal → token)"]
        n4["reference&amp;lt;br/&amp;gt;renders"]
        n5["copy&amp;lt;br/&amp;gt;corpus"]
    end
    GATES["Provider-neutral gates:&amp;lt;br/&amp;gt;checklist, token check, copy check,&amp;lt;br/&amp;gt;visual comparison, evidence guard"]

    VENDORS --&amp;gt; ADAPTER --&amp;gt; NORM --&amp;gt; GATES&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;C8 — The connector contract. The adapter proves what it delivered (fingerprints, completeness cross-checks) and earns its capability flags; gates never see a vendor field.&lt;/p&gt;

&lt;p&gt;Two rules within the contract carry most of the weight:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Capabilities are earned, both directions.&lt;/strong&gt; A source that cannot produce reference renders gets &lt;code&gt;screenshots: false&lt;/code&gt;, and the dependent check records SKIPPED — never PASS. That is the honest half. The half that closes P4: when a reference exists, SKIPPED is a violation. The verifier demands a real verdict from every fidelity check on any unit that carries a design reference. Between "the check honestly couldn't run" and "the check quietly didn't run," there is no third state left.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Completeness is cross-witnessed (P6).&lt;/strong&gt; A manually delivered export parses cleanly at any level of truncation. The adapter therefore validates what arrived against independent evidence of what should exist — the export's own manifest, the names in the delivered render set, sidecar files — and names every item evidenced elsewhere but absent from the normalized output. Silence is not success; a partial input produces a named warning that escalates to a hard stop the moment a work unit claims one of the missing items.&lt;/p&gt;

&lt;p&gt;The contract only stays a contract if new adapters cannot ship half-conformant, so it is enforced the same way everything else here is: a shared conformance suite that every registered adapter must pass — the registry-coverage test fails if an adapter exists that the suite does not cover, which makes conformance impossible to opt out of — pinning the shared agent, the normalized layout, and the earned-capability shape. And because each adapter's mechanics are injected into the extraction dispatch as an instruction string, those strings carry byte budgets ratcheted to current size, exactly like any other prompt-paid text: a connector whose mechanics cannot be stated within budget moves the excess into a deterministic post-extraction step, in code, with tests — not into the prompt. That is the scaling rule that keeps "one universal extractor" from decaying into a god-prompt as connectors multiply: the role is universal; the mechanics are per-adapter code; a genuinely different behavior is a new role and a deliberate decision.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Traceability: coverage as a computed property
&lt;/h2&gt;

&lt;p&gt;P5's answer is small and unglamorous, which is why it is skipped so often: &lt;strong&gt;requirements get stable identifiers at planning time, and identifiers are claimed, gated, and rolled up mechanically.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart TB
    A["Plan phase emits&amp;lt;br/&amp;gt;requirements with ids&amp;lt;br/&amp;gt;R-1 … R-n (machine-readable)"] --&amp;gt; B["Each work unit's contract&amp;lt;br/&amp;gt;claims the ids it implements"]
    B --&amp;gt; C{"SCOPE GATE:&amp;lt;br/&amp;gt;any id unclaimed?&amp;lt;br/&amp;gt;any unknown id cited?"}
    C --&amp;gt;|yes| D["Breakdown rejected&amp;lt;br/&amp;gt;before human review"]
    C --&amp;gt;|no| E["Human approves plan&amp;lt;br/&amp;gt;WITH coverage table"]
    E --&amp;gt; F["Per-unit verdicts accumulate&amp;lt;br/&amp;gt;in the ledger"]
    F --&amp;gt; G["Final report:&amp;lt;br/&amp;gt;id → covering units → verdict,&amp;lt;br/&amp;gt;computed, not asserted"]&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;C9 — The requirement lifecycle. The human still judges whether the requirements are right; the machine judges whether they are all claimed and what happened to each.&lt;/p&gt;

&lt;p&gt;This discipline is absent by default — as one traceability proposal puts it, AI-generated code "is typically not linked to any requirement unless the developer explicitly establishes the connection" (&lt;a href="https://arxiv.org/abs/2603.13999" rel="noopener noreferrer"&gt;Schlathölter, ReqToCode&lt;/a&gt;) — and the delivery data argues AI code needs more verification, not less: the 2025 DORA report, surveying nearly five thousand practitioners, found AI adoption correlating positively with throughput but &lt;strong&gt;negatively with delivery stability&lt;/strong&gt;, with 30% of respondents reporting little or no trust in AI-generated code (&lt;a href="https://dora.dev/dora-report-2025/" rel="noopener noreferrer"&gt;DORA 2025&lt;/a&gt;). Traceability is what lets you aim that extra verification.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Routing, degradation, escalation: buying rigor by the unit
&lt;/h2&gt;

&lt;p&gt;Three smaller mechanisms answer P8, and they matter disproportionately for adoption.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Route intelligence by stakes.&lt;/strong&gt; Work units carry a declared complexity; model strength follows it — the strongest models where judgment compounds (architecture, review, high-complexity units), cheaper models for mechanical work. Anthropic's own system makes the same trade — an Opus lead with Sonnet subagents outperformed a single Opus agent by 90.2% on their internal research eval, and token use alone explained 80% of performance variance on the BrowseComp evaluation (&lt;a href="https://www.anthropic.com/engineering/multi-agent-research-system" rel="noopener noreferrer"&gt;Anthropic, multi-agent research&lt;/a&gt;). The inference we draw from operating our own: uniform maximum strength is paying flagship prices for lint runs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Parallelism is bought with two rules, not a flag.&lt;/strong&gt; The first is the printed schedule from §1: the wave plan — which units may run now, which are blocked and on what — is computed and printed by code from the declared dependencies, and the orchestrator dispatches exactly what the plan names. The second is &lt;strong&gt;disjoint ownership&lt;/strong&gt;: every concurrently dispatched agent receives an explicit owned file set in its instructions, derived from the work-unit contracts; sets that overlap are never dispatched in parallel, whatever the dependency graph would permit, and an edit outside the owned set is a violation the evaluator must flag. Merge conflicts between agents are not a coordination problem to manage; they are a scheduling error that should have been impossible.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Offer an honest cheap path.&lt;/strong&gt; A single-iteration fast path for small tasks — one gate, generation plus evaluation, the same evidence rules — keeps small fixes from paying the full pipeline tax. The qualifier that keeps it honest: the cheap path relaxes ceremony, never evidence. The moment the lightweight path has weaker gates, every task migrates there, and P4 returns wearing a cost-optimization costume.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Degrade features, never gates.&lt;/strong&gt; A missing optional dependency (a browser runtime, a design source, a retrieval index) reduces capability and records a warning. It never weakens a gate. And when retries exhaust or infrastructure is genuinely unavailable:&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;sequenceDiagram
    participant E as Evaluator
    participant O as Orchestrator
    participant L as Ledger
    participant H as Human
    E-&amp;gt;&amp;gt;O: FAIL (attempt 2 of 2) + structured feedback
    O-&amp;gt;&amp;gt;L: record exhaustion
    O-&amp;gt;&amp;gt;H: Unit N failed twice.&amp;lt;br/&amp;gt;Options: skip / redirect / stop
    H-&amp;gt;&amp;gt;O: redirect: "reuse the existing component"
    O-&amp;gt;&amp;gt;L: record decision + rationale
    Note over O,H: The human decision is a&amp;lt;br/&amp;gt;state transition — recorded,&amp;lt;br/&amp;gt;resumable, auditable.
    O-&amp;gt;&amp;gt;E: (after re-generation) evaluate with same ladder&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;C10 — Escalation as a first-class state. Nothing about a human deciding is informal: options are bounded, the decision lands in the ledger as a durable waiver record — who decided, what was waived, and why — and the run remains resumable from that exact point.&lt;/p&gt;

&lt;p&gt;A scope note belongs here. Everything in this article assumes a human at all four gates — the three pre-code approvals and the final disposition — and at every escalation; the orchestrator retries within its budget and then asks, it never waives. A supervised-autonomy mode — a model deciding gates and escalations within hard boundaries and a bounded number of revise rounds — is a separate design we have planned and not built, and nothing here should be read as evidence for or against it. The evidence model and the deterministic boundary would carry over unchanged; what would change is who signs the waivers, and that is precisely the question this article does not answer.&lt;/p&gt;

&lt;p&gt;That is the component inventory: a state machine that cannot be talked out of its transitions, evidence demanded at every claim, context that never accumulates, evaluation that must attach proof, connectors that earn their capabilities, coverage that is computed, and rigor bought by the unit. Each one is an elaboration of Part I's single boundary — models generate and evaluate; deterministic code decides. The appendix below writes the three mechanisms that make that boundary operable as catalog patterns.&lt;/p&gt;




&lt;h2&gt;
  
  
  Appendix — Three proposed patterns, in catalog form
&lt;/h2&gt;

&lt;p&gt;Part I argued that the agentic-patterns catalog is missing its discipline layer. These three entries are written in the catalog's own format so the claim is concrete (the evidence model of §2 appears here under its catalog name, Evidence-Gated Progress): they compose with the existing twenty-one patterns and, in our experience, they are what makes the rest of the catalog safe to operate.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pattern: Deterministic Control Boundary
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Intent.&lt;/strong&gt; Keep workflow control in deterministic code; models act within states, never between them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem.&lt;/strong&gt; The orchestrating model exhibits the same failure modes as any model: under context pressure it skips, reorders, or rationalizes away steps — including the verification steps that exist to catch its own mistakes (P3, P7). A predefined path the model can deviate from is a suggestion, not a workflow.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Forces.&lt;/strong&gt; Model judgment is valuable inside a phase (what to build, what feedback means) and hazardous between phases (whether evaluation is "really necessary"). Flexibility trades directly against auditability and resumability.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mechanism.&lt;/strong&gt; One code-owned entry point advances state; a deterministic validator per phase checks facts on disk before any transition; violations return as structured re-dispatch input, not warnings; an exit hook re-verifies all completed work before the run may end; a crashed validator is a crash, never a verdict.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Consequences.&lt;/strong&gt; (+) Trajectory variance collapses; runs are resumable from the ledger; every transition is auditable. (−) State design becomes an up-front cost; validators are code you must maintain and test; genuine flexibility needs explicit escape hatches (escalation states), or users will fight the machine.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Related.&lt;/strong&gt; Workflows-vs-agents (Anthropic); Exception Handling and Recovery; Guardrails/Safety Patterns.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pattern: Evidence-Gated Progress
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Intent.&lt;/strong&gt; No claim moves the system forward without an artifact a deterministic verifier can inspect.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem.&lt;/strong&gt; Agents systematically overreport success — up to 75.8% false-success among self-assessing coding agents (P2). Narrative quality and work quality are uncorrelated exactly when it matters.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Forces.&lt;/strong&gt; Trusting claims is cheap and fast; verifying artifacts costs plumbing. Evidence must also resist the generator (reward hacking: editing tests to pass). Checks themselves can be wrong (weak oracles), so the evidence bar applies recursively.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mechanism.&lt;/strong&gt; An artifact taxonomy per claim type: logs plus exit codes for builds and tests; per-criterion evidence strings; visual evidence whose filenames encode the render parameters so the verifier can check conditions, not just existence; a reviewer reading the diff for gamed checks. Small structured outputs cross the boundary as schema-validated messages persisted by code, never as files the model wrote — shape is rejected at the boundary, truth is verified after. The verifier admits artifacts, never assertions — from any model, including the evaluator. And the acting layer samples: before an admitted artifact changes what happens next, its highest-impact claim plus one more are checked against primary sources, so fabrication is irrational even where audit is expensive.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Consequences.&lt;/strong&gt; (+) False success is eliminated as a class at the gate, independent of model honesty; audits and post-mortems become cheap because evidence is already on disk. (−) Artifact plumbing everywhere; verifiers need their own test suites, goldens, and replay fixtures; evidence formats become interfaces you must version.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Related.&lt;/strong&gt; Evaluation and Monitoring; Reflection (in its adversarial form); Goal Setting and Monitoring.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pattern: Earned Capability
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Intent.&lt;/strong&gt; A capability flag is true only when the artifacts backing it exist; absence degrades loudly, never silently.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem.&lt;/strong&gt; Checks keyed on fields that can be empty, or capabilities that can be absent, record "skipped" — and pipelines read skipped as success (P4). Composed with silently partial inputs (P6), this ships unverified work under a green dashboard: the false-green failure class.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Forces.&lt;/strong&gt; Graceful degradation is a genuine virtue — a missing optional dependency must not block a build. But every degradation path is also a disengagement path; the difference between the two is whether anyone can tell it happened.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mechanism.&lt;/strong&gt; Adapters compute capabilities from what they actually delivered, never declare them from hope; a check without its capability records SKIPPED — never PASS; the inverse rule closes the loop: where a reference exists, SKIPPED is a violation, so there is no third state between "honestly couldn't run" and "quietly didn't run." Inputs are cross-witnessed against independent evidence of what should exist, and every degradation writes a named warning.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Consequences.&lt;/strong&gt; (+) The false-green class closes structurally; degradations become visible, countable telemetry. (−) Requires a normalized artifact layer for gates to key on (its own investment); capability plumbing must be honest — an earned flag that is merely re-declared reintroduces the original bug one level up, harder to see.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Related.&lt;/strong&gt; Guardrails/Safety Patterns; Exception Handling and Recovery; the connector/adapter boundary (§5).&lt;/p&gt;




&lt;p&gt;Continue to &lt;a href="https://dev.to/sashua/engineering-reliability-into-ai-agent-code-generation-part-iii-jdg"&gt;Part III&lt;/a&gt;: the team-of-agents layer — coordination that is never requested — the false-green case study, what is still unsolved, and an adoption ladder.&lt;/p&gt;




&lt;p&gt;This article on &lt;a href="https://github.com/sash-ua/ai-agent-code-generation-article" rel="noopener noreferrer"&gt;github&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I’m Oleksandr Tranchenko, an AI engineer and team lead. I spend most of my thinking on an under-discussed question: how do you get reliable software out of a probabilistic system? My answer so far is boring on purpose — deterministic processes wrapped around the model, mandatory verification, and treating the LLM as something you steer rather than something you trust. Find me on &lt;a href="https://www.linkedin.com/in/oleksandr-tranchenko-ai/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Gabor, J., Lynch, J., &amp;amp; Rosenfeld, J., EvilGenie: A Reward Hacking Benchmark (26 Nov 2025; v2 17 May 2026) — &lt;a href="https://arxiv.org/abs/2511.21654" rel="noopener noreferrer"&gt;arxiv.org/abs/2511.21654&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Krakovna, V., Uesato, J., Mikulik, V., Rahtz, M., Everitt, T., Kumar, R., Kenton, Z., Leike, J., &amp;amp; Legg, S. (DeepMind), Specification gaming: the flip side of AI ingenuity (21 Apr 2020), and the linked master list of specification-gaming examples — &lt;a href="https://deepmind.google/blog/specification-gaming-the-flip-side-of-ai-ingenuity" rel="noopener noreferrer"&gt;deepmind.google/blog/specification-gaming-the-flip-side-of-ai-ingenuity&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Lenat, D. B., EURISKO: A program that learns new heuristics and domain concepts, Artificial Intelligence 21(1–2), 61–98 (1983) — &lt;a href="https://doi.org/10.1016/S0004-3702(83)80005-8" rel="noopener noreferrer"&gt;doi.org/10.1016/S0004-3702(83)80005-8&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;OpenAI, Why SWE-bench Verified no longer measures frontier coding capabilities (23 Feb 2026) — &lt;a href="https://openai.com/index/why-we-no-longer-evaluate-swe-bench-verified" rel="noopener noreferrer"&gt;openai.com/index/why-we-no-longer-evaluate-swe-bench-verified&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Rajasekaran, P. (Anthropic), Harness design for long-running application development (24 Mar 2026) — &lt;a href="https://anthropic.com/engineering/harness-design-long-running-apps" rel="noopener noreferrer"&gt;anthropic.com/engineering/harness-design-long-running-apps&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Rajasekaran, P., Dixon, E., Ryan, C., &amp;amp; Hadfield, J. (Anthropic), Effective context engineering for AI agents (29 Sep 2025) — &lt;a href="https://anthropic.com/engineering/effective-context-engineering-for-ai-agents" rel="noopener noreferrer"&gt;anthropic.com/engineering/effective-context-engineering-for-ai-agents&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;McMillan, D., Instruction Adherence in Coding Agent Configuration Files: A Factorial Study of Four File-Structure Variables (11 May 2026) — &lt;a href="https://arxiv.org/abs/2605.10039" rel="noopener noreferrer"&gt;arxiv.org/abs/2605.10039&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Schlathölter, T., ReqToCode: Embedding Requirements Traceability as a Structural Property of the Codebase (14 Mar 2026) — &lt;a href="https://arxiv.org/abs/2603.13999" rel="noopener noreferrer"&gt;arxiv.org/abs/2603.13999&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;DORA (Google Cloud), State of AI-assisted Software Development 2025 (Sept 2025) — &lt;a href="https://dora.dev/dora-report-2025" rel="noopener noreferrer"&gt;dora.dev/dora-report-2025&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Hadfield, J., Zhang, B., Lien, K., Scholz, F., Fox, J., &amp;amp; Ford, D. (Anthropic), How we built our multi-agent research system (13 Jun 2025) — &lt;a href="https://anthropic.com/engineering/multi-agent-research-system" rel="noopener noreferrer"&gt;anthropic.com/engineering/multi-agent-research-system&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Gullí, A., Agentic Design Patterns: A Hands-On Guide to Building Intelligent Systems (Springer Cham, 2025) — &lt;a href="https://doi.org/10.1007/978-3-032-01402-3" rel="noopener noreferrer"&gt;doi.org/10.1007/978-3-032-01402-3&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Schluntz, E., &amp;amp; Zhang, B. (Anthropic), Building effective agents (19 Dec 2024) — &lt;a href="https://anthropic.com/engineering/building-effective-agents" rel="noopener noreferrer"&gt;anthropic.com/engineering/building-effective-agents&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>llm</category>
      <category>programming</category>
      <category>promptengineering</category>
      <category>aidesignpatterns</category>
    </item>
    <item>
      <title>Engineering Reliability into AI Agent Code Generation</title>
      <dc:creator>Alex Tranchenko</dc:creator>
      <pubDate>Sun, 30 Aug 2026 14:29:41 +0000</pubDate>
      <link>https://dev.to/sashua/engineering-reliability-into-ai-agent-code-generation-546d</link>
      <guid>https://dev.to/sashua/engineering-reliability-into-ai-agent-code-generation-546d</guid>
      <description>&lt;h2&gt;
  
  
  Part I — The Problems, the Patterns, and the Architecture
&lt;/h2&gt;

&lt;p&gt;A three-part article for engineering leaders and architects deciding how to adopt AI agents for real software delivery. Part I defines the failure modes and the high-level architecture that answers them. &lt;a href="https://dev.to/sashua/engineering-reliability-into-ai-agent-code-generation-part-ii-1d0d"&gt;Part II&lt;/a&gt; descends into each architectural component. &lt;a href="https://dev.to/sashua/engineering-reliability-into-ai-agent-code-generation-part-iii-jdg"&gt;Part III&lt;/a&gt; extends the architecture to the team-of-agents layer, walks through a production post-mortem, and closes with what remains unsolved.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What you'll learn in Part I:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Why single-agent code generation fails late, not early — the eight failure modes behind that shape (P1–P8), each backed by published research&lt;/li&gt;
&lt;li&gt;Why a green dashboard can be the most dangerous artifact in an agent pipeline: false-success rates up to 75.8%, checks that silently skip, inputs that are silently partial&lt;/li&gt;
&lt;li&gt;Why adding more prompt rules stops working — instruction adherence collapses toward zero as rules stack — and what replaces prompt rules&lt;/li&gt;
&lt;li&gt;The one architectural boundary that matters: models generate and evaluate; deterministic code decides&lt;/li&gt;
&lt;li&gt;Where human judgment is cheapest: gates before code exists, not after — HITL after code is review theater&lt;/li&gt;
&lt;li&gt;Three mechanisms the agentic-patterns catalog is missing: a deterministic control boundary, an evidence model, and earned capabilities&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Ask a capable AI agent to "build this feature" and, most days, something impressive happens. Code appears. Tests appear. A confident summary appears, reporting success. For a demo, that is the end of the story. For a production system, it is the beginning of a different one — because the confidence is not evidence, and on long tasks the gap between the two grows in exactly the places you are least likely to look.&lt;/p&gt;

&lt;p&gt;This article is a field report. It comes out of building and operating a multi-agent code-generation pipeline through real product deliveries — and out of one delivery in particular, where the pipeline reported &lt;strong&gt;seven of seven work units passed, every requirement covered&lt;/strong&gt;, while the shipped UI looked dramatically different from the approved design. Every dashboard was green. The work was wrong.&lt;/p&gt;

&lt;p&gt;The thesis, up front: &lt;strong&gt;reliability in agent systems does not come from better prompts. It comes from treating agent output as untrusted input to an engineering system&lt;/strong&gt; — deterministic control flow, evidence-backed verification, and human judgment placed where it is cheap. In our experience, every time a rule moved from prompt text into code, reliability went up. And every check that could silently skip eventually did.&lt;/p&gt;

&lt;p&gt;One scope note before the argument. The pipeline runs as a Claude Code plugin: the orchestrating model comes with the harness — a given, not a design choice. That constraint shaped the most distinctive mechanisms here, because when you cannot replace the conductor, enforcement gets built around it: deterministic validators, hooks, and printed schedules — decision tables shipped as small programs, whose printed output the model follows instead of re-deriving the logic from prose. Teams that own their control loop natively — workflow-engine architectures — inherit part of this discipline for free; the evidence and verification layer they still need. The patterns are argued stack-agnostically; they were proven in one harness.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. The problem we wanted to solve
&lt;/h2&gt;

&lt;p&gt;Single-agent code generation fails in a characteristic shape: not early, but late. The first hour is excellent; the tenth is not. Understanding why requires naming the individual failure modes precisely, because each one demands a different countermeasure. We catalogued eight. None of them is hypothetical — each burned us at least once, and each is now independently documented in the research literature.&lt;/p&gt;

&lt;h3&gt;
  
  
  P1 — Context rot
&lt;/h3&gt;

&lt;p&gt;An agent working in one long-lived conversation accumulates everything: stale file contents, dead ends, resolved errors, its own verbose narration. Model quality degrades as that window fills. The "lost in the middle" line of research showed multi-document QA accuracy dropping by more than 20% when relevant information sits mid-context — the severity varies by task and model (the Claude-1.3 variants were noticeably flatter), but the U-shaped curve appeared in most models tested (&lt;a href="https://arxiv.org/abs/2307.03172" rel="noopener noreferrer"&gt;Liu et al.&lt;/a&gt;). Chroma's evaluation of 18 models found performance "grows increasingly unreliable as input length grows" even on simple tasks — the report that made context rot the standard name for the phenomenon (&lt;a href="https://www.trychroma.com/research/context-rot" rel="noopener noreferrer"&gt;Chroma&lt;/a&gt;). Are findings from 2023 and mid-2025 still relevant? The naive version — the U-shaped positional curve — has visibly improved with each model generation, and each generation's measurements age with it (Liu et al. measured the GPT-3.5/Claude-1.3 generation; Chroma's evaluation spans the GPT-4.1/Claude-4/Gemini-2.5 era). The pattern worth trusting is that the degradation keeps being re-measured at whatever the frontier currently is: as of May 2026, Claude Opus 4.6, GPT-5.4 Thinking and Gemini 3.1 Pro used as long-transcript classifiers miss dangerous actions 2×–30× more often when those actions sit after 800K tokens of benign context — Opus 4.6 with extended thinking, on the needle-injection task, drops from 99.7% recall at 100K tokens to 69% at 800K (&lt;a href="https://arxiv.org/abs/2605.12366" rel="noopener noreferrer"&gt;Martin &amp;amp; Roger&lt;/a&gt;). The problem moves with the frontier; it does not disappear — and an architecture that bets on the next generation closing it is betting against three years of converging evidence from three research groups measuring three different faces of the same degradation. The practical consequence for agents: the decisions made in hour ten — which are usually the integration decisions, the ones that hurt most when wrong — are made against the noisiest context of the entire run.&lt;/p&gt;

&lt;h3&gt;
  
  
  P2 — Self-assessed success
&lt;/h3&gt;

&lt;p&gt;Agents grade their own homework, and they grade generously. A 2026 study of nearly twelve thousand agent trajectories found false success — the agent claiming completion when the task failed — in 45–48% of failing runs in single-control τ²-bench domains (though only 3% in the dual-control telecom domain), and — on AppWorld, a separate benchmark in the same study — &lt;strong&gt;75.8% of failing runs for coding agents that explicitly self-assess their status&lt;/strong&gt; (&lt;a href="https://arxiv.org/abs/2606.09863" rel="noopener noreferrer"&gt;Advani&lt;/a&gt;). Calibration work found the same shape: some agents that succeed only 22% of the time predict 77% success (&lt;a href="https://arxiv.org/abs/2602.06948" rel="noopener noreferrer"&gt;Kaddour et al.&lt;/a&gt;). Anthropic's harness-design post put it plainly: asked to evaluate their own work, agents "tend to respond by confidently praising the work — even when, to a human observer, the quality is obviously mediocre" (&lt;a href="https://www.anthropic.com/engineering/harness-design-long-running-apps" rel="noopener noreferrer"&gt;Anthropic, harness design&lt;/a&gt;). A status report from an agent is a claim, not a fact.&lt;/p&gt;

&lt;h3&gt;
  
  
  P3 — Prompt-rule decay
&lt;/h3&gt;

&lt;p&gt;The intuitive fix for agent misbehavior is another instruction. It does not scale. Benchmark work on stacked instructions shows the rate at which a model satisfies every rule in its prompt hitting an effective floor of zero by around 80 concurrent rules — across all five models, four formats, and both placements tested, with the steep decline starting near 40 — a redesign point rather than a tuning point (&lt;a href="https://arxiv.org/abs/2607.19257" rel="noopener noreferrer"&gt;Eliav&lt;/a&gt;) — and a second benchmark finds instruction-follow rates falling from ~96% to as low as 20% as constraints accumulate (&lt;a href="https://arxiv.org/abs/2608.02639" rel="noopener noreferrer"&gt;Anand &amp;amp; Chattaraj&lt;/a&gt;). Both test mechanical, programmatically checkable rules; the authors are explicit that the exact thresholds are properties of the models tested, not laws. Worse, prompt rules fail silently: when an instruction erodes under context pressure, no error fires. A rule that matters cannot live only in the prompt.&lt;/p&gt;

&lt;h3&gt;
  
  
  P4 — Silent gate disengagement
&lt;/h3&gt;

&lt;p&gt;The most dangerous entry in this catalog, and the proximate cause of our false-green delivery. A verification step keyed on a field that can be empty, or a capability that can be absent, does not fail — it records "skipped." And a pipeline that treats skipped as acceptable reads it as success. The output looks audited. Software operations has known this failure class for decades — Google's SRE canon prefers alerting on user-visible symptoms over internal causes, because a page should fire only when users are actually affected, and internal indicators alone do not tell you that (&lt;a href="https://sre.google/sre-book/monitoring-distributed-systems/" rel="noopener noreferrer"&gt;Google SRE Book&lt;/a&gt;) — and the data-engineering world rediscovered it in pipeline form: every job completes, the orchestrator shows green, no exception is raised, no alert fires — while the data is quietly incomplete or wrong (&lt;a href="https://seattledataguy.substack.com/p/the-5-silent-failures-in-data-pipelines" rel="noopener noreferrer"&gt;SeattleDataGuy&lt;/a&gt;). Agent pipelines inherit this failure class and add a new twist: the checks themselves are often conditionally constructed by the pipeline, so a wiring gap manufactures skips at scale.&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;stateDiagram-v2
    direction TB
    state "Check scheduled" as scheduled
    state "Key field present?" as keyed
    state "Capability available?" as capable
    state "Check RUNS&amp;lt;br/&amp;gt;PASS or FAIL + evidence" as runs
    state "Check SKIPPED" as skipped
    state "Pipeline reads&amp;lt;br/&amp;gt;'not failed' = OK" as green
    state "FALSE GREEN&amp;lt;br/&amp;gt;work ships unverified" as ship

    scheduled --&amp;gt; keyed
    keyed --&amp;gt; capable : yes
    keyed --&amp;gt; skipped : empty
    capable --&amp;gt; runs : yes
    capable --&amp;gt; skipped : absent
    skipped --&amp;gt; green
    green --&amp;gt; ship
    note right of skipped
        No error fires.
        Nothing distinguishes
        "nothing to check" from
        "check quietly disengaged."
    end note&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;C1 — Anatomy of a false green: two ordinary conditions (an empty field, an absent capability) compose into an unverified ship with no alarm anywhere. (Figures are numbered C1–C11 across the article's three parts.)&lt;/p&gt;

&lt;h3&gt;
  
  
  P5 — Requirements coverage by eyeball
&lt;/h3&gt;

&lt;p&gt;Ask "does the implementation cover every requirement?" of a human process and you get reviews, matrices, sign-offs. Ask it of an agent pipeline and, by default, you get nothing: generated code carries no link to the requirement that motivated it. Researchers on AI-code provenance argue that provenance information — tracing generated code back to the prompt components, training data, and model internals that produced it — is "a practical necessity that current tools do not provide" (&lt;a href="https://arxiv.org/abs/2608.02329" rel="noopener noreferrer"&gt;Velasco et al.&lt;/a&gt;, a research-vision paper), and the gap has measurable consequences: Apiiro's analysis of repositories and developers affiliated with Fortune 50 enterprises (vendor research, Sept 2025) found that developers using AI assistants shipped &lt;strong&gt;322% more privilege-escalation paths and 153% more architectural design flaws&lt;/strong&gt; than their unassisted peers — while syntax errors fell 76% and logic bugs 60%, which is the sharper point: AI improves local correctness while degrading exactly the cross-cutting properties — security posture, architectural constraints — that line-by-line review does not surface (&lt;a href="https://apiiro.com/blog/4x-velocity-10x-vulnerabilities-ai-coding-assistants-are-shipping-more-risks/" rel="noopener noreferrer"&gt;Apiiro&lt;/a&gt;). Coverage tracked by human attention does not survive contact with agent throughput.&lt;/p&gt;

&lt;h3&gt;
  
  
  P6 — Silently partial inputs
&lt;/h3&gt;

&lt;p&gt;Agent pipelines consume artifacts that arrive by hand: design exports, requirement documents, data files. Manual delivery has no transport error. A partial export parses cleanly and yields a plausible result missing a third of its content — the input-side twin of P4. Data engineering calls the general phenomenon data downtime — periods when data is "partial, erroneous, missing or otherwise inaccurate" (&lt;a href="https://montecarlo.ai/blog-the-rise-of-data-downtime" rel="noopener noreferrer"&gt;Monte Carlo&lt;/a&gt;) — and its case literature has the same shape: a manual Excel upload path whose records an incremental pipeline silently skipped, batch after batch, with no exception and every run reporting success (&lt;a href="https://www.phdata.io/blog/preventing-silent-data-loss/" rel="noopener noreferrer"&gt;phData&lt;/a&gt;). In our false-green delivery, the design reference the agents implemented against had silently lost most of its views at ingestion — only 7 of 30 survived. Nothing said so. That partial input was the origin of our false green; P4 — the gates that silently disengaged — is why nothing downstream caught it.&lt;/p&gt;

&lt;h3&gt;
  
  
  P7 — Non-deterministic orchestration
&lt;/h3&gt;

&lt;p&gt;If an LLM writes the code and decides which steps to take, both layers inherit the model's variance. Anthropic's influential taxonomy draws the line between &lt;strong&gt;workflows&lt;/strong&gt; — LLMs orchestrated through predefined code paths — and &lt;strong&gt;agents&lt;/strong&gt;, which direct their own process, and advises workflows for well-defined tasks, reserving agents for when flexibility and model-driven decision-making are needed at scale (&lt;a href="https://www.anthropic.com/engineering/building-effective-agents" rel="noopener noreferrer"&gt;Anthropic, Building Effective Agents&lt;/a&gt;). The variance is not subtle: on the TravelPlanner benchmark, moving operational logic from agent discretion into deterministic blueprints cut commonsense-constraint violations by 96% against the same model on an agentic baseline — 11 versus 275 (&lt;a href="https://arxiv.org/abs/2508.02721" rel="noopener noreferrer"&gt;Qiu et al.&lt;/a&gt;). Left free, an orchestrating LLM under context pressure will quietly optimize away the very steps that exist to catch its mistakes — we watched it happen.&lt;/p&gt;

&lt;h3&gt;
  
  
  P8 — Rigor versus cost
&lt;/h3&gt;

&lt;p&gt;Every countermeasure above costs tokens and wall-clock. Anthropic reports agents consuming ~4× the tokens of chat, and multi-agent systems ~15× (&lt;a href="https://www.anthropic.com/engineering/multi-agent-research-system" rel="noopener noreferrer"&gt;Anthropic, multi-agent research&lt;/a&gt;); their own three-agent harness experiment cost &lt;strong&gt;\$200 and six hours versus \$9 and twenty minutes&lt;/strong&gt; for a solo run of the same task (&lt;a href="https://www.anthropic.com/engineering/harness-design-long-running-apps" rel="noopener noreferrer"&gt;Anthropic, harness design&lt;/a&gt;). The punchline, though, is in the outcomes: the solo run's core feature did not work. Rigor is expensive; unverified failure is more expensive; and a system with no cheap path will be bypassed by its own users. The architecture must let you buy exactly as much rigor as the task warrants.&lt;/p&gt;




&lt;p&gt;These eight compound. Context rot (P1) accelerates prompt-rule decay (P3); decayed rules stop the orchestrator from running checks (P7); the skipped checks read as green (P4); the self-assessment layer confidently confirms it (P2). That cascade is not a tail risk — on long tasks it is the default trajectory. It would still be a manageable one if agent runs stayed short; they are not staying short, and that is the one external fact this argument depends on. METR's longitudinal measurements have the length of task a frontier model completes at 50% reliability doubling roughly every seven months since 2019 — closer to every three in the post-2024 data — with the frontier measurement — Claude Mythos Preview, May 2026 — at sixteen hours, two working days, which is also the ceiling past which METR's current task suite cannot measure reliably (&lt;a href="https://metr.org/blog/2025-03-19-measuring-ai-ability-to-complete-long-tasks/" rel="noopener noreferrer"&gt;METR, 2025&lt;/a&gt;; &lt;a href="https://metr.org/blog/2026-1-29-time-horizon-1-1/" rel="noopener noreferrer"&gt;METR, Time Horizon 1.1&lt;/a&gt;; &lt;a href="https://metr.org/time-horizons/" rel="noopener noreferrer"&gt;METR, live tracker&lt;/a&gt;). Every doubling extends the part of the run where these failure modes concentrate; an architecture that is only safe on short tasks is aging out on that curve.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. A pattern vocabulary
&lt;/h2&gt;

&lt;p&gt;Before architecture, vocabulary. The agent-engineering community has converged on a reasonably stable catalog of design patterns — Antonio Gullí's Agentic Design Patterns is the most complete treatment, cataloguing twenty-one, and Anthropic's workflow taxonomy covers the orchestration subset. Leaders evaluating an agent architecture should be able to ask "which patterns does this compose, and what did you add?" the same way they would ask about GoF patterns in an OO design.&lt;/p&gt;

&lt;p&gt;The reference architecture in this article composes fourteen of the twenty-one catalog patterns (the remainder — tool use, inter-agent communication, learning and adaptation, and the like — are either assumed or deliberately excluded, as Part III explains for inter-agent communication):&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Catalog pattern&lt;/th&gt;
&lt;th&gt;Where it appears in this architecture&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Prompt Chaining&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The pipeline itself: plan → design → scope → implement → evaluate, each phase consuming the previous phase's artifact&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Planning&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Dedicated planning and solution-design phases producing reviewable artifacts before code exists&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Routing&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Model strength routed per work unit by declared complexity; strongest models only where judgment compounds&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Parallelization&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Independent work units dispatched concurrently — but only when independence is proven, not assumed; the schedule itself is printed by code, never re-derived by the model&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Reflection&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Evaluator feedback driving bounded regeneration — with the crucial amendment below&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Multi-Agent Collaboration&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Specialist roles (planner, architect, scoper, implementer, evaluator, summarizer) instead of one generalist&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Memory Management&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Tiered knowledge with engineered briefs; inter-phase compression as a deliberate artifact&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Knowledge Retrieval (RAG)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;On-demand knowledge queries available to every role, with per-role budgets&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Goal Setting and Monitoring&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Machine-readable requirements claimed by work units; coverage computed, not eyeballed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Exception Handling and Recovery&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Escalation as a first-class state: bounded retries, then a structured human decision&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Human-in-the-Loop&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Approval gates at the spec, design, and plan — where change is cheap&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Resource-Aware Optimization&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;A lightweight single-iteration path for small tasks; full pipeline for feature-sized ones&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Guardrails/Safety Patterns&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Deterministic validators on every phase transition&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Evaluation and Monitoring&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Evaluation as a separate adversarial role, required to attach evidence&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Two amendments to the catalog matter enormously in practice:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reflection must be adversarial, not introspective.&lt;/strong&gt; The catalog's Reflection pattern — the model critiques and improves its own output — runs straight into P2. Self-critique is the least reliable form of evaluation: the false-success studies above measured it, and Anthropic's harness work reached the same conclusion, splitting generation and evaluation into separate, GAN-inspired agents after finding that tuning a standalone evaluator to be skeptical is far more tractable than making a generator critical of its own work. Reflection works when the reflector is a different context with different incentives and — critically — access to evidence rather than to the generator's narrative.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The catalog has no discipline layer.&lt;/strong&gt; Nothing in the twenty-one patterns says how the pipeline knows a pattern actually executed. That gap is precisely where P2, P3, P4, and P7 live. The architecture below adds three mechanisms that we believe belong in the catalog as first-class patterns. The &lt;strong&gt;deterministic control boundary&lt;/strong&gt;: workflow control lives in code — models act inside states, and no model, however convinced it is that a step is redundant, can move the pipeline between them. The &lt;strong&gt;evidence model&lt;/strong&gt;: no claim moves the pipeline without an on-disk artifact a deterministic verifier can inspect, and small structured outputs are schema-validated at the boundary before they are ever allowed to become files. And &lt;strong&gt;earned capabilities&lt;/strong&gt;: a capability flag — this source can produce reference renders, this check can run — is true only when the artifacts backing it actually exist, earned from what was delivered rather than declared from hope; a check that cannot run records SKIPPED, never PASS, and where a reference exists, SKIPPED itself is a violation. Part II treats each in detail, and its appendix writes all three in catalog form — name, intent, problem, forces, mechanism, consequences — so they can be evaluated, and argued with, as patterns.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. The architecture, high level
&lt;/h2&gt;

&lt;h3&gt;
  
  
  3.1 The control loop
&lt;/h3&gt;

&lt;p&gt;Everything in the architecture is an elaboration of one loop, and one boundary drawn through it:&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart TB
    subgraph CODE["Owned by deterministic code"]
        direction TB
        V{"Verify:&amp;lt;br/&amp;gt;evidence on disk?"}
        G8["Gate: advance /&amp;lt;br/&amp;gt;retry / escalate"]
        L["Ledger: record&amp;lt;br/&amp;gt;verdict + evidence"]
    end
    subgraph LLM["Owned by LLM agents"]
        direction TB
        GEN["Generate&amp;lt;br/&amp;gt;(fresh context, engineered brief)"]
        EV["Evaluate&amp;lt;br/&amp;gt;(adversarial, separate agent)"]
    end
    H["Human decision&amp;lt;br/&amp;gt;(bounded options)"]

    GEN --&amp;gt; EV
    EV --&amp;gt;|"claims + artifacts"| V
    V --&amp;gt;|"evidence complete"| G8
    V --&amp;gt;|"evidence missing"| GEN
    G8 --&amp;gt;|advance| GEN
    G8 --&amp;gt;|"retry (bounded)"| GEN
    G8 --&amp;gt;|"retries exhausted"| H
    H --&amp;gt;|"skip / redirect / stop"| G8
    V --&amp;gt; L
    H --&amp;gt; L
    L -.-&amp;gt;|"crash resume:&amp;lt;br/&amp;gt;position rebuilt from record"| G8
    L -.-&amp;gt; R["Read later:&amp;lt;br/&amp;gt;final re-verification,&amp;lt;br/&amp;gt;coverage rollup, audit"]&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;C2 — The control loop. Models generate and evaluate; code decides. No agent — including the orchestrating one — can move the pipeline forward. Only the verifier can, and it accepts evidence, not claims.&lt;/p&gt;

&lt;p&gt;The boundary is the load-bearing decision. Everything an LLM produces — code, test results, evaluations, status reports — is treated as a claim. Claims cross into the code-owned region only accompanied by artifacts a deterministic verifier can inspect: logs with exit codes, screenshots with encoded parameters, per-criterion evidence strings. The orchestrator that dispatches agents is itself an LLM, and it is also untrusted: phase transitions happen through a code-validated step — the gate in C2, which advances, retries, or escalates on the verifier's verdict — or not at all, which is the direct answer to P7. When the verifier finds a violation, the result is not a warning — it is a blocked transition with a structured description of what is missing, injected into the next dispatch.&lt;/p&gt;

&lt;p&gt;This does not make the orchestrator decision-free. It still chooses what feedback to inject into a re-dispatch, whether a retry remains, which claims to spot-check, whether a handoff warrants an interpretive pass. But every decision it makes is reversible inside the retry budget — the worst case is one wasted dispatch. The irreversible decisions — waive a criterion, degrade a check, skip a unit, stop the run — are never the orchestrator's; they belong to a human, and they land in the ledger as waivers.&lt;/p&gt;

&lt;p&gt;The third code-owned component in C2, the ledger, is easy to overlook because it makes no decisions. It is the append-only record of what happened: every verdict with its evidence, every human choice with its rationale. Its consumers come later — a crashed run resumes from the ledger rather than from any model's memory, the end-of-run hook re-verifies completed work against it, and the final coverage report is computed from it. In a system where every model output is a claim, the ledger is the one component allowed to be trusted without verification, because nothing is asked of it except to remember.&lt;/p&gt;

&lt;p&gt;This is Anthropic's workflows-over-agents recommendation taken to its conclusion: the workflow is not merely predefined, it is enforced, because a predefined path that the orchestrating model can skip under context pressure is a suggestion, not a workflow.&lt;/p&gt;

&lt;h3&gt;
  
  
  3.2 The pipeline
&lt;/h3&gt;

&lt;p&gt;The loop runs inside a phase pipeline whose shape answers a different question: where is human judgment cheapest?&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart TB
    A["Validate config&amp;lt;br/&amp;gt;+ environment"] --&amp;gt; B["Extract sources&amp;lt;br/&amp;gt;(designs, docs, URLs)&amp;lt;br/&amp;gt;+ completeness cross-checks"]
    B --&amp;gt; C["Plan: product spec +&amp;lt;br/&amp;gt;machine-readable requirements"]
    C --&amp;gt; G1{{"HUMAN GATE:&amp;lt;br/&amp;gt;approve spec"}}
    G1 --&amp;gt; D["Solution design:&amp;lt;br/&amp;gt;entity map, reuse-vs-new,&amp;lt;br/&amp;gt;grounded against the codebase"]
    D --&amp;gt; G2{{"HUMAN GATE:&amp;lt;br/&amp;gt;approve design"}}
    G2 --&amp;gt; E["Scope: ordered work units,&amp;lt;br/&amp;gt;acceptance criteria per unit&amp;lt;br/&amp;gt;+ COVERAGE GATE:&amp;lt;br/&amp;gt;every requirement claimed"]
    E --&amp;gt; G3{{"HUMAN GATE:&amp;lt;br/&amp;gt;approve plan + coverage"}}
    G3 --&amp;gt; F["Iterative build loop&amp;lt;br/&amp;gt;(per work unit:&amp;lt;br/&amp;gt;generate → evaluate → verify)"]
    F --&amp;gt; G4{{"HUMAN GATE:&amp;lt;br/&amp;gt;merge / PR / leave"}}

    style G1 fill:#f4d03f22,stroke:#b7950b
    style G2 fill:#f4d03f22,stroke:#b7950b
    style G3 fill:#f4d03f22,stroke:#b7950b
    style G4 fill:#f4d03f22,stroke:#b7950b&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;C3 — The phase pipeline. Human gates (highlighted) sit before code exists — at the spec, the design, and the plan — where a correction costs minutes. The only post-code gate is the final disposition.&lt;/p&gt;

&lt;p&gt;Three properties of this shape deserve a leader's attention:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Judgment is front-loaded.&lt;/strong&gt; Reviewing a spec, a solution design, and a work breakdown takes a human minutes each, and a correction at any of these gates costs almost nothing — the artifact is text. Reviewing a finished thousand-line diff is slower, less reliable, and corrections cost a rebuild. The gates are placed where the ratio of insight-per-minute to cost-of-change is best. This is the Human-in-the-Loop pattern, but positioned: HITL after code is review theater; HITL before code is control.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Every phase emits an artifact, and the next phase consumes only artifacts.&lt;/strong&gt; The spec, the requirements list, the solution design, the work-unit contracts — each is a file with a defined shape, validated on write. Agents never hand each other conversation; they hand each other documents. This is what makes fresh-context dispatch (the answer to P1) possible, and it is what makes the pipeline resumable after a crash: state lives on disk, not in anyone's context window.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Coverage is computed at the gate.&lt;/strong&gt; The planning phase emits requirements with stable identifiers; every work unit must claim the identifiers it implements; a deterministic gate fails the breakdown if any requirement is unclaimed — before the human sees it. The human approves a coverage table, not a vibe (P5's answer, detailed in Part II).&lt;/p&gt;

&lt;h3&gt;
  
  
  3.3 The roles
&lt;/h3&gt;

&lt;p&gt;Inside the build loop, work is divided among specialist roles — the Multi-Agent Collaboration pattern, but motivated by context hygiene as much as by skill separation. Each dispatch starts a fresh context containing an engineered brief: the work-unit contract, the relevant slice of the solution design, the relevant knowledge — and nothing else. Between iterations, a handoff artifact carries what the next unit needs to know — and here the code-over-model rule earned its keep a second time: most of that handoff turned out to be derivable (what completed, which files to carry forward, which criteria were skipped), so a script now computes it from the ledger, and a summarizing model pass runs only when the unit's outcome actually warrants interpretation. The long-lived orchestrator never accumulates content at all, only paths and states.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Role&lt;/th&gt;
&lt;th&gt;Mandate&lt;/th&gt;
&lt;th&gt;Why it is separate&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Planner&lt;/td&gt;
&lt;td&gt;Expand intent into spec + requirements&lt;/td&gt;
&lt;td&gt;Product thinking pollutes implementation contexts&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Solution architect&lt;/td&gt;
&lt;td&gt;Map the spec onto the existing codebase&lt;/td&gt;
&lt;td&gt;Reuse-vs-new decisions need whole-system view, once&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Scoper&lt;/td&gt;
&lt;td&gt;Break design into contracted work units&lt;/td&gt;
&lt;td&gt;The contract is the interface to implementation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Implementer&lt;/td&gt;
&lt;td&gt;One work unit, fresh context&lt;/td&gt;
&lt;td&gt;P1: the tenth unit deserves as clean a window as the first&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Evaluator&lt;/td&gt;
&lt;td&gt;Adversarial verification with evidence&lt;/td&gt;
&lt;td&gt;P2: never the implementer; graded on finding problems&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Summarizer&lt;/td&gt;
&lt;td&gt;Add interpretation to a computed handoff&lt;/td&gt;
&lt;td&gt;The derivable facts are scripted from the ledger; a model dispatch is bought only when deviation signals warrant judgment&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The evaluator deserves the last word of Part I, because it is where most of the reliability actually comes from. It runs a fail-fast ladder — build, lint, tests, security scan, design fidelity, browser-level behavior, then the unit's acceptance criteria — and it is required to attach evidence to every verdict it emits. Not because the evaluator model is special: because the verifier behind it refuses any PASS that arrives without artifacts. The evaluator can be lazy, sycophantic, or wrong; the claims it makes still do not move the pipeline unless the evidence exists on disk.&lt;/p&gt;




&lt;p&gt;Continue to &lt;a href="https://dev.to/sashua/engineering-reliability-into-ai-agent-code-generation-part-ii-1d0d"&gt;Part II&lt;/a&gt;: the components in detail — deterministic guards, the evidence model, context engineering, adversarial evaluation, the connector contract, traceability, and escalation — with the three proposed patterns in catalog form. &lt;a href="https://dev.to/sashua/engineering-reliability-into-ai-agent-code-generation-part-iii-jdg"&gt;Part III&lt;/a&gt; completes the series: the team-of-agents layer (coordination that is never requested), the false-green case study, what is still unsolved, and an adoption ladder.&lt;/p&gt;




&lt;p&gt;This article on &lt;a href="https://github.com/sash-ua/ai-agent-code-generation-article" rel="noopener noreferrer"&gt;github&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I’m Oleksandr Tranchenko, an AI engineer and team lead. I spend most of my thinking on an under-discussed question: how do you get reliable software out of a probabilistic system? My answer so far is boring on purpose — deterministic processes wrapped around the model, mandatory verification, and treating the LLM as something you steer rather than something you trust. Find me on &lt;a href="https://www.linkedin.com/in/oleksandr-tranchenko-ai/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Liu, N. F., Lin, K., Hewitt, J., Paranjape, A., Bevilacqua, M., Petroni, F., &amp;amp; Liang, P., Lost in the Middle: How Language Models Use Long Contexts (v3, Nov 2023) — &lt;a href="https://arxiv.org/abs/2307.03172" rel="noopener noreferrer"&gt;arxiv.org/abs/2307.03172&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Hong, K., Troynikov, A., &amp;amp; Huber, J. (Chroma), Context Rot: How Increasing Input Tokens Impacts LLM Performance (14 Jul 2025) — &lt;a href="https://trychroma.com/research/context-rot" rel="noopener noreferrer"&gt;trychroma.com/research/context-rot&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Advani, L., From Confident Closing to Silent Failure: Characterizing False Success in LLM Agents (1 Jun 2026) — &lt;a href="https://arxiv.org/abs/2606.09863" rel="noopener noreferrer"&gt;arxiv.org/abs/2606.09863&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Kaddour, J., Patel, S., Dovonon, G., Richter, L., Minervini, P., &amp;amp; Kusner, M. J., Agentic Uncertainty Reveals Agentic Overconfidence (6 Feb 2026) — &lt;a href="https://arxiv.org/abs/2602.06948" rel="noopener noreferrer"&gt;arxiv.org/abs/2602.06948&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Rajasekaran, P. (Anthropic), Harness design for long-running application development (24 Mar 2026) — &lt;a href="https://anthropic.com/engineering/harness-design-long-running-apps" rel="noopener noreferrer"&gt;anthropic.com/engineering/harness-design-long-running-apps&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Eliav, N., Prompt Design at Scale: How Format, Instruction Count, and Context Length Shape Instruction Adherence and Hallucination in Large Language Models (21 Jul 2026; released with the VeyraBench harness) — &lt;a href="https://arxiv.org/abs/2607.19257" rel="noopener noreferrer"&gt;arxiv.org/abs/2607.19257&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Anand, A., &amp;amp; Chattaraj, S., Instruction Stacking Collapse: A Benchmark and the Capability-Dependent Value of Prompt Compilation (31 Jul 2026) — &lt;a href="https://arxiv.org/abs/2608.02639" rel="noopener noreferrer"&gt;arxiv.org/abs/2608.02639&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Ewaschuk, R. (ed. Beyer, B.), Monitoring Distributed Systems, ch. 6 of Site Reliability Engineering: How Google Runs Production Systems (O'Reilly, 2016) — &lt;a href="https://sre.google/sre-book/monitoring-distributed-systems" rel="noopener noreferrer"&gt;sre.google/sre-book/monitoring-distributed-systems&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;SeattleDataGuy, The 5 Silent Failures in Data Pipelines (24 Apr 2026) — &lt;a href="https://seattledataguy.substack.com/p/the-5-silent-failures-in-data-pipelines" rel="noopener noreferrer"&gt;seattledataguy.substack.com/p/the-5-silent-failures-in-data-pipelines&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Velasco, A., Wintersgill, N., Stalnaker, T., Chaparro, O., &amp;amp; Poshyvanyk, D., On Automated and Explainable Provenance of AI-Generated Code (3 Aug 2026) — &lt;a href="https://arxiv.org/abs/2608.02329" rel="noopener noreferrer"&gt;arxiv.org/abs/2608.02329&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Nussbaum, I. (Apiiro), 4x Velocity, 10x Vulnerabilities: AI Coding Assistants Are Shipping More Risks (4 Sept 2025) — &lt;a href="https://apiiro.com/blog/4x-velocity-10x-vulnerabilities-ai-coding-assistants-are-shipping-more-risks" rel="noopener noreferrer"&gt;apiiro.com/blog/4x-velocity-10x-vulnerabilities-ai-coding-assistants-are-shipping-more-risks&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Moses, B. (Monte Carlo), What is Data Downtime? (4 Feb 2024; originally published as The Rise of Data Downtime) — &lt;a href="https://montecarlo.ai/blog-the-rise-of-data-downtime" rel="noopener noreferrer"&gt;montecarlo.ai/blog-the-rise-of-data-downtime&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Chen, E. (phData), Trials and Tribulations Preventing Silent Data Loss (15 Oct 2020) — &lt;a href="https://phdata.io/blog/preventing-silent-data-loss" rel="noopener noreferrer"&gt;phdata.io/blog/preventing-silent-data-loss&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Schluntz, E., &amp;amp; Zhang, B. (Anthropic), Building effective agents (19 Dec 2024) — &lt;a href="https://anthropic.com/engineering/building-effective-agents" rel="noopener noreferrer"&gt;anthropic.com/engineering/building-effective-agents&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Qiu, L., Ye, Y., Gao, Z., Zou, X., Chen, J., Gui, Z., Huang, W., Xue, X., Qiu, W., &amp;amp; Zhao, K., Blueprint First, Model Second: A Framework for Deterministic LLM Workflow (v2, 16 Jun 2026; the TravelPlanner result) — &lt;a href="https://arxiv.org/abs/2508.02721" rel="noopener noreferrer"&gt;arxiv.org/abs/2508.02721&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Hadfield, J., Zhang, B., Lien, K., Scholz, F., Fox, J., &amp;amp; Ford, D. (Anthropic), How we built our multi-agent research system (13 Jun 2025) — &lt;a href="https://anthropic.com/engineering/multi-agent-research-system" rel="noopener noreferrer"&gt;anthropic.com/engineering/multi-agent-research-system&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;METR, Measuring AI Ability to Complete Long Software Tasks (19 Mar 2025) — &lt;a href="https://metr.org/blog/2025-03-19-measuring-ai-ability-to-complete-long-tasks" rel="noopener noreferrer"&gt;metr.org/blog/2025-03-19-measuring-ai-ability-to-complete-long-tasks&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;METR, Time Horizon 1.1 (29 Jan 2026) — &lt;a href="https://metr.org/blog/2026-1-29-time-horizon-1-1" rel="noopener noreferrer"&gt;metr.org/blog/2026-1-29-time-horizon-1-1&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;METR, Task-Completion Time Horizons of Frontier AI Models (live tracker; last updated 8 May 2026, accessed 22 Aug 2026) — &lt;a href="https://metr.org/time-horizons" rel="noopener noreferrer"&gt;metr.org/time-horizons&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Gullí, A., Agentic Design Patterns: A Hands-On Guide to Building Intelligent Systems (Springer Cham, 2025) — &lt;a href="https://doi.org/10.1007/978-3-032-01402-3" rel="noopener noreferrer"&gt;doi.org/10.1007/978-3-032-01402-3&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Martin, S., &amp;amp; Roger, F. (Anthropic), Classifier Context Rot: Monitor Performance Degrades with Context Length (12 May 2026) — &lt;a href="https://arxiv.org/abs/2605.12366" rel="noopener noreferrer"&gt;arxiv.org/abs/2605.12366&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>softwareengineering</category>
      <category>aisoftwarearchitecture</category>
      <category>agenticai</category>
      <category>aicodegeneration</category>
    </item>
  </channel>
</rss>
