Ai4
Engineering teams must restrict LLMs to targeted semantic validation because unconstrained coding agents trigger costly context loops and production outages that deterministic tools prevent.
AI-assisted summary of Friends Don't Let AI Code in the Dark: Fixing the Token Burning Chaos of Agentic UI — original source. Check the original for full context.
Source published:
Detailed notes
## Background Published on YouTube by Ai4 on August 18, 2026, this technical presentation features Dylan Barrell, Chief Technology Officer at Deque Systems. The session addresses the token-burning chaos and unpredictable accessibility defects introduced when autonomous coding agents generate UI, proposing an advanced hybrid testing architecture that combines deterministic tools with targeted multimodal LLM validation.
## TL;DR Dylan Barrell examines the practical realities of autonomous software engineering, exposing failure modes such as architectural rot, endless review churn, and stubborn model polling loops. He establishes three fundamental design principles: never use an LLM for deterministic tasks, decompose hybrid problems, and treat generative AI strictly as a last resort. Applying this philosophy to UI accessibility, Barrell details Deque's hybrid pipeline—combining DOM inspection, visual object detection, surgical LLM semantic queries, and deterministic heuristics—which reduces false positives to near zero and drastically cuts remediation time.
## Atmosphere & style The presentation carries a candid, battle-tested, and deeply pragmatic engineering tone that cuts through generative AI hype with sobering war stories like self-inflicted DDoS outages. Barrell speaks with the authority of an experienced CTO who has spent months stress-testing frontier models against massive codebases, blending wry observations about model pathologies with disciplined architectural solutions. It feels like an insider masterclass for developers, evolving from the frustrating chaos of unconstrained agent loops into the reassuring clarity of deterministic systems design.
## Key takeaways - [00:04](https://www.youtube.com/watch?v=pBSEfsJLaMQ&t=4s) Achieving an agentic software economy requires autonomous AI agents capable of producing software that matches or exceeds human engineering quality. - [01:19](https://www.youtube.com/watch?v=pBSEfsJLaMQ&t=79s) Early agentic workflows suffer from circular edits, context leaks, and brittle tests, which must be solved using atomic design, modular interfaces, and strict red-green-refactor TDD. - [04:32](https://www.youtube.com/watch?v=pBSEfsJLaMQ&t=272s) When agents exceed 200,000 to 300,000 tokens of context, they enter a degraded state where they promise compliance verbally while continuing to execute failing behaviors like repetitive polling. - [06:52](https://www.youtube.com/watch?v=pBSEfsJLaMQ&t=412s) Validation and review dominate enterprise agent workflows, consuming roughly two-thirds (~66.7%) of total token budgets compared to only ~16% for writing implementation code. - [06:52](https://www.youtube.com/watch?v=pBSEfsJLaMQ&t=412s) Executing the same review prompt multiple times on identical code with fresh context yields non-deterministic defect discovery that catches critical edge cases missed in previous cycles. - [10:08](https://www.youtube.com/watch?v=pBSEfsJLaMQ&t=608s) An AI-reviewed change caused an internal DDoS outage after missing an uncached error path, proving that prompt engineering cannot substitute for deterministic rules and monitors. - [10:08](https://www.youtube.com/watch?v=pBSEfsJLaMQ&t=608s) Robust AI systems adhere to three core principles: never use an LLM if a task can be done deterministically, break hybrid problems down, and deploy AI strictly as a last resort. - [13:51](https://www.youtube.com/watch?v=pBSEfsJLaMQ&t=831s) Static accessibility linters like axe-core only catch 50% to 57% of defects, but feeding full screenshots to raw LLMs is too expensive and inconsistent for production testing. - [17:36](https://www.youtube.com/watch?v=pBSEfsJLaMQ&t=1056s) A hybrid testing harness reconciles live DOM semantic roles with visual object detection to capture unsemantic styled controls without passing full pages into prompts. - [18:53](https://www.youtube.com/watch?v=pBSEfsJLaMQ&t=1133s) Constraining multimodal LLMs to single, isolated elements delivers surgical semantic verification, transparent reasoning justifications, and a minimal failure blast radius. - [20:39](https://www.youtube.com/watch?v=pBSEfsJLaMQ&t=1239s) Unlike pure LLM audit approaches with erratic costs and high noise, hybrid deterministic pipelines achieve predictable flat costs and false positive rates that round down to zero. - [21:34](https://www.youtube.com/watch?v=pBSEfsJLaMQ&t=1294s) Combining deterministic diagnostics with RAG-retrieved remediation patterns compressed 257 engineering hours of accessibility fixes into 4 hours, fully automating 70% of repairs.
## Detailed walkthrough ### [00:04](https://www.youtube.com/watch?v=pBSEfsJLaMQ&t=4s) The Goal: Building Autonomous Agentic Software Development
Opening the presentation at AI4, Dylan Barrell asks the audience how many are attending for the first time, noting that the crowd has doubled since the previous year. He introduces his core ambition: exploring how to build code completely with autonomous AI agents so that the resulting software is "as good or better even better than what humans build." This level of quality is a vital stepping stone toward realizing an agentic economy.
Over the past four months, Barrell engaged in hands-on experimentation to push the boundaries of AI agents, uncover their current limitations, and figure out practical techniques to make fully agentic workflows work.
[01:19](https://www.youtube.com/watch?v=pBSEfsJLaMQ&t=79s) Early Growing Pains: Atomic Design, Context Leaks, and Bad Architecture
In his initial attempts to build fully agentic systems, Barrell ran into a sequence of recurring software engineering and agent execution challenges:
1. **Pixel-Perfect UI:** Models initially struggled with visual precision and integrating with tools like Figma. Barrell solved this by applying atomic design principles, structuring the UI into discrete atoms and components accompanied by targeted agent skills. 2. **Token Burning & Context Management:** Naive implementations pass massive context indiscriminately across agent turns without accounting for prompt caching, causing rapid token burn. Proper token budgeting, context pruning, and caching strategies mitigate this. 3. **Architectural Rot & Circular Edits:** When tasked with modifying established codebases, agents often get stuck in endless loops. This is a telltale "code smell" showing the agent has written unstructured, fragile code that it can no longer understand. Teaching the agent deep modularity, clean interfaces, and introducing architecture-focused review agents resolved this. 4. **Implementation Coupling in Tests:** Making a minor change to a module often triggered massive refactors that broke entire test suites. The issue was that the agents were writing tests tied directly to internal implementation details rather than verifying functional outcomes. Introducing strict Test-Driven Development (TDD) via "red-green-refactor" workflows fixed this pattern. 5. **Endless Review Churn:** Introducing multiple automated reviewer agents led to endless loops—10 to 14 review cycles between implementation and review agents without convergence. This happens when ambiguities or drift creep in between specifications, tickets, and plans. Eliminating cross-artifact inconsistencies and barring agents from generating verbose code comments stops the churn.
[04:32](https://www.youtube.com/watch?v=pBSEfsJLaMQ&t=272s) Model Pathology: Assumptions, Hallucinations, and Polling Loops
Beyond workflow issues, foundational model behaviors present real risks. As models become more intelligent, they exhibit a dangerous tendency to make assumptions—such as assuming a failing test was pre-existing and "not my fault," choosing to ignore it entirely. To counter this, Barrell enforces an explicit rule: never assume and never report anything as fact without verifiable execution.
However, verbal rules alone cannot be trusted. Barrell recounts testing Claude 3.7 Sonnet (Opus/Sonnet 4.7 era), which exhibited a persistent habit of actively polling background tasks rather than waiting for event monitors to fire.
```mermaid flowchart TD accTitle: Agent Polling Failure Loop accDescription: Flowchart illustrating the agent repeatedly polling background tasks despite explicit instructions not to.
subgraph DumbZone["High Token Context (>200k-300k tokens)"] A["Agent Polling Loop Active"] --> B["Human: 'Stop polling, wait for monitor.'"] B --> C["Agent: 'Understood, I will stop polling.'"] C --> D["Agent immediately issues 2 polling requests"] D --> E["Human repeats instruction"] E --> F["Agent promises again, then polls immediately"] end ```
When an agent enters the "dumb zone" past 200,000–300,000 tokens of context, every back-and-forth turn burns substantial cost. Despite repeatedly telling the agent "don't poll... just wait for the monitor to fire," the agent would acknowledge the prompt ("Okay, yep. I'll stop polling") and immediately execute two more polling requests. This behavior highlighted a fundamental rule: agents cannot be trusted on their word alone; every step must be deterministically verified.
[06:52](https://www.youtube.com/watch?v=pBSEfsJLaMQ&t=412s) The Deque Agentic Development Workflow and Token Economics
To overcome these constraints, Deque developed an end-to-end development pipeline that balances autonomous agent phases with structured human checkpoints:
```mermaid flowchart LR accTitle: Deque Agentic Development Lifecycle accDescription: Lifecycle flowchart showing ticket creation, plan review, autonomous implementation, and multi-model review.
subgraph Stage1["1. Specification"] A["Interview Agent Creates Ticket"] --> B["Ticket Grooming on Pickup"] end
subgraph Stage2["2. Planning (AFK)"] B --> C["Agent & Reviewers Draft Plan"] C --> D["Human Polishes Plan"] end
subgraph Stage3["3. Implementation (AFK)"] D --> E["Autonomous Coding & Red Tests"] E --> F["Human Interrogation Prompts"] end
subgraph Stage4["4. Polish & Review"] F --> G["GitHub Copilot & Claude Review Loops"] G --> H["Clean Merged Code"] end ```
- **Interactive Ticket Creation:** Using an interview model to generate tickets with strict guidelines, focusing entirely on measurable outcomes rather than prescribing low-level implementations. - **Ticket Re-Grooming:** Re-verifying ticket relevance against incoming changes before starting work. - **Away-From-Keyboard (AFK) Planning:** Agents and plan-review agents draft technical plans autonomously before the human reviews and polishes them. - **AFK Implementation:** Agents write failing red tests first (TDD) followed by implementation code and self-reviews. - **Human Interrogation & Model Reviews:** The engineer runs targeted prompts to interrogate the solution, followed by multi-model reviews across GitHub Copilot and Anthropic Claude until zero issues remain.
This workflow maintains massive enterprise codebases with over 250,000 lines of code spanning multiple databases and services. However, token consumption is heavily skewed toward validation:
| Development Stage | Token Allocation Percentage | |:--- |:--- | | **Reviewing & Bug Fixing** | ~66.7% (Two-thirds) | | **Writing Implementation Code** | ~16.0% | | **Writing Red Tests (TDD)** | ~12.0% | | **Planning & Architecture** | ~6.0% |
Running the exact same Copilot or Claude review prompt five or six times on identical code with fresh context yields non-deterministic, overlapping sets of defects—frequently uncovering critical edge cases that prior cycles missed entirely.
[10:08](https://www.youtube.com/watch?v=pBSEfsJLaMQ&t=608s) The Self-Inflicted DDoS Outage and the Three Principles of AI Systems
Barrell describes an incident where a major code change—written by AI, reviewed by AI, and approved by senior engineers—caused a production outage by effectively launching an internal Distributed Denial of Service (DDoS) attack against themselves.
```mermaid flowchart TD accTitle: Production DDoS Incident Root Cause accDescription: Flow showing how unprivileged getFeature calls generated non-cached failures and swamped servers.
A["New Unprivileged Context Added"] --> B["Calls getFeature()"] B --> C["getFeature() Fails Consistently"] C --> D["Only Successful Responses Cached"] D --> E["Storm of Rapid Uncached HTTP Requests"] E --> F["No Heavy Server CPU Load Generated"] F --> G["Autoscaling Fails to Trigger Outage Occurs"] ```
Barrell spent four hours trying to get AI code review agents to spot the issue by refining instructions, specifically requiring security agents to "follow every single call all the way to the sink." The model repeatedly skipped tracing an unprivileged `getFeature()` call. When asked directly why it missed the bug, the LLM generated long retrospective reasoning explaining why it should have caught it, praised Barrell for finding it, and then provided recommendations to prevent future occurrences.
Critically, the AI's top recommendations were not prompt adjustments or more LLM reviews, but **deterministic controls**: custom ESLint rules and production DataDog metrics.
This led to three foundational principles for building robust agent systems: 1. **Never use an LLM if you can do it deterministically:** Deterministic tools are drastically cheaper, faster, and 100% precise. 2. **Break hybrid problems down:** Separate tasks into deterministic subsets and AI-dependent subsets. 3. **Use AI strictly as a last resort:** Deploy LLM reasoning only where semantic understanding cannot be achieved with rule-based scripts.
[13:51](https://www.youtube.com/watch?v=pBSEfsJLaMQ&t=831s) Deterministic Tooling Combined with Multimodal AI for Accessibility
Applying this hybrid strategy transforms UI and accessibility engineering. By combining deterministic generators (e.g., custom scripts bootstrapping atomic components and matching test templates) with deterministic lint checks (custom ESLint rules enforcing structure), agent drift is eliminated.
For accessibility, traditional deterministic engines like `axe-core` automatically catch roughly 50% to 57% of defects. The remaining issues traditionally required manual human testing—an approach that fails in automated agent workflows. While raw LLMs offer semantic vision capabilities, throwing raw screenshots at an LLM is both token-prohibitive and inconsistent.
```mermaid flowchart TD accTitle: Hybrid Deterministic and Multimodal AI Accessibility Pipeline accDescription: Pipeline diagram showing deterministic DOM filtering followed by targeted AI vision and heuristic evaluation.
A["Rendered UI / Live DOM"] --> B["1. Deterministic Scope Inspection (Interactive Nodes Only)"] B --> C["2. Multimodal Data Extraction (DOM Snippets + Cropped Screenshots)"] C --> D["3. Targeted LLM Vision / Semantic Analysis"] D --> E["4. Deterministic Heuristic Engine (Applies WCAG Pass/Fail Rules)"] ```
To solve this, Deque built an accessibility testing harness combining deterministic rules with targeted multimodal AI: - **Heuristic Scope Inspection:** Deterministically scans the live DOM and filters down to only the interactive elements that require Name, Role, Value verification, skipping non-relevant elements. - **Multimodal Extraction:** Captures focused screenshots and DOM subsets specifically tied to those targets. - **Targeted AI Vision Querying:** The LLM evaluates semantic visual parity (e.g., ensuring a button visually labeled "Search" conveys the exact same semantic label and role to assistive screen readers across every interaction modality). - **Heuristic Evaluation:** A deterministic rule engine evaluates the LLM's structured semantic responses to issue definitive pass/fail decisions.
[17:36](https://www.youtube.com/watch?v=pBSEfsJLaMQ&t=1056s) Building the Hybrid Accessibility Testing Harness
To prevent testing agents from wandering or burning tokens needlessly, the process starts by building an exact inventory of interactive elements. The system first inspects the application's DOM to identify everything announcing itself as interactive, such as elements assigned an explicit `role="button"` or standard HTML `<button>` tags. However, because one of the most widespread UI failure modes is wrapping an unsemantic `<div>` in styling to look like a button without semantic markup, static inspection is insufficient on its own. The architecture simultaneously captures screenshots and runs visual object detection across the rendered page to locate everything that visually looks interactive.
These two independent element lists—semantic DOM nodes and visually identified controls—are merged and resolved into a single, definitive testing scope. Rather than dumping an entire page or massive guidelines into a generic prompt, the harness extracts the precise semantic data for each specific element and feeds a tightly scoped context to the large language model. By asking the model surgical, narrowly defined questions without extra prompt overhead, the system achieves exceptionally high precision and low error rates before merging the results back with deterministic heuristics.
```mermaid flowchart TD accTitle: Hybrid Accessibility Testing Scoping Flow subgraph Discovery["1. Multi-Modal Discovery"] A["DOM Query<br>(Roles & HTML Elements)"] B["Visual Object Detection<br>(Screenshots)"] end subgraph Resolution["2. Target Resolution"] C["Reconcile & Merge Elements"] D["Scoped Element Context"] end subgraph Validation["3. Precision Analysis"] E["Targeted LLM Query<br>(Semantic Validation)"] F["Deterministic Heuristics Engine"] G["Final Audit Result"] end
A --> C B --> C C --> D D --> E E --> F F --> G ```
[18:53](https://www.youtube.com/watch?v=pBSEfsJLaMQ&t=1133s) Architectural Guarantees: Scoped Context, Semantic Matching, and Explainability
This structured harness provides a reliable foundation with guaranteed coverage. Because the agent is given an explicit, isolated element alongside its direct context rather than being expected to navigate an entire WCAG checklist across an open-ended interface, it cannot lose track of execution paths or skip essential verification routines. Even if the visual AI fails to detect an object during a specific pass, the dual semantic analysis acts as a safety net, keeping the overall "blast radius" of any single tool failure exceptionally small.
The core principle is deploying AI exclusively where its cognitive capabilities are strictly necessary. Instead of asking the model to handle routine parsing tasks, the system uses the LLM specifically for semantic reasoning, such as asking "do these actual meanings match?" or verifying whether a given heading accurately describes the content structured beneath it. Furthermore, because these prompts are executed systematically, the model generates an explicit justification alongside each finding. This rationale is surfaced directly to developers, giving humans full transparency into why an issue was flagged and the ability to review or override the decision.
- **Guaranteed scope**: Eliminates agent hallucination and missed edge cases by feeding single, isolated element contexts rather than dumping full WCAG specs. - **Small failure blast radius**: Redundant DOM and visual pipelines prevent single-point detection failures from breaking the audit. - **Focused LLM reasoning**: Reserves model compute strictly for semantic matching and contextual comprehension tasks. - **Auditable reasoning**: Returns structured justifications for every flagged issue, allowing developers to inspect and override decisions.
[20:39](https://www.youtube.com/watch?v=pBSEfsJLaMQ&t=1239s) Cost Predictability and Low Noise: Hybrid vs. Pure LLM Approaches
When benchmarking audit strategies across cost, duration, and accuracy, pure LLM workflows show extreme unpredictability. Evaluating simple and detailed prompt strategies with models like Claude demonstrates that performance is often "all over the map"—with basic prompts occasionally taking longer or consuming more resources than complex ones without delivering consistent results. In contrast, the hybrid deterministic architecture delivers a predictable "straight line in terms of cost."
``` +-----------------------------------+-----------------------------------+ | Metric | Pure LLM Prompts (Simple/Detail) | Hybrid Deterministic Pipeline | +-----------------------------------+-----------------------------------+ | Cost & Runtime Predictability | Highly volatile; irregular spikes | Consistent "straight line" cost | | False Positive Rate | Variable noise and hallucinations | Rounds down to near-zero | | Downstream Agent Parsing Overhead | Expensive, noisy token payload | Fraction of standard LLM cost | +-----------------------------------+-----------------------------------+ ```
Evaluating real-world utility requires measuring not only how many legitimate accessibility flaws are caught, but also the volume of false positives and the computational overhead imposed on downstream agents. The hybrid framework produces false positive rates that, while technically above absolute zero, "actually round down to zero." By filtering out spurious noise before an agent processes the report, token consumption and execution costs drop to a small fraction of what unconstrained models demand.
[21:34](https://www.youtube.com/watch?v=pBSEfsJLaMQ&t=1294s) RAG-Powered Remediation and Massive Efficiency Gains
The deterministic, context-driven architecture extends directly into automated code remediation. Deque pairs incoming accessibility findings with a comprehensive database of verified accessibility solutions using a specialized RAG-based (Retrieval-Augmented Generation) backend. When an issue is identified, the system packages the complete contextual snapshot and retrieves the optimal remediation pattern for that specific application framework.
This curated remediation proposal is passed to the developer's coding agent, which applies the fix directly into the repository while honoring local design systems, custom component libraries, and codebase conventions. In production environments, this hybrid pipeline delivers dramatic efficiency gains:
- **Labor reduction**: Compresses remediation workloads that previously required 257 engineering hours down to just 4 hours. - **Zero-touch automation**: Resolves 70% of identified accessibility defects completely automatically without human intervention. - **Supervised completion**: Handles 80% of issues with only minimal human oversight or review.
The ultimate takeaway is that while large language models are extraordinarily capable tools, they must be deployed with architectural discipline—using them where semantic reasoning is essential while relying on deterministic tools and hybrid pipelines for everything else.
## Notable quotes > [00:04](https://www.youtube.com/watch?v=pBSEfsJLaMQ&t=4s) as good or better even better than what humans build — Dylan Barrell
> [04:32](https://www.youtube.com/watch?v=pBSEfsJLaMQ&t=272s) not my fault — Dylan Barrell
> [04:32](https://www.youtube.com/watch?v=pBSEfsJLaMQ&t=272s) don't poll... just wait for the monitor to fire — Dylan Barrell
> [04:32](https://www.youtube.com/watch?v=pBSEfsJLaMQ&t=272s) Okay, yep. I'll stop polling — Agent
> [10:08](https://www.youtube.com/watch?v=pBSEfsJLaMQ&t=608s) follow every single call all the way to the sink — Dylan Barrell
> [10:08](https://www.youtube.com/watch?v=pBSEfsJLaMQ&t=608s) Never use an LLM if you can do it deterministically — Dylan Barrell
> [10:08](https://www.youtube.com/watch?v=pBSEfsJLaMQ&t=608s) Break hybrid problems down — Dylan Barrell
> [10:08](https://www.youtube.com/watch?v=pBSEfsJLaMQ&t=608s) Use AI strictly as a last resort — Dylan Barrell
> [18:53](https://www.youtube.com/watch?v=pBSEfsJLaMQ&t=1133s) do these actual meanings match? — Dylan Barrell
> [20:39](https://www.youtube.com/watch?v=pBSEfsJLaMQ&t=1239s) all over the map — Dylan Barrell
> [20:39](https://www.youtube.com/watch?v=pBSEfsJLaMQ&t=1239s) straight line in terms of cost — Dylan Barrell
> [20:39](https://www.youtube.com/watch?v=pBSEfsJLaMQ&t=1239s) actually round down to zero — Dylan Barrell
## Mentioned Dylan Barrell, Deque Systems, Ai4, Figma, Claude 3.7 Sonnet, Anthropic Claude, GitHub Copilot, ESLint, DataDog, Playwright, axe-core, WCAG
## Video description Dylan Barrell - Chief Technology Officer, Deque Systems
When AI coding agents generate UI on the fly, they introduce highly dynamic, unpredictable accessibility bugs—from broken keyboard traps to unreadable, low-contrast color palettes. If your testing pipeline relies solely on traditional static linter rules, you are only finding half the issues and just throwing an AI at the problem is a token burning time bomb.
You need to combine the best of the AI agent with good context creation and deterministic tools to achieve what you need to with a reasonable cost.
It’s time to upgrade your UI stack.
This technical talk introduces an advanced testing pattern built for the agentic era. We’ll show you how to stop wasting tokens on expensive, endless quality loops and instead deploy cost-effective skills, tools and AI. By orchestrating Playwright and targeted LLM vision calls to dynamically audit live rendered applications rather than guessing at static code, this architecture catches 30% more real-world accessibility issues than axe-core with a fraction of the cost and near-zero noise. Stop babysitting your agent's code and start automating its validation efficiently.
[Source](https://www.youtube.com/watch?v=pBSEfsJLaMQ)