<?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: shakti mishra</title>
    <description>The latest articles on DEV Community by shakti mishra (@shakti_mishra_308e9f36b5d).</description>
    <link>https://dev.to/shakti_mishra_308e9f36b5d</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%2F3895003%2Ff64e0882-0aa9-44ad-8c7c-a53d7a669188.jpg</url>
      <title>DEV Community: shakti mishra</title>
      <link>https://dev.to/shakti_mishra_308e9f36b5d</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/shakti_mishra_308e9f36b5d"/>
    <language>en</language>
    <item>
      <title>Workload-Fit Routing: A Four-Decision Test for Assigning Models to Agentic Tasks</title>
      <dc:creator>shakti mishra</dc:creator>
      <pubDate>Sat, 19 Sep 2026 14:51:58 +0000</pubDate>
      <link>https://dev.to/shakti_mishra_308e9f36b5d/workload-fit-routing-a-four-decision-test-for-assigning-models-to-agentic-tasks-1o5i</link>
      <guid>https://dev.to/shakti_mishra_308e9f36b5d/workload-fit-routing-a-four-decision-test-for-assigning-models-to-agentic-tasks-1o5i</guid>
      <description>&lt;h2&gt;
  
  
  Stop Picking a Model. Start Routing Workloads.
&lt;/h2&gt;

&lt;p&gt;Procurement wants one model. Your architecture wants two.&lt;/p&gt;

&lt;p&gt;That tension is where most enterprise AI programs quietly lose money. Someone runs a bake-off, picks a winner on aggregate benchmark scores, signs an enterprise agreement, and then routes every workload — spreadsheet reconciliation, CI/CD debugging, contract analysis, browser automation — through the same endpoint. The bill arrives in Q3 and nobody can explain it.&lt;/p&gt;

&lt;p&gt;Here's the thing the benchmark leaderboard can't tell you: &lt;strong&gt;"best model" is not a property of a model. It's a property of a model &lt;em&gt;plus a workload plus a tool surface plus an acceptance criterion&lt;/em&gt;.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Consider two requests hitting the same architect in the same week. Finance wants an agent that opens a sales spreadsheet, reconciles the numbers, builds a chart, updates a deck, and saves the document. Engineering wants an agent that investigates a recurring inventory-service bug, traces dependencies, proposes a fix, and verifies that the fix doesn't break a neighboring service.&lt;/p&gt;

&lt;p&gt;Those look similar on a roadmap. They fail in completely different ways. The spreadsheet workflow fails when the agent writes to the wrong file. The debugging workflow fails when a plausible-looking patch hides the actual defect. In neither case is "produced a fast answer" the definition of done.&lt;/p&gt;

&lt;p&gt;You're not hiring the smartest colleague. You're assigning responsibilities, tools, and acceptance criteria to two different jobs.&lt;/p&gt;

&lt;h2&gt;
  
  
  The reflex vs. the fix
&lt;/h2&gt;

&lt;p&gt;Most teams run this loop:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;REFLEX:  pick a model → give it every task → optimize the bill later
FIX:     define the job → test the model + tools → verify the outcome
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The reflex isn't stupid. It's operationally cheap — one vendor, one key, one SDK, one set of rate limits. It only becomes expensive when the failure modes diverge, which is exactly what happens the moment your agents start &lt;em&gt;acting&lt;/em&gt; instead of &lt;em&gt;answering&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;The fix requires you to score each workload on four decisions before any model gets assigned.&lt;/p&gt;

&lt;h2&gt;
  
  
  The four-decision routing test
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Execution — can it complete the required actions across your tools?
&lt;/h3&gt;

&lt;p&gt;Not "can it write code that would work." Can it drive your actual tool surface: your CRM API, your shell, your browser, your filesystem? This is an agentic capability question, and it's mostly orthogonal to reasoning quality.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Building — can it understand the problem and produce a correct, maintainable artifact?
&lt;/h3&gt;

&lt;p&gt;This is the analytical axis. Does the output survive code review? Does the contract comparison hold up when a lawyer reads it? An artifact that's wrong in a subtle way is worse than no artifact, because it consumes review cycles and then fails in production anyway.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Time — does it meet the deadline for an &lt;em&gt;accepted&lt;/em&gt; result?
&lt;/h3&gt;

&lt;p&gt;Note the word accepted. Time-to-first-token is a demo metric. Time-to-accepted-outcome includes retries, tool errors, and the human who has to look at it. A model that answers in four seconds and gets rejected twice is slower than one that takes forty seconds and lands.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Cost — what does that accepted result cost, fully loaded?
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;cost_per_accepted_outcome&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;input_tokens_uncached&lt;/span&gt; &lt;span class="err"&gt;×&lt;/span&gt; &lt;span class="n"&gt;rate_in&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;input_tokens_cached&lt;/span&gt;   &lt;span class="err"&gt;×&lt;/span&gt; &lt;span class="n"&gt;rate_cached&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cache_write_tokens&lt;/span&gt;    &lt;span class="err"&gt;×&lt;/span&gt; &lt;span class="n"&gt;rate_cache_write&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;output_tokens&lt;/span&gt;         &lt;span class="err"&gt;×&lt;/span&gt; &lt;span class="n"&gt;rate_out&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;retry_count&lt;/span&gt; &lt;span class="err"&gt;×&lt;/span&gt; &lt;span class="n"&gt;full_attempt_cost&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;human_review_minutes&lt;/span&gt;  &lt;span class="err"&gt;×&lt;/span&gt; &lt;span class="n"&gt;loaded_hourly_rate&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="err"&gt;÷&lt;/span&gt; &lt;span class="n"&gt;acceptance_rate&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That last division is the one everyone forgets. At a 70% acceptance rate, your real cost per outcome is 1.43× your per-attempt cost. Token price is maybe a third of the equation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reading benchmarks as capability signals, not rankings
&lt;/h2&gt;

&lt;p&gt;The useful move isn't "which model is #1." It's "what does this specific test actually measure, and which of my workloads does that map to?"&lt;/p&gt;

&lt;p&gt;Working from the Artificial Analysis September 15 snapshot at maximum reasoning effort (with Fable's default fallback enabled — meaning another model may service some requests, so treat these as directional, not matched):&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Astra reads as an operator.&lt;/strong&gt; It leads on AutomationBench-AA, which measures completing multi-step business workflows across SaaS apps through APIs while respecting business rules. It also posts stronger Terminal-Bench 4.0 results — command-line engineering and ops work. OpenAI reports it ahead of GPT-5.6 Sol and Claude Opus 5 on OSWorld 2.0's offline partial-credit comparison, though that published setup doesn't establish a matched head-to-head against Fable 5.1.&lt;/p&gt;

&lt;p&gt;Map that to: CRM record updates, support escalation processing, employee onboarding flows, expense-vs-budget checks, failed build triage, dependency resolution, CI/CD pipeline debugging, supplier invoice retrieval, portal form filling, frontend QA.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fable reads as an analytical builder.&lt;/strong&gt; It leads on SciCode — scientific programming specifically, not software development broadly — and on AA-LCR v1.1, long-document reasoning.&lt;/p&gt;

&lt;p&gt;Map that to: engineering simulations, numerical work, research-oriented code where domain reasoning and code generation have to interlock, supplier contract comparison, RFP analysis, financial report review, conflicting-policy detection, regulatory requirement mapping.&lt;/p&gt;

&lt;p&gt;Then the economics split in an interesting way: Astra shows lower cost per task in the cited evaluation, while Fable is cheaper on cached input. Those favor different shapes of work.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cached-input pricing is a workload-shape question, not a discount.&lt;/strong&gt; If the same large context — a policy corpus, a codebase, a contract set, a documentation tree — gets reused across many calls, cache-friendly pricing dominates the bill. If every call carries a fresh context, it's irrelevant. Check your reuse ratio before you let a pricing page pick your model.&lt;/p&gt;

&lt;h2&gt;
  
  
  The pattern that beats picking one: plan with the builder, execute with the operator
&lt;/h2&gt;

&lt;p&gt;Once you stop treating model choice as a procurement decision, an obvious architecture falls out. Split the workflow at the plan/act boundary.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                    ┌──────────────────────────────┐
   task + context → │  PLANNER  (analytical model) │
                    │  • decompose the goal        │
                    │  • read the long context     │
                    │  • emit typed action plan    │
                    └───────────────┬──────────────┘
                                    │  structured plan
                                    │  (JSON, validated)
                    ┌───────────────▼──────────────┐
                    │  VALIDATOR (deterministic)   │
                    │  • schema check              │
                    │  • policy / scope check      │
                    │  • blast-radius estimate     │
                    └───────────────┬──────────────┘
                          reject ◄──┤──► approve
                                    │
                    ┌───────────────▼──────────────┐
                    │  EXECUTOR (operator model)   │
                    │  • drive tools step by step  │
                    │  • no re-planning authority  │
                    │  • emit per-step receipts    │
                    └───────────────┬──────────────┘
                                    │
                    ┌───────────────▼──────────────┐
                    │  VERIFIER                    │
                    │  • did the artifact change?  │
                    │  • does it pass acceptance?  │
                    └──────────────────────────────┘
                         pass → done | fail → replan
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The critical design constraint: &lt;strong&gt;the executor does not get replanning authority.&lt;/strong&gt; If it hits an unexpected state, it fails the step and returns control to the planner. That one rule is what makes the split worth the added latency — it keeps an operator-tuned model from improvising its way into your production filesystem.&lt;/p&gt;

&lt;p&gt;Here's the handoff contract, which matters more than either model choice:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"plan_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"recon-2026-09-19-001"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"goal"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Reconcile Q3 regional sales against the GL extract"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"acceptance"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"assertion"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"check"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"variance_report.total_unexplained &amp;lt; 0.005 * gl_total"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"steps"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"tool"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"sheets.read"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"args"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"file_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"1AbC..."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"range"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Q3!A1:M400"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"writes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"tool"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"sheets.write"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"args"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"file_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"1AbC..."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"range"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Variance!A1"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"writes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"blast_radius"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"single_sheet"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"requires_approval"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"on_unexpected_state"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"halt_and_return"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every step declares whether it writes. Every write declares a blast radius. The validator can now enforce policy &lt;em&gt;before&lt;/em&gt; a token of execution is spent — and your autonomy limits become config, not vibes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Autonomy is a dial, not a switch
&lt;/h2&gt;

&lt;p&gt;The four decisions give you capability. This gives you containment:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tier&lt;/th&gt;
&lt;th&gt;Model class&lt;/th&gt;
&lt;th&gt;Write access&lt;/th&gt;
&lt;th&gt;Human gate&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;T0&lt;/td&gt;
&lt;td&gt;Small / cheap&lt;/td&gt;
&lt;td&gt;None (read-only)&lt;/td&gt;
&lt;td&gt;None&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;T1&lt;/td&gt;
&lt;td&gt;Operator&lt;/td&gt;
&lt;td&gt;Scratch + sandbox&lt;/td&gt;
&lt;td&gt;Post-hoc audit&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;T2&lt;/td&gt;
&lt;td&gt;Operator&lt;/td&gt;
&lt;td&gt;Scoped production writes&lt;/td&gt;
&lt;td&gt;Pre-approve plan&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;T3&lt;/td&gt;
&lt;td&gt;Builder + Operator&lt;/td&gt;
&lt;td&gt;Broad production writes&lt;/td&gt;
&lt;td&gt;Approve plan + verify artifact&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Most workloads that get routed to a frontier model belong at T0 or T1. Classification, extraction, routing, summarization of a single document, formatting — these don't need frontier reasoning, and paying for it is the quiet majority of overspend in most agent platforms I've seen described.&lt;/p&gt;

&lt;p&gt;You do not need a frontier model at every step. You need the right amount of intelligence at each step.&lt;/p&gt;

&lt;h2&gt;
  
  
  What to actually do on Monday
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;List your top five agentic workloads. For each, write the acceptance criterion as an assertion, not a sentence.&lt;/li&gt;
&lt;li&gt;Score each on the four decisions. Execution and Building especially — most teams have never separated them.&lt;/li&gt;
&lt;li&gt;Compute cost per &lt;em&gt;accepted&lt;/em&gt; outcome, including retries and review minutes. Divide by acceptance rate.&lt;/li&gt;
&lt;li&gt;Find the workloads with high context reuse. Those are your cache-pricing candidates.&lt;/li&gt;
&lt;li&gt;Pick one workflow and split it at the plan/act boundary with a typed handoff contract. Measure acceptance rate before and after.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Key takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;"Best model" isn't a model property.&lt;/strong&gt; It's model × workload × tool surface × acceptance criterion. Leaderboards can't encode the last three.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Score four decisions, not one score:&lt;/strong&gt; Execution (can it drive your tools?), Building (is the artifact correct and maintainable?), Time (to accepted result, not first token), Cost (per accepted outcome, fully loaded).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Benchmarks are capability signals.&lt;/strong&gt; Read what a test measures — SaaS workflow completion, terminal ops, scientific programming, long-document reasoning — and map it to a workload, not a ranking.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cached-input pricing only matters if your context is reused.&lt;/strong&gt; Measure your reuse ratio before letting a pricing page make an architecture decision.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Split plan from execute, and deny the executor replanning authority.&lt;/strong&gt; A typed, write-annotated handoff contract turns autonomy limits into enforceable config.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Most steps don't need a frontier model.&lt;/strong&gt; Tier your autonomy and your model class together.
## Your turn&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here's what I keep going back and forth on: the planner/executor split adds a network hop, a serialization boundary, and a second vendor relationship. It only pays off if the acceptance rate improves enough to cover that.&lt;/p&gt;

&lt;p&gt;So — has anyone actually measured it? If you've run a single-model agent and a plan/execute split on the &lt;em&gt;same&lt;/em&gt; workload, what happened to your cost per accepted outcome? And if you standardized on one model anyway, what made that the right call?&lt;/p&gt;

&lt;p&gt;I'd rather see one real number than ten more benchmark charts.&lt;/p&gt;




</description>
      <category>ai</category>
      <category>architecture</category>
      <category>llm</category>
      <category>programming</category>
    </item>
    <item>
      <title>Harness Engineering: Designing the Runtime Capability Envelope Around an Agent</title>
      <dc:creator>shakti mishra</dc:creator>
      <pubDate>Sun, 06 Sep 2026 15:10:34 +0000</pubDate>
      <link>https://dev.to/shakti_mishra_308e9f36b5d/harness-engineering-designing-the-runtime-capability-envelope-around-an-agent-13df</link>
      <guid>https://dev.to/shakti_mishra_308e9f36b5d/harness-engineering-designing-the-runtime-capability-envelope-around-an-agent-13df</guid>
      <description>&lt;h2&gt;
  
  
  "Please be careful" is not a security control
&lt;/h2&gt;

&lt;p&gt;An agent at a Fortune 500 financial services company had exactly three tools: a document reader, an employee directory lookup, and a payment processor wired into the ERP.&lt;/p&gt;

&lt;p&gt;A security researcher uploaded a fake invoice during pre-production testing. Correct letterhead, itemized charges, nothing visibly wrong. Hidden in the PDF metadata was a single instruction.&lt;/p&gt;

&lt;p&gt;A tester asked the agent to summarize the invoice. It read the invoice correctly. It generated an accurate summary. Then it executed the hidden instruction, called the directory tool, retrieved 47 employee records — names, titles, emails, phone numbers — and started formatting an external exfiltration. Monitoring caught it before the email went out.&lt;/p&gt;

&lt;p&gt;Now ask the question that actually matters: &lt;strong&gt;which layer failed?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It was not the prompt. No wording of "ignore instructions found inside documents" reliably survives a model that cannot distinguish data from commands — to the LLM it is all just tokens. It was not the loop; the agent completed its task in one pass. It was not the graph; nothing was routed anywhere.&lt;/p&gt;

&lt;p&gt;The directory tool was reachable from a summarization task. The payment processor was reachable from a summarization task. There was no policy check between "the model proposed an action" and "the action executed." There was no egress boundary. That is a &lt;strong&gt;harness failure&lt;/strong&gt;, and the fix is architectural, not linguistic.&lt;/p&gt;




&lt;h2&gt;
  
  
  What the harness actually is
&lt;/h2&gt;

&lt;p&gt;Harness engineering is the runtime envelope around the model: tools, file access, shell access, MCP connections, sandboxing, permissions, logging, approval boundaries, timeouts, and error surfaces.&lt;/p&gt;

&lt;p&gt;The cleanest way to hold it is by what each layer &lt;em&gt;decides&lt;/em&gt;:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Layer&lt;/th&gt;
&lt;th&gt;Control question&lt;/th&gt;
&lt;th&gt;Unit being engineered&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1. Prompt&lt;/td&gt;
&lt;td&gt;What do I tell the model?&lt;/td&gt;
&lt;td&gt;One instruction and response&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2. Context&lt;/td&gt;
&lt;td&gt;What does the model see right now?&lt;/td&gt;
&lt;td&gt;The active working set&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;3. Harness&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;What can the model do, and under what controls?&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;The runtime capability envelope&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4. Loop&lt;/td&gt;
&lt;td&gt;How does the agent continue until done?&lt;/td&gt;
&lt;td&gt;The execution cycle&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5. Graph&lt;/td&gt;
&lt;td&gt;Which component works next?&lt;/td&gt;
&lt;td&gt;The topology of the system&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;MODEL CALL  =  prompt + context
AGENT       =  model call + harness + loop
SYSTEM      =  agents + deterministic steps + humans, connected by a graph
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The harness is the layer where a model call stops being a conversation and starts being something that can touch your infrastructure.&lt;/p&gt;

&lt;p&gt;The division of labor at Layer 3 is sharp. &lt;strong&gt;The model decides "I need to run the tests." The harness decides whether test execution is available at all, which commands are allowed, which directory is visible, how long the process may run, what output comes back, and what gets recorded.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That sentence is the whole discipline. The model proposes. The harness disposes.&lt;/p&gt;




&lt;h2&gt;
  
  
  The envelope, drawn
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌── SANDBOX ──── IDENTITY ──── PERMISSIONS ──── ALLOWLIST ───┐
│                                                            │
│                       AGENT HARNESS                        │
│                  capability + control                      │
│                                                            │
│      TERMINAL      FILES        GIT       MCP TOOLS        │
│          ▲           ▲           ▲            ▲            │
│          └───────────┴─────┬─────┴────────────┘            │
│                         ┌──┴──┐                            │
│                         │MODEL│                            │
│                         └──┬──┘                            │
│                            │ proposes action               │
│                            ▼                               │
│                     ┌──────────────┐                       │
│                     │ POLICY CHECK │                       │
│                     └──┬────────┬──┘                       │
│                  ALLOW │        │ DENY                     │
│                        ▼        ▼                          │
│                  tool action   deny + explain              │
│                        │        │                          │
│                        └───┬────┘                          │
│                            ▼                               │
│                       observation ─────► back to MODEL     │
│                                                            │
└── TIMEOUTS ── APPROVAL GATE ── SECRETS ── LOGS + TRACES ───┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three details in that diagram carry most of the weight.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The control chips sit on the boundary, not inside it.&lt;/strong&gt; Sandbox, identity, permissions, allow list, timeouts, approval gate, secrets isolation, and logs are properties of the envelope. They are not tools the agent calls and they are not instructions the agent can be talked out of. If a control is something the model can reason its way past, it is a prompt, not a harness.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Every proposed action passes through a policy check before it becomes a tool action.&lt;/strong&gt; Not after. The interesting architectural choice is what sits on that edge — an allow list, a scope check against the current task, a blast-radius classifier, an approval gate for anything above a threshold.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Deny returns an observation, it does not throw.&lt;/strong&gt; This is the part teams get wrong most often. A denial that surfaces as an opaque exception gives the agent nothing to work with, so it retries the same forbidden action until the budget dies. A denial that returns &lt;em&gt;"blocked: directory lookup is not in scope for a summarization task"&lt;/em&gt; lets the agent adapt or escalate. &lt;strong&gt;Deny and explain, not deny and crash.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Capability without control expands blast radius
&lt;/h2&gt;

&lt;p&gt;That is the whole thesis in six words, and it reframes tool design as a security decision rather than a features decision.&lt;/p&gt;

&lt;p&gt;Return to the invoice incident and map it against the envelope:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SHIPPED CONFIGURATION — blast radius = every registered tool

  "summarize this invoice"
          │
          ▼
        Agent ──► doc reader        ──► summary                  ✅
          ├─────► directory lookup  ──► 47 employee records      ❌
          │                                     │
          │                                     ▼
          │                            external send attempt     ❌
          └─────► payment processor  ──► reachable, untriggered  ❌


HARNESSED CONFIGURATION — blast radius = one tool

  "summarize this invoice"
          │
          ▼
     scope check ──► doc reader ──► summary ──► egress boundary  ✅
          │
          ├─────► directory lookup     DENIED — out of task scope
          └─────► payment processor    APPROVAL GATE — irreversible
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The failing configuration is not unusual. It is what you get when tools are registered once, at the agent level, and every task inherits the full manifest. The task was summarization; the capability envelope was "everything this agent has ever needed."&lt;/p&gt;

&lt;p&gt;The harnessed version changes four things, none of which touch the prompt:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Per-task scoping.&lt;/strong&gt; The tool manifest is derived from the task, not from the agent. A summarization task does not get a directory lookup.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Blast-radius tiering.&lt;/strong&gt; The payment processor is not merely allow list or denied — it sits behind an approval gate because a wrong call is irreversible.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;An egress boundary.&lt;/strong&gt; Data leaving the envelope is its own control point, independent of which tool produced it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Deny paths that return observations.&lt;/strong&gt; The agent learns it was blocked and why.
Note what this buys you against indirect prompt injection specifically. You cannot reliably teach a model to distinguish instructions embedded in retrieved content from instructions issued by the user — that is the defining weakness of the architecture. What you &lt;em&gt;can&lt;/em&gt; do is guarantee that a successful injection reaches a capability envelope narrow enough that the injection has nothing useful to do.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To be precise about the claim: input filtering, output classifiers, and instruction-hierarchy training all reduce the &lt;em&gt;rate&lt;/em&gt; of successful injection, and you should run them. What they cannot do is give you a bound. The harness is the only layer that produces one — it caps what a successful injection can reach, independent of how the injection got through. &lt;strong&gt;Detection lowers the probability. Only the harness lowers the damage.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  MCP authorizes the connection. It does not authorize the task.
&lt;/h2&gt;

&lt;p&gt;This is the distinction teams collapse, and it is worth being precise about — including in the direction that flatters MCP.&lt;/p&gt;

&lt;p&gt;MCP is not authorization-silent. The spec is built on OAuth 2.1: the MCP server is a resource server, a separate authorization server issues tokens, PKCE with S256 is mandatory, and RFC 9728 protected resource metadata plus RFC 8707 resource indicators bind a token to a specific server. Scopes are first-class (&lt;code&gt;mcp:read&lt;/code&gt;, &lt;code&gt;mcp:write&lt;/code&gt;), the 2025-11-25 revision added step-up authorization so a server can demand more scope mid-session, and token passthrough is explicitly forbidden — a server must reject tokens not issued for it.&lt;/p&gt;

&lt;p&gt;So "MCP doesn't do auth" is a claim that has been out of date for a while. Say it in a design review and someone will correct you.&lt;/p&gt;

&lt;p&gt;What the spec deliberately leaves open is narrower and more interesting:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;MCP SPECIFIES                    │  STILL YOURS TO BUILD
─────────────────────────────────┼──────────────────────────────────
OAuth 2.1 client/server roles    │  which tools THIS task may use
PKCE, resource indicators        │  per-task manifest derivation
protected resource metadata      │  blast-radius tiering
coarse scopes (mcp:read/write)   │  approval gates on irreversible ops
no token passthrough             │  MCP server → downstream API auth
                                 │  agent-acting-on-own-behalf auth
                                 │
                          trust boundary
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two of those gaps are named limitations in the spec's own discourse. How an MCP server authenticates onward to the database or API behind it is described as outside the specification's scope. Server-to-server and agent-acting-on-its-own-behalf authorization is intentionally left silent in the core spec. And scope granularity is a known pain point — Rich Authorization Requests have been discussed for exactly this reason and are not in the protocol.&lt;/p&gt;

&lt;p&gt;Which lands on the point that matters for Layer 3. An MCP server exposing a &lt;code&gt;delete_records&lt;/code&gt; tool, behind a correctly implemented OAuth 2.1 flow, with a valid token carrying &lt;code&gt;mcp:write&lt;/code&gt;, has answered &lt;em&gt;"is this client allowed to talk to me?"&lt;/em&gt; It has not answered &lt;em&gt;"should a summarization task invoke destructive deletion right now?"&lt;/em&gt; A scope is not a task scope. &lt;strong&gt;That second question is the harness's, and nothing in the protocol will answer it for you.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Teams that treat "we adopted MCP" as "we solved tool governance" have correctly secured the connection and left the blast radius untouched.&lt;/p&gt;




&lt;h2&gt;
  
  
  Where the harness ends and the loop begins
&lt;/h2&gt;

&lt;p&gt;The boundary between Layer 3 and Layer 4 is where most architecture arguments stall, so here is the split as a pair of questions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Harness:&lt;/strong&gt; &lt;em&gt;Can&lt;/em&gt; the agent execute the test — in which sandbox, with what permission, under what timeout?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Loop:&lt;/strong&gt; &lt;em&gt;Should&lt;/em&gt; a failed test trigger another attempt, what must change before retrying, how many attempts are allowed, and what counts as done?
You can have an excellent harness and a terrible loop. An agent can be perfectly sandboxed, fully logged, permission-scoped to exactly the right surface — and still retry the identical failing fix until it exhausts its token budget. Nothing in the harness stops that, because nothing in the harness is supposed to.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The inverse is worse. A disciplined loop with a wide-open harness means every retry is a fresh opportunity to do damage with precision and persistence.&lt;/p&gt;

&lt;p&gt;This is also why "the layers are not a build order" matters. Sketch the graph, define the control boundaries, then tune prompts. The harness is a concentric ring around the model, not a stage in a pipeline — and in practice the weakest control sets the reliability ceiling for the entire system.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why I keep the definition narrow
&lt;/h2&gt;

&lt;p&gt;You will encounter a much broader use of "harness" in the wild — one that means &lt;em&gt;everything in an agent that is not the model&lt;/em&gt;. Under that reading, the harness swallows the instruction file at your repo root, the retrieval pipeline, the verification loop, the memory store, the orchestration, all of it.&lt;/p&gt;

&lt;p&gt;That definition is not wrong. It is just useless for the thing Layer 3 exists to do.&lt;/p&gt;

&lt;p&gt;The honest caveat in the five-layer framework is that the boundaries leak. Memory can plausibly be filed under context, harness, or runtime state. Verification can sit inside a tool boundary, a retry loop, or a separate graph node. These are five &lt;em&gt;concerns&lt;/em&gt;, not five cleanly separated software components, and anyone who tells you the seams are crisp has not shipped one.&lt;/p&gt;

&lt;p&gt;So the question is not which definition is philosophically correct. It is which one produces better decisions in a design review. Two tests:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Can you audit it?&lt;/strong&gt; "Is our harness good?" is unanswerable if the harness is everything. "Which tools are reachable from this task, who authorized them, and what happens on deny" is a question with a finite answer that a security reviewer can actually check. A category that spans the entire system is a category you cannot pass or fail.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Does it survive a postmortem?&lt;/strong&gt; When an agent burns its budget retrying an identical broken fix, the narrow definition tells you immediately that the harness held and the loop failed — go fix the retry policy. The broad definition tells you "the harness failed," which is true, uninformative, and points at no owner.&lt;/p&gt;

&lt;p&gt;Diagnostic clarity is the whole value of the layered model. It gives a team a better answer than "the AI was weird." Collapse verification, retrieval, and permissions into one word and you have traded that clarity for a tidier vocabulary.&lt;/p&gt;

&lt;p&gt;Use the wide definition when you are explaining to an executive why the model is not the product. Use the narrow one when you are deciding what your agent is allowed to touch on Monday.&lt;/p&gt;




&lt;h2&gt;
  
  
  Measuring harness quality
&lt;/h2&gt;

&lt;p&gt;A layer you cannot measure is a layer you cannot defend in a design review. Three metrics travel well:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Metric&lt;/th&gt;
&lt;th&gt;What it tells you&lt;/th&gt;
&lt;th&gt;Failure signal&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Tool success rate&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Whether the capability surface actually works&lt;/td&gt;
&lt;td&gt;High denial-adjacent failures mean your allowlist is wrong, not your model&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Unsafe actions denied&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Whether the policy check is doing anything&lt;/td&gt;
&lt;td&gt;A permanent zero means either a perfect agent or a dead control&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Permission boundary integrity&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Whether scope holds under adversarial input&lt;/td&gt;
&lt;td&gt;Any crossing is a P0, not a tuning issue&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;That middle row deserves emphasis. &lt;strong&gt;If your deny counter never moves, you do not have evidence of safety — you have an untested control.&lt;/strong&gt; Treat a flat-zero denial rate the way you would treat a monitoring system that has never fired an alert: assume it is broken until you prove otherwise with a deliberate probe.&lt;/p&gt;

&lt;p&gt;Which points at the natural companion practice. Automated red teaming exists to move that counter on purpose — adversarial probing that scores attack-response pairs into an attack success rate, run continuously rather than once before launch. Harness metrics tell you the envelope is holding. Red teaming tells you whether anyone has actually pushed on it.&lt;/p&gt;

&lt;p&gt;Both belong on the same dashboard, alongside latency and cost. As Microsoft's framing puts it: a chatbot saying something offensive is a PR issue; an agent executing a prohibited action is a security breach.&lt;/p&gt;




&lt;h2&gt;
  
  
  What to build first
&lt;/h2&gt;

&lt;p&gt;If you are retrofitting a harness onto an agent already in production, the ordering that produces the fastest risk reduction:&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart LR
    A[Inventory the real&amp;lt;br/&amp;gt;capability envelope] --&amp;gt; B[Scope manifests&amp;lt;br/&amp;gt;per task]
    B --&amp;gt; C[Policy check on&amp;lt;br/&amp;gt;proposed action]
    C --&amp;gt; D[Deny + explain&amp;lt;br/&amp;gt;observations]
    D --&amp;gt; E[Approval gates on&amp;lt;br/&amp;gt;irreversible actions]
    E --&amp;gt; F[Instrument&amp;lt;br/&amp;gt;the boundary]&lt;/code&gt;&lt;/pre&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Inventory the actual capability envelope.&lt;/strong&gt; Not the documented one. Enumerate every tool reachable from every task type, including transitively through MCP servers. Most teams find at least one surprise.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Derive tool manifests per task, not per agent.&lt;/strong&gt; This single change eliminates the largest class of blast-radius incidents, and it costs you a routing decision rather than a rewrite.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Insert the policy check on the proposed-action edge.&lt;/strong&gt; Start with an allowlist. Add scope checking second. Add blast-radius tiering third.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Make denials informative observations.&lt;/strong&gt; Cheapest change on this list, and it converts a retry storm into an escalation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Put irreversible actions behind approval gates.&lt;/strong&gt; Deletion, payment, external send, production writes. If undoing it requires a human, invoking it should too.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Instrument the boundary.&lt;/strong&gt; Logs and traces on every proposed action, allowed or denied. You cannot investigate an incident inside an envelope you did not record.
Prompts still matter. In an agent system the prompt is the steering wheel — but the harness is the brakes, the seatbelt, and the guardrail on the shoulder. Nobody has ever argued that a good driver makes the guardrail optional.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Key takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The model proposes, the harness disposes.&lt;/strong&gt; The model decides it needs to run a command; the harness decides whether that capability exists, in which sandbox, under what permission and timeout.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Controls belong on the boundary, not in the prompt.&lt;/strong&gt; If the agent can reason its way past a constraint, that constraint is an instruction, not a control.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Capability without control expands blast radius.&lt;/strong&gt; Tool registration is a security decision. Scope tool manifests per task, not per agent.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Deny and explain, not deny and crash.&lt;/strong&gt; A denial that returns an interpretable observation lets the agent adapt; an opaque exception produces a retry storm.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;MCP authorizes the connection, not the task.&lt;/strong&gt; OAuth 2.1, PKCE, and scopes answer "may this client talk to this server." Whether &lt;em&gt;this task&lt;/em&gt; should invoke &lt;em&gt;this tool right now&lt;/em&gt; is the harness's question, and the protocol leaves it open.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A denial counter stuck at zero is an untested control&lt;/strong&gt;, not a safe system. Pair harness metrics with deliberate adversarial probing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keep the definition narrow enough to audit.&lt;/strong&gt; "Harness" is often used to mean everything that isn't the model. That framing is fine for explaining why the model isn't the product, and useless for deciding what your agent may touch on Monday.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  The question worth arguing about
&lt;/h2&gt;

&lt;p&gt;Here is the uncomfortable audit. Pick your most autonomous production agent and enumerate every tool reachable from its lowest-stakes task — a summarization, a lookup, a status check.&lt;/p&gt;

&lt;p&gt;If a hostile instruction landed inside the content that task processes, what is the worst thing it could reach?&lt;/p&gt;

&lt;p&gt;If you cannot answer that in under a minute, the envelope is not designed; it accumulated.&lt;/p&gt;

&lt;p&gt;So: &lt;strong&gt;is your agent's tool manifest scoped per task, or per agent — and if it's per agent, what's the actual reason?&lt;/strong&gt; I suspect "the framework defaults that way" is the honest answer far more often than anyone wants to admit.&lt;/p&gt;




</description>
      <category>ai</category>
      <category>security</category>
      <category>architecture</category>
      <category>devops</category>
    </item>
    <item>
      <title>Standard RAG vs. Agentic RAG: Moving Retrieval From Pipeline Stage to Runtime Decision</title>
      <dc:creator>shakti mishra</dc:creator>
      <pubDate>Sun, 30 Aug 2026 15:23:38 +0000</pubDate>
      <link>https://dev.to/shakti_mishra_308e9f36b5d/standard-rag-vs-agentic-rag-moving-retrieval-from-pipeline-stage-to-runtime-decision-2e1d</link>
      <guid>https://dev.to/shakti_mishra_308e9f36b5d/standard-rag-vs-agentic-rag-moving-retrieval-from-pipeline-stage-to-runtime-decision-2e1d</guid>
      <description>&lt;h2&gt;
  
  
  The assumption every RAG demo makes
&lt;/h2&gt;

&lt;p&gt;Standard RAG assumes the user's question maps onto one vector search. One query in, one embedding, one top-k lookup, one answer.&lt;/p&gt;

&lt;p&gt;That assumption holds up in demos, because demos ask demo questions. "What's our parental leave policy?" is one document. Retrieve it, stuff it into the prompt, done.&lt;/p&gt;

&lt;p&gt;Then you ship, and a real user types: &lt;em&gt;"Did the carrier rate change we approved in Q2 actually reduce our cost per shipment in the Northeast, and does that hold if I exclude the Boston depot?"&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;That question needs a policy document, a rate table, a transactional aggregate, and a filtered re-computation. Your retriever will embed the whole sentence, find the three chunks nearest to it in vector space, and hand the model text that is topically adjacent and factually useless. The model, being a good sport, will answer anyway.&lt;/p&gt;

&lt;p&gt;The problem isn't the embedding model or the chunk size. You hardcoded how many times to retrieve, and where to retrieve from, at design time, for a question you hadn't read yet.&lt;/p&gt;

&lt;p&gt;Agentic RAG moves that decision to runtime. Planners, memory, MCP servers, sub-agents: all of it is implementation detail hanging off that one change.&lt;/p&gt;




&lt;h2&gt;
  
  
  Architecture 1: standard RAG is a straight line
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;STANDARD RAG — fixed pipeline, one pass
┌──────┐   1. prompt+query    ┌─────────────┐
│ User │ ───────────────────► │ Chat UI     │
└──────┘                      └──────┬──────┘
   ▲                                 │ 2. query
   │ 6. response                     ▼
   │                          ┌─────────────┐
   │                          │  Retriever  │
   │                          └──────┬──────┘
   │                                 │ 3. fetch (top-k, one shot)
   │                                 ▼
   │                     ┌───────────────────────────┐
   │                     │  Knowledge Sources        │
   │                     │  docs · PDFs · code · DB  │
   │                     │  APIs · web index         │
   │                     └───────────┬───────────────┘
   │                                 │ 4. chunks
   │                          ┌──────▼──────┐
   └──────────────────────────│     LLM     │
                              └─────────────┘
                       5. prompt + query + enhanced context
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The defining property is that the model is never consulted about retrieval. It receives context and produces text, and retrieval already finished by the time it runs.&lt;/p&gt;

&lt;p&gt;That's a design choice with real advantages. One embedding call plus one vector query is cheap and predictable, latency sits in a tight distribution, and you can cache aggressively. Failures are legible: a bad answer means bad chunks, and you can go read the chunks. Your eval harness is a fixed input and a fixed output, so it works.&lt;/p&gt;

&lt;p&gt;Standard RAG is the right architecture when your corpus is homogeneous and your users mostly want lookup rather than synthesis. Don't let anyone talk you out of it for those workloads.&lt;/p&gt;




&lt;h2&gt;
  
  
  Architecture 2: agentic RAG makes retrieval a decision
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;AGENTIC RAG — planner decides retrieval at runtime
┌──────┐  1. prompt+query   ┌─────────────┐
│ User │ ─────────────────► │ Chat UI     │
└──────┘                    └──────┬──────┘
   ▲                               │ 2. query
   │ 6. response                   ▼
   │                    ┌──────────────────────┐      ┌──────────────┐
   │                    │  Aggregator /        │◄────►│ Planning     │
   │                    │  Orchestrator Agent  │  3.  │ ReAct · CoT  │
   │                    └───────┬──────────────┘      └──────────────┘
   │                            │         ▲
   │                            │         └──────┐  ┌──────────────┐
   │                            │ 4. fan-out     └─►│ Memory       │
   │                            ▼                   │ short · long │
   │            ┌───────────────┼───────────────┐   └──────────────┘
   │       ┌────▼────┐     ┌────▼────┐    ┌─────▼───┐
   │       │ Agent 1 │     │ Agent 2 │    │ Agent 3 │
   │       └────┬────┘     └────┬────┘    └────┬────┘
   │            │  MCP servers / tool layer    │
   │       ┌────▼────┐     ┌────▼────┐    ┌────▼────┐
   │       │ SQL DB  │     │ Search  │    │ Data    │
   │       │         │     │ index   │    │ Explorer│
   │       └─────────┘     └─────────┘    └─────────┘
   │                            │ 5. prompt + query + enhanced context
   │                     ┌──────▼──────┐
   └─────────────────────│     LLM     │
                         └─────────────┘
                  ◄── loop back to (3) if context insufficient
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Four things are different.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. A planner sits between the query and the retriever.&lt;/strong&gt; The aggregator agent decomposes the question before anything gets embedded. ReAct and chain-of-thought are the mechanism that turns one user sentence into a retrieval plan. The Northeast shipping question decomposes into four steps: fetch the Q2 rate change record, aggregate shipment costs by region and date, re-aggregate with the Boston depot excluded, compare.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Retrieval fans out across heterogeneous backends.&lt;/strong&gt; Standard RAG normalizes everything into one vector index at ingestion time. Agentic RAG queries systems in their native language at query time: SQL against the warehouse, semantic search against the document index, a time-series query against event data. You don't embed a rate table, you query it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. MCP is the integration seam.&lt;/strong&gt; When your retrievers are MCP servers rather than bespoke functions, the tool surface is declarative and swappable. You add a data source by registering a server instead of shipping a new agent build. It's a plugin architecture applied to retrieval.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Memory carries retrieval state across turns.&lt;/strong&gt; Short-term memory holds what this session already fetched, so hop three doesn't re-retrieve what hop one found. Long-term memory holds durable facts about the user and their prior queries. Without it, a multi-hop system re-derives the same context every turn and you pay for it twice.&lt;/p&gt;

&lt;p&gt;The structural difference is the loop back to the planner. Standard RAG has one retrieval pass. Agentic RAG has a loop with a termination condition, and that loop is where both the value and the risk live.&lt;/p&gt;




&lt;h2&gt;
  
  
  What runtime retrieval costs you
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Dimension&lt;/th&gt;
&lt;th&gt;Standard RAG&lt;/th&gt;
&lt;th&gt;Agentic RAG&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Retrieval decision&lt;/td&gt;
&lt;td&gt;Design time&lt;/td&gt;
&lt;td&gt;Runtime&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;LLM calls per query&lt;/td&gt;
&lt;td&gt;One&lt;/td&gt;
&lt;td&gt;One per hop, plus planning&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Latency&lt;/td&gt;
&lt;td&gt;One round trip, tight variance&lt;/td&gt;
&lt;td&gt;Accumulates per hop, long tail&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cost per query&lt;/td&gt;
&lt;td&gt;Flat&lt;/td&gt;
&lt;td&gt;Variable, roughly linear in hops&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Determinism&lt;/td&gt;
&lt;td&gt;High&lt;/td&gt;
&lt;td&gt;Low, the same query can take a different plan&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Debugging&lt;/td&gt;
&lt;td&gt;Inspect the chunks&lt;/td&gt;
&lt;td&gt;Reconstruct the trace&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Eval strategy&lt;/td&gt;
&lt;td&gt;Answer quality on fixed input&lt;/td&gt;
&lt;td&gt;Answer quality and trajectory quality&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Multi-hop questions&lt;/td&gt;
&lt;td&gt;Fails silently&lt;/td&gt;
&lt;td&gt;Handles&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Structured data&lt;/td&gt;
&lt;td&gt;Poor, embeddings flatten schema&lt;/td&gt;
&lt;td&gt;Native, via SQL tools&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Failure mode&lt;/td&gt;
&lt;td&gt;Confident answer from wrong chunks&lt;/td&gt;
&lt;td&gt;Loops, fans out, burns budget&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The determinism row is the one that costs most in practice. Standard RAG failures are boring and reproducible. Agentic RAG failures are interesting, which is a bad property for a production system: the same question asked twice can take different paths and produce different answers, and neither is wrong so much as differently sourced. Reproducibility was doing quiet work in your incident response process, and you give it up when you move the decision to runtime.&lt;/p&gt;




&lt;h2&gt;
  
  
  The sufficiency gate
&lt;/h2&gt;

&lt;p&gt;Before adding another hop, check whether the context you already have is enough to answer, and put a hard ceiling on the case where it isn't. That check does more for a production agentic RAG loop than a better planner does.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;MAX_HOPS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;
&lt;span class="n"&gt;TOKEN_BUDGET&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;20_000&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;agentic_retrieve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tools&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;RetrievalResult&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;plan&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;planner&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;decompose&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;          &lt;span class="c1"&gt;# ReAct-style sub-questions
&lt;/span&gt;    &lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;trace&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;spent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;hop&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;MAX_HOPS&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;gap&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;planner&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;next_gap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;   &lt;span class="c1"&gt;# what's still missing?
&lt;/span&gt;        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;gap&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;break&lt;/span&gt;                            &lt;span class="c1"&gt;# sufficiency gate: stop early
&lt;/span&gt;
        &lt;span class="n"&gt;tool&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;router&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;select&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;gap&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tools&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;     &lt;span class="c1"&gt;# sql | search | timeseries
&lt;/span&gt;        &lt;span class="n"&gt;chunks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;tool&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;invoke&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;gap&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="n"&gt;spent&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nf"&gt;count_tokens&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;chunks&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;spent&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;TOKEN_BUDGET&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;trace&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;halt&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;budget_exceeded&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hop&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
            &lt;span class="k"&gt;break&lt;/span&gt;

        &lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;extend&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;chunks&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;trace&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;tool&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;gap&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;chunks&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;RetrievalResult&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nf"&gt;dedupe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="n"&gt;trace&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;trace&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;                         &lt;span class="c1"&gt;# emit this. always.
&lt;/span&gt;        &lt;span class="n"&gt;exhausted&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;trace&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;MAX_HOPS&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;    &lt;span class="c1"&gt;# flag for review queue
&lt;/span&gt;    &lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;next_gap&lt;/code&gt; returning &lt;code&gt;None&lt;/code&gt; is the sufficiency gate. It lets a single-hop question cost one hop instead of four. Without it, your agentic system pays multi-hop prices on lookup questions, which are most of your traffic, and that shows up on the bill.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;MAX_HOPS&lt;/code&gt; and &lt;code&gt;TOKEN_BUDGET&lt;/code&gt; are not optional. An unbounded retrieval loop against a live SQL tool is a denial-of-service vector pointed at your own warehouse, and a badly worded user question is enough to trigger it.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;trace&lt;/code&gt; is what makes the system debuggable. Emit it on every request, store it next to the answer, and make it queryable. When agentic RAG fails, the answer tells you nothing about why.&lt;/p&gt;




&lt;h2&gt;
  
  
  Where teams get this decision wrong
&lt;/h2&gt;

&lt;p&gt;The most common mistake is adopting agentic RAG for a single-hop corpus. If your knowledge base is a few thousand support articles and users ask article-shaped questions, a planner adds latency and cost to reach the same document standard RAG would have found in one pass. Route on question shape rather than on architectural fashion.&lt;/p&gt;

&lt;p&gt;Skipping the router is close behind. A planner handed eleven tools and no routing heuristic will explore all of them. Constrain the tool set per query class before the planner ever sees it.&lt;/p&gt;

&lt;p&gt;Then there's treating the two architectures as either/or. A classifier in front of both paths usually works better: the cheap single-hop route for lookup questions, the agentic route for questions that decompose. If most of your traffic is lookup, most of your traffic shouldn't be paying for a planner.&lt;/p&gt;

&lt;p&gt;Evaluation is the expensive mistake. In standard RAG, answer quality is a decent proxy for system health. In agentic RAG it isn't, because a correct answer reached through six wasteful hops is a cost and latency problem waiting for your traffic to grow. Track hops per query, tool selection precision, redundant retrieval rate, and how often the sufficiency gate fires.&lt;/p&gt;

&lt;p&gt;Finally, teams forget which argument actually closes the case, and it isn't multi-hop reasoning. Embeddings are a lossy representation of a relational schema. If your answers require joins, aggregations, or filters, no chunking strategy saves you, and you need a tool that speaks SQL.&lt;/p&gt;




&lt;h2&gt;
  
  
  Key takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The difference between the two architectures is control flow, and everything else follows from it. Standard RAG decides how to retrieve at design time; agentic RAG defers that to runtime.&lt;/li&gt;
&lt;li&gt;Standard RAG isn't a legacy pattern. On a homogeneous corpus with single-hop questions it's cheaper, faster, more reproducible, and easier to evaluate.&lt;/li&gt;
&lt;li&gt;A sufficiency gate is what keeps the cost model viable, because it stops the loop early on the ordinary questions that make up most of your traffic.&lt;/li&gt;
&lt;li&gt;Always bound the loop. &lt;code&gt;MAX_HOPS&lt;/code&gt; and a token budget give you a worst case you can name.&lt;/li&gt;
&lt;li&gt;Structured data is the clearest signal to switch. Embeddings flatten schema, so joins and aggregations need a tool that queries the database directly.&lt;/li&gt;
&lt;li&gt;Evaluate the trajectory as well as the answer. A right answer reached the wrong way is a latent production problem.&lt;/li&gt;
&lt;/ul&gt;




</description>
      <category>ai</category>
      <category>rag</category>
      <category>architecture</category>
      <category>agents</category>
    </item>
    <item>
      <title>Separating the Idea, State, and Artifact Planes in Agent Pipelines</title>
      <dc:creator>shakti mishra</dc:creator>
      <pubDate>Sat, 22 Aug 2026 23:17:55 +0000</pubDate>
      <link>https://dev.to/shakti_mishra_308e9f36b5d/separating-the-idea-state-and-artifact-planes-in-agent-pipelines-518g</link>
      <guid>https://dev.to/shakti_mishra_308e9f36b5d/separating-the-idea-state-and-artifact-planes-in-agent-pipelines-518g</guid>
      <description>&lt;h2&gt;
  
  
  The agent worked. The architecture didn't.
&lt;/h2&gt;

&lt;p&gt;This failure mode won't show up in your eval suite.&lt;/p&gt;

&lt;p&gt;An AI architect builds a personal automation pipeline: an agent scouts trending content, pipes ideas into a chat thread, he reacts, things get logged. The agent did its job. It found the trends, wrote them down, and responded when he asked it to.&lt;/p&gt;

&lt;p&gt;He killed it anyway, and not over hallucination or token cost. He killed it because everything lived in "a flat scroll of messages. No structure, no views, no way to see what is in scripting versus what is scheduled." He was spending his entire one-hour creation window scrolling backwards through a Telegram thread, looking for something he'd written the day before.&lt;/p&gt;

&lt;p&gt;The model wasn't the problem. The substrate was, and almost everyone shipping agents today has the same problem, because the default agent UI is a chat window and the default system of record is the transcript.&lt;/p&gt;

&lt;p&gt;If your agent's output lands in a conversation, you've built an append-only log with no schema and no query interface. Retrieval is O(n), and a human eye does the scanning. That works fine in a demo and falls apart somewhere around week three.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why the transcript fails as a system of record
&lt;/h2&gt;

&lt;p&gt;Break a chat log down to its data properties and the problem is obvious:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CHAT TRANSCRIPT AS DATABASE
---------------------------
Schema            none (freeform text)
Primary key       timestamp (not semantic)
Indexes           none
Query interface   Ctrl+F, human eyes
Mutation          impossible (append-only, no UPDATE)
Aggregation       none
Views/filters     none
State transitions untracked
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The row that matters is &lt;code&gt;Mutation: impossible&lt;/code&gt;. Real work has state that &lt;em&gt;changes&lt;/em&gt;: an idea becomes a draft, the draft gets scheduled, the scheduled item ships. In a chat log none of those transitions exist as data. They exist as later messages contradicting earlier ones, and the reader has to reconstruct the current truth by replaying the whole thread.&lt;/p&gt;

&lt;p&gt;That's event sourcing without a projection. You get the event stream and no materialized view.&lt;/p&gt;

&lt;p&gt;It also compounds. Every session starts with context reconstruction: &lt;em&gt;what did I decide? where did I leave off? which of these forty messages is still live?&lt;/em&gt; The human pays that cost every time, and it grows with the length of the thread while the thread's value stays flat.&lt;/p&gt;

&lt;p&gt;You'll know you have the problem when you catch yourself using the agent to search the agent's own output.&lt;/p&gt;




&lt;h2&gt;
  
  
  The fix: three planes, not one thread
&lt;/h2&gt;

&lt;p&gt;The working version of the pipeline separates concerns into three data planes, each with a different write pattern and a different owner.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        ┌──────────────────────────────────────────┐
        │  PLANE 1: IDEA / INTAKE                  │
        │  Google Sheet · append-only              │
        │  Writer: agent (scheduled, unattended)   │
        │  Volume: high · Precision: low           │
        │  Never edited in place                   │
        └───────────────────┬──────────────────────┘
                            │  human selects (the gate)
                            ▼
        ┌──────────────────────────────────────────┐
        │  PLANE 2: STATE / PIPELINE               │
        │  Notion DB · typed records               │
        │  Writer: agent on human instruction      │
        │  Volume: low · Precision: high           │
        │  status ∈ {Idea, Scripting, Filming,     │
        │            Scheduled, Published}         │
        └───────────────────┬──────────────────────┘
                            │  references by ID
                            ▼
        ┌──────────────────────────────────────────┐
        │  PLANE 3: ARTIFACT                       │
        │  Google Docs · Drive · rendered media    │
        │  Writer: human (scripts) + agent (renders)│
        │  Addressed by link from Plane 2          │
        └──────────────────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each plane has a job the other two are bad at.&lt;/p&gt;

&lt;p&gt;Plane 1 optimizes for recall rather than precision. The scheduled scan writes 20+ ideas a day across TikTok, Reels, X and YouTube, each row carrying the trend, a hook, an angle, a caption, hashtags, format notes, and a suggested post time. Most of those rows are garbage, which is fine. It's an intake buffer, and the rule is &lt;em&gt;never curate in place&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;That rule earns its keep. Agent writes are non-deterministic, so if your agent mutates rows in the same table it writes to, you lose the ability to tell "the agent changed its mind" from "I changed my mind" from "the agent silently dropped something." Append-only intake gives you an audit trail for free, and it makes human selection the only path from noise to signal.&lt;/p&gt;

&lt;p&gt;Plane 2 optimizes for queryable state: one typed record per unit of work, with a status enum. A single glance answers what's in scripting, what's waiting to film, and what ships next, which is the question the chat thread could never answer.&lt;/p&gt;

&lt;p&gt;Plane 3 holds the payload. Documents and media are referenced by ID from Plane 2, never inlined into it. That's ordinary normalization, and agent systems break it all the time by pasting entire drafts into chat messages.&lt;/p&gt;

&lt;p&gt;The state machine itself is simple enough to copy:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  Idea ──► Scripting ──► Filming ──► Scheduled ──► Published
   │           │             │
   └───────────┴─────────────┴──► Dropped
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Five states and one escape hatch. That's the whole orchestration model, and both the human and the agent can read it, which matters: an agent that sees &lt;code&gt;status = "Scripting"&lt;/code&gt; can act on it directly. An agent reading a chat thread has to &lt;em&gt;infer&lt;/em&gt; status from prose, and inference is where reliability starts slipping.&lt;/p&gt;




&lt;h2&gt;
  
  
  Splitting the agent into workflow, runner, and schedule
&lt;/h2&gt;

&lt;p&gt;The second architectural idea in the piece is a clean three-way split of what most people mash into a single "agent":&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Component&lt;/th&gt;
&lt;th&gt;Answers&lt;/th&gt;
&lt;th&gt;Analogue&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Workflow&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;em&gt;How&lt;/em&gt; the job is done&lt;/td&gt;
&lt;td&gt;DAG definition / playbook&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Runner&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;em&gt;Who&lt;/em&gt; owns and executes it&lt;/td&gt;
&lt;td&gt;Worker identity + permissions + memory&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Schedule&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;em&gt;When&lt;/em&gt; it fires&lt;/td&gt;
&lt;td&gt;Cron / event trigger&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;If you've ever built data infrastructure, this is Airflow's DAG-vs-worker-vs-scheduler split arriving in the agent world, and the fact that it keeps getting rediscovered independently is a decent signal that it's correct.&lt;/p&gt;

&lt;p&gt;The practical consequence is that each axis varies independently. Same workflow, different runner (dev vs prod credentials). Same runner, different schedule (daily scan vs on-demand). Same schedule, swapped workflow (v1 to v2 of your edit pipeline) without touching the trigger or the identity.&lt;/p&gt;

&lt;p&gt;The monolithic alternative is a chat agent where the how, the who, and the when are tangled together in a prompt you retype every session. You can't version that, and you certainly can't hand it to anyone else.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ENTANGLED (chat agent)
  "hey can you scan trends and put them in my sheet like
   you did last time, you know the format" ──► ???

DECOMPOSED
  Workflow:  trend_scan.v3   (deterministic playbook)
  Runner:    content_bot     (Drive+Notion scopes, memory: voice/topics)
  Schedule:  0 6 * * *       (daily 06:00)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The decomposed version is a config artifact. You can diff it, review it, and roll it back.&lt;/p&gt;




&lt;h2&gt;
  
  
  Skills are portable; runtimes are not
&lt;/h2&gt;

&lt;p&gt;This is the detail with the longest shelf life. The video editing logic (cut to vertical 1080×1920, word-synced captions, motion graphics, brand logos, phone-legible thumbnail) was a Claude Skill wrapping Remotion. When the pipeline moved to a different orchestrator, that logic wasn't rebuilt from scratch. It was ported into a saved Workflow and invoked by a Runner.&lt;/p&gt;

&lt;p&gt;The value was never in the runtime.&lt;/p&gt;

&lt;p&gt;It was in the encoded decision rules: caption style, safe zones, font sizes, brand colors, render steps. Those took work to get right and would be expensive to rediscover. The execution environment around them is commodity infrastructure that churns every eighteen months or so.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;       ┌─────────────────────────────────────┐
       │  DURABLE  (you author this once)    │
       │  • decision rules &amp;amp; checklists       │
       │  • constraints, safe zones, brand    │
       │  • step ordering &amp;amp; failure handling  │
       └──────────────┬──────────────────────┘
                      │ portable
       ┌──────────────▼──────────────────────┐
       │  COMMODITY (swap every ~18 months)  │
       │  • agent runtime / orchestrator      │
       │  • model provider · tool bindings    │
       └─────────────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So write skills as instruction artifacts rather than runtime code. A skill expressed as a markdown playbook with explicit steps, constraints, and decision rules is a text file you can carry anywhere. Bind it hard to one vendor's SDK and you've scheduled a rewrite.&lt;/p&gt;

&lt;p&gt;If you already have Claude Skills, you already have portable assets. They're the durable layer, not vendor lock-in, and every orchestrator (including the one you're using today) is replaceable.&lt;/p&gt;




&lt;h2&gt;
  
  
  Where to put the human: automate the overhead, not the critical path
&lt;/h2&gt;

&lt;p&gt;The pipeline has five stages. Two of them are deliberately not automated:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. Trend scan   AGENT   (scheduled, unattended)
2. Curation     HUMAN   → agent files the selection
3. Scripting    HUMAN   ← agent assists on request
4. Filming      HUMAN   (fully manual, by design)
5. Editing      AGENT   (workflow-invoked)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Automation sits at the ends, intake and post-production, while the human occupies the middle where judgment lives. The stated reason for keeping scripting human is sharp: &lt;em&gt;"the point of the system is not to remove me from the work that is mine."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The engineering framing is Amdahl's law. Total time is critical path plus serial overhead. In a creative or knowledge pipeline the critical path is judgment, and it's irreducible because &lt;em&gt;you&lt;/em&gt; are the value being produced. The serial overhead is everything around it: noticing, logging, filing, linking, formatting, rendering.&lt;/p&gt;

&lt;p&gt;Speed up the overhead and the whole system gets faster. Try to speed up the critical path by automating judgment and you don't get faster output, you get more output that nobody wanted.&lt;/p&gt;

&lt;p&gt;There's a second constraint the piece names explicitly, and it deserves a term: the friction budget. As he puts it: &lt;em&gt;"anything that is not seamless does not get done. If an idea requires me to open six tabs, copy something from one place to another, and remember where I put the draft, it dies."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Treat friction as a hard budget. For a part-time operator with one hour, the budget is near zero: six tabs exceeds it, and the workflow gets abandoned no matter how good the agent is. It's the same reason an accurate internal tool that takes six clicks to reach loses to a rougher one sitting behind a single button. Adoption follows friction more than capability. Most agent projects that "failed" cleared the capability bar and blew the friction budget.&lt;/p&gt;




&lt;h2&gt;
  
  
  What to build on Monday
&lt;/h2&gt;

&lt;p&gt;If you're standing up an agent pipeline, personal or production, the port is mechanical:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Pick a real system of record: anything with a schema, a status field, and views. A database, a project tracker, even a spreadsheet. Not the chat transcript.&lt;/li&gt;
&lt;li&gt;Split intake from state. Agents write to a high-volume, append-only intake table. Nothing moves to the state table without passing a gate, either human approval or a deterministic filter. Never let an unattended agent mutate your source of truth in place.&lt;/li&gt;
&lt;li&gt;Model the states explicitly, as a short enum both the human and the agent can read. If your agent has to infer status from prose, add the field.&lt;/li&gt;
&lt;li&gt;Decompose how, who, and when into workflow, runner, and schedule, versioned separately. A retyped prompt is not an architecture.&lt;/li&gt;
&lt;li&gt;Write skills as portable instruction artifacts. Playbooks in text, loosely bound to whatever runtime is current. Assume the runtime churns.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  6. Audit your friction budget. Count the tabs and copy-paste steps between "I have an idea" and "I'm doing the work." If it's more than two, the workflow will be abandoned, and the model won't be the reason.
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Key Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A chat transcript is an append-only log with no schema, no index, and no UPDATE, so it can't serve as a system of record for stateful work, however good the agent writing to it is.&lt;/li&gt;
&lt;li&gt;Separate the idea plane, the state plane, and the artifact plane. Intake optimizes for recall and stays append-only, state optimizes for queryability and stays typed, and artifacts are referenced by ID.&lt;/li&gt;
&lt;li&gt;Split the agent into workflow (how), runner (who), and schedule (when) so each axis versions and rolls back independently. Airflow settled on the same split a decade ago.&lt;/li&gt;
&lt;li&gt;Skills are the durable layer and runtimes are commodity. Encode decision rules as portable instruction artifacts so an orchestrator swap is a port rather than a rewrite.&lt;/li&gt;
&lt;li&gt;Automate the serial overhead, not the critical path. Judgment is where the human is the product. Noticing, filing, and rendering are where the hours leak.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  - Adoption follows friction more than capability. A workflow that exceeds the user's friction budget dies regardless of model quality.
&lt;/h2&gt;

&lt;h2&gt;
  
  
  The question worth arguing about
&lt;/h2&gt;

&lt;p&gt;Every major agent product is converging on the same interface: a chat box. But the moment an agent's work has state that outlives a session, the chat box stops being a UI and starts being a bad database.&lt;/p&gt;

&lt;p&gt;So which is it? Is chat a transitional interface we'll look back on the way we look back on command-line-only databases, with agents eventually shipping real structured front ends? Or is the transcript fine, and the fix is just better memory and retrieval bolted onto the thread?&lt;/p&gt;

&lt;p&gt;If you've killed an agent that technically worked, what made you stop using it? I'd bet more of those stories are about state and friction than about the model.&lt;/p&gt;




</description>
      <category>ai</category>
      <category>agents</category>
      <category>architecture</category>
      <category>automation</category>
    </item>
    <item>
      <title>Graph Engineering Explained: The Missing Fifth Layer of AI Agent Architecture</title>
      <dc:creator>shakti mishra</dc:creator>
      <pubDate>Sun, 16 Aug 2026 20:37:46 +0000</pubDate>
      <link>https://dev.to/shakti_mishra_308e9f36b5d/graph-engineering-explained-the-missing-fifth-layer-of-ai-agent-architecture-5ab</link>
      <guid>https://dev.to/shakti_mishra_308e9f36b5d/graph-engineering-explained-the-missing-fifth-layer-of-ai-agent-architecture-5ab</guid>
      <description>&lt;ul&gt;
&lt;li&gt;
Every "my agent isn't working" postmortem starts the same way: someone rewrites the prompt. Adds a constraint. Adds an example. Ships it again. Three iterations later the agent still can't hold up in production, and the team is quietly out of ideas — because the prompt was never the layer that broke.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are five control layers standing between a raw model call and a system you can actually trust with a business outcome: prompt, context, harness, loop, and graph. Most teams staff and instrument only the first one or two. The failures that show up in production — wrong tool called, same mistake retried forever, output routed to the wrong reviewer — live almost entirely in the layers nobody named.&lt;/p&gt;

&lt;p&gt;Graph engineering is the newest and least understood of the five: it's the layer that decides which component runs next, when agents work in parallel versus in sequence, and where a human has to sign off before anything expensive or irreversible happens. This piece breaks down all five layers, works through a single production failure end to end, and shows where evals fit as the measurement system running through every one of them.&lt;/p&gt;

&lt;h2&gt;
  
  
  The mental model: five rings around the model
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;MODEL CALL  =  prompt + context
AGENT       =  model call + harness + loop
SYSTEM      =  agents + deterministic steps + humans, connected by a graph
EVALS       =  evidence that every layer actually works
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Prompt and context sit closest to the model. Harness and loop turn a model call into something that can act and recover. Graph turns a collection of agents, functions, and human checkpoints into a coordinated system. None of these layers replace each other — they're concentric controls, not pipeline stages, and a production agent uses all five simultaneously. The weakest layer sets the ceiling on how reliable the whole thing is, no matter how good the other four are.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Layer&lt;/th&gt;
&lt;th&gt;Controls&lt;/th&gt;
&lt;th&gt;Fails as&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Prompt&lt;/td&gt;
&lt;td&gt;Role, goal, constraints, output contract&lt;/td&gt;
&lt;td&gt;Ambiguous instructions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Context&lt;/td&gt;
&lt;td&gt;What reaches the window: docs, history, tool results&lt;/td&gt;
&lt;td&gt;Missing or noisy evidence&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Harness&lt;/td&gt;
&lt;td&gt;Tools, file/shell access, sandboxing, permissions&lt;/td&gt;
&lt;td&gt;Overprivileged or unsafe actions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Loop&lt;/td&gt;
&lt;td&gt;Retry policy, validators, stop conditions, escalation&lt;/td&gt;
&lt;td&gt;Infinite retries on the same mistake&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Graph&lt;/td&gt;
&lt;td&gt;Routing, parallelism, recovery paths, human gates&lt;/td&gt;
&lt;td&gt;Work reaching the wrong next step&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  A production failure, diagnosed layer by layer
&lt;/h2&gt;

&lt;p&gt;Consider a coding agent built to fix low-risk defects in an internal payments service. The prompt is reasonable: inspect the issue, avoid unrelated changes, run the tests, return a PR summary. On a clean sample repo, it works. On the real repository, it falls apart in four distinct ways:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;It misses an architecture decision buried in the docs — a &lt;strong&gt;context&lt;/strong&gt; failure.&lt;/li&gt;
&lt;li&gt;It runs a shell command with a broader scope than intended — a &lt;strong&gt;harness&lt;/strong&gt; failure.&lt;/li&gt;
&lt;li&gt;It retries the same failing test without changing its hypothesis — a &lt;strong&gt;loop&lt;/strong&gt; failure.&lt;/li&gt;
&lt;li&gt;It sends the pull request down the wrong review path — a &lt;strong&gt;graph&lt;/strong&gt; failure.
The natural instinct is to ask "how do we improve the prompt?" That's the wrong question. Only one of these four failures traces back to the instruction layer — and it isn't the one that caused the damage. Each failure needs a fix in the layer that actually owns it, not a paragraph bolted onto the system prompt.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Layer 1 — Prompt: steers one model call
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Analyze the reported defect and propose the smallest safe fix.
Do not change unrelated behavior.
Return the root cause, files changed, test evidence, and residual risk.
Stop and ask for approval if the fix changes an external contract.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The unit being optimized here is a single model interaction. A stronger prompt reduces ambiguity, but it cannot supply a missing design document, restrict a dangerous tool, or decide who reviews the output. In an agent system, the prompt is the steering wheel — not the car.&lt;/p&gt;

&lt;h3&gt;
  
  
  Layer 2 — Context: what the model can actually see
&lt;/h3&gt;

&lt;p&gt;Ask a model to summarize risk in an 80-page contract. Dumping the whole document into the window and retrieving the liability, indemnification, termination, and data-use clauses (plus the org's risk policy) produce two very different answers from the &lt;em&gt;same prompt&lt;/em&gt;. The instruction didn't change — the evidence available to answer it did. For the coding agent, the missing architecture decision is a retrieval problem. Rewording the prompt might paper over one test case; fixing context assembly fixes the whole class of failure.&lt;/p&gt;

&lt;h3&gt;
  
  
  Layer 3 — Harness: the runtime envelope
&lt;/h3&gt;

&lt;p&gt;The harness is everything around the model call: tools, file access, shell access, MCP connections, sandboxing, permissions, timeouts, logging, approval boundaries. The model can decide "I need to run the tests" — the harness decides whether that's even possible, which commands are allowlisted, which directory is visible, and what gets recorded. MCP standardizes &lt;em&gt;how&lt;/em&gt; an agent connects to tools; it does not decide that an agent deserves production write access. Identity, least privilege, and approval policy still belong to the host and its surrounding control plane. This is usually the first layer a security team asks about, and it's exactly where the broad shell command should have been caught.&lt;/p&gt;

&lt;h3&gt;
  
  
  Layer 4 — Loop: the retry contract
&lt;/h3&gt;

&lt;p&gt;Loop engineering owns the cycle — act, observe, evaluate, adjust, repeat — plus retry policy, validators, completion criteria, budgets, and escalation rules. It's a distinct concern from the harness:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Harness asks:&lt;/strong&gt; Can the agent execute the test, in which sandbox, with what timeout?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Loop asks:&lt;/strong&gt; Does a failed test trigger another attempt, what has to change before retrying, how many attempts are allowed, and what counts as done?
You can have a perfectly sandboxed, fully logged harness and still watch an agent burn its entire budget retrying the identical failed fix. The coding agent's repeated test failure needed a new-hypothesis requirement and a retry cap — not broader filesystem access.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Layer 5 — Graph: coordinating the system
&lt;/h3&gt;

&lt;p&gt;Graph Engineering is the operational paradigm for building complex AI agents and multi-agent systems by representing their workflows as explicit stateful graphs rather than relying on unstructured, single-agent loops or linear prompt chains. Instead of letting an LLM autonomously decide every execution step in an unpredictable loop ("prompt and pray"), graph engineering imposes architectural boundaries. It treats the overall task as a state machine where nodes execute discrete logic (LLM calls, tool execution, validation), edges direct routing decisions, and a schema-defined state persists throughout the lifecycle.&lt;/p&gt;

&lt;p&gt;Graph engineering controls the topology of the whole workflow. Nodes can be agents, deterministic functions, evaluators, or human gates; edges define sequencing, routing, parallel branches, recovery paths, and where the loops from layer 4 actually live. Loop asks "how does this one agent keep working?" Graph asks "which component runs next, and how does the system coordinate?"&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;flowchart LR
    A[Triage] --&amp;gt; B[Planner]
    B --&amp;gt; C[Coding Agent]
    C --&amp;gt; D[Deterministic Tests]
    D --&amp;gt;|pass| E[Security Reviewer]
    D --&amp;gt;|fail| C
    E --&amp;gt; F{Human Approval}
    F --&amp;gt;|approved| G[Merge]
    F --&amp;gt;|rejected| B
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's the fix for the coding agent's fourth failure: an explicit route from code change to tests, to security review, to human approval before merge — instead of an implicit hope that the right person eventually sees it.&lt;/p&gt;

&lt;p&gt;LangGraph frames itself as a low-level orchestration runtime for exactly this: mixing deterministic steps with model-driven steps while preserving state, durable execution, and human interrupts. The useful idea isn't "draw boxes and arrows" — it's splitting responsibilities that a single overloaded chat session was quietly doing all at once (plan, research, write, and approve its own work), and keeping a human where mistakes get expensive.&lt;/p&gt;

&lt;p&gt;Graph complexity isn't free, and the data backs that up: Anthropic reported its multi-agent research system beat a single-agent setup by &lt;strong&gt;90.2%&lt;/strong&gt; on an internal breadth-first research evaluation — but the multi-agent runs consumed roughly &lt;strong&gt;15x&lt;/strong&gt; the tokens of a normal chat interaction. That number is specific to Anthropic's research workload, not a universal multiplier, but it captures the trade-off precisely: graphs earn their complexity only when the task's value and parallelism justify the bill. Reach for a graph because the workflow genuinely branches, not because orchestration frameworks are the interesting part of the stack right now.&lt;/p&gt;

&lt;h2&gt;
  
  
  Core Pillars of Graph Engineering
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; [ Shared Typed State Object (e.g., Pydantic / TypedDict) ]
                         |
  +----------------------+----------------------+
  |                                             |
  v                                             v
[ Node: LLM / Tool / Task ] ---------&amp;gt; [ Conditional Edge ]
  |                                             |
  +----------------------+----------------------+
                         |
                         v
                [ Node: Validator / Human Checkpoint ]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  1. State Management
&lt;/h3&gt;

&lt;p&gt;The explicit data structure passed through every execution step in the graph.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Typed Schemas:&lt;/strong&gt; Defines exact variables, tool outputs, message histories, and system metadata.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reducers:&lt;/strong&gt; Functions that determine how state field updates from parallel or sequential steps are merged (e.g., appending items to a list vs. overwriting a variable).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Nodes (Units of Execution)
&lt;/h3&gt;

&lt;p&gt;Self-contained, bounded steps inside the system. A node takes the current state, performs logic, and returns a state patch.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Agentic Nodes:&lt;/strong&gt; Specialized LLM calls tailored to a single role (e.g., Researcher, Refiner, Evaluator).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Deterministic Nodes:&lt;/strong&gt; Standard code executions (API calls, data parsers, formatting utilities).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Validation Nodes:&lt;/strong&gt; Output parsers and schema checkers that evaluate prior steps.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Edges (Control Flow &amp;amp; Routing)
&lt;/h3&gt;

&lt;p&gt;Rules that connect nodes and govern system transitions.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Fixed Edges:&lt;/strong&gt; Direct, deterministic routing from Node A to Node B.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Conditional Edges:&lt;/strong&gt; Dynamic routing based on LLM outputs or state evaluation (e.g., if confidence &amp;lt; 0.8, route to Human Review; else route to Execution).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cyclic Paths:&lt;/strong&gt; Loops designed for iterative refinement (e.g., Draft -&amp;gt; Evaluate -&amp;gt; Revise -&amp;gt; Evaluate).&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The concern that cuts across all five: evals
&lt;/h2&gt;

&lt;p&gt;There's a sixth thread running through every layer, and it isn't a sixth ring — it's the measurement system for the other five.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Does the &lt;strong&gt;prompt&lt;/strong&gt; reliably produce instruction-following output?&lt;/li&gt;
&lt;li&gt;Did &lt;strong&gt;context&lt;/strong&gt; retrieval include the decisive evidence, or silently omit it?&lt;/li&gt;
&lt;li&gt;Did the &lt;strong&gt;harness&lt;/strong&gt; allow the necessary tool and deny the dangerous one?&lt;/li&gt;
&lt;li&gt;Did the &lt;strong&gt;loop&lt;/strong&gt; stop for the right reason, or exhaust its budget on a dead end?&lt;/li&gt;
&lt;li&gt;Did the &lt;strong&gt;graph&lt;/strong&gt; route the risky case to a human, or let it fall through?
OpenAI's own evaluation guidance follows the same discipline regardless of layer: define the desired behavior, run representative test inputs against explicit criteria, analyze results, iterate. Evals aren't a separate architectural concern sitting outside the five layers — they're the evidence that each one is doing its job.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Three honest caveats
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;The vocabulary isn't equally mature.&lt;/strong&gt; Prompt engineering and context engineering are established industry terms. "Agent harness" is a real, recognized category. Loop engineering and graph engineering are newer labels for things practitioners have also called agent loops, workflows, and orchestration — useful names, not settled ones.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The boundaries leak.&lt;/strong&gt; Memory can plausibly belong to context, harness, or loop-level runtime state. Verification can live inside a tool boundary, a retry loop, or its own graph node. These are five &lt;em&gt;concerns&lt;/em&gt;, not five cleanly separable software components — don't force a rigid file-by-file mapping onto them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;This isn't a build order.&lt;/strong&gt; In practice, the graph (the workflow shape) tends to get sketched first, loops and control boundaries get defined next, and prompts get tuned last. Think concentric controls around the model, not a waterfall you execute top to bottom.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Five control layers sit between a raw model call and a trustworthy system: prompt (steers), context (informs), harness (constrains), loop (persists), graph (coordinates) — and the weakest one sets the reliability ceiling for the whole system.&lt;/li&gt;
&lt;li&gt;Diagnose failures by layer, not by rewording the prompt. A misrouted PR, an infinite retry, and an overprivileged shell command are three different bugs in three different layers, and "improve the prompt" fixes none of them.&lt;/li&gt;
&lt;li&gt;Graph engineering is topology, not decoration: nodes are agents, deterministic steps, or human gates; edges define sequencing, parallelism, recovery, and where a human has to sign off.&lt;/li&gt;
&lt;li&gt;Multi-agent orchestration is a cost trade-off, not a free upgrade — Anthropic's own research system needed ~15x the tokens to get a 90.2% quality gain, and that ratio should inform whether your workflow actually needs a graph.&lt;/li&gt;
&lt;li&gt;Evals aren't a separate layer — they're the proof that each of the other five is doing what you think it's doing, and without them "the AI was weird" is the best diagnosis your team will ever get.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Closing CTA
&lt;/h2&gt;

&lt;p&gt;Before you rewrite another prompt: which of the other four layers — context, harness, loop, or graph — is actually the weakest link in your system, and how would you know?&lt;/p&gt;




</description>
      <category>ai</category>
      <category>agents</category>
      <category>architecture</category>
      <category>langchain</category>
    </item>
    <item>
      <title>MCP vs. Agent Skills: A Decision Framework for Context Engineering</title>
      <dc:creator>shakti mishra</dc:creator>
      <pubDate>Wed, 22 Jul 2026 01:42:31 +0000</pubDate>
      <link>https://dev.to/shakti_mishra_308e9f36b5d/mcp-vs-agent-skills-a-decision-framework-for-context-engineering-ljf</link>
      <guid>https://dev.to/shakti_mishra_308e9f36b5d/mcp-vs-agent-skills-a-decision-framework-for-context-engineering-ljf</guid>
      <description>&lt;h2&gt;
  
  
  MCP vs. Agent Skills: What's the Difference and Which Do You Need?
&lt;/h2&gt;

&lt;p&gt;As AI agents evolve beyond basic chat interfaces into fully autonomous systems, developers keep hitting the same architectural decision: how do we actually extend what an agent can do?&lt;/p&gt;

&lt;p&gt;Two concepts dominate that conversation right now — &lt;strong&gt;Model Context Protocol (MCP)&lt;/strong&gt; and &lt;strong&gt;AI Agent Skills (&lt;code&gt;SKILL.md&lt;/code&gt;)&lt;/strong&gt; — and they're routinely discussed as if they're competing options. They aren't. They solve two different problems that only look similar from a distance, and picking the wrong one for the job is one of the more common ways teams burn a sprint building an agent that's either disconnected from reality or has no idea what to do once it's connected.&lt;/p&gt;

&lt;p&gt;Here's the actual distinction, how each one works under the hood, and a framework for knowing which one — or both — your next agent build actually needs.&lt;/p&gt;




&lt;h2&gt;
  
  
  The core concept: a badge versus a playbook
&lt;/h2&gt;

&lt;p&gt;Imagine hiring a new developer for your team:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;MCP&lt;/strong&gt; is the &lt;strong&gt;interface that lets them connect&lt;/strong&gt; to your databases, Slack channels, GitHub repos, and cloud infrastructure. The actual access is whatever credential is behind that connection; MCP just standardizes how the agent calls it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AI Agent Skills&lt;/strong&gt; are their &lt;strong&gt;Standard Operating Procedures&lt;/strong&gt;. It's the playbook that tells them &lt;em&gt;how&lt;/em&gt; your team formats code, writes pull requests, or triages production incidents.
An interface without a playbook gets you a new hire who can technically reach every system but has no idea how your team actually wants things done — so they improvise, inconsistently, every time. A playbook without any system access gets you someone who knows exactly what to do but can't touch anything. Production-grade agents need both, and knowing which gap you're actually looking at is what keeps you from reaching for the wrong fix.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                    "How do I extend this agent?"
                                │
              ┌──────────────────┴──────────────────┐
              │                                      │
     Needs access to a                     Needs to follow a
     live external system                  repeatable procedure
              │                                      │
              ▼                                      ▼
      ┌───────────────┐                    ┌───────────────────┐
      │      MCP      │                    │   Agent Skills    │
      │ (interface)   │                    │   (the playbook)  │
      └───────────────┘                    └───────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What is MCP (Model Context Protocol)?
&lt;/h2&gt;

&lt;p&gt;MCP is an open standard designed to standardize how LLMs connect to external tools, databases, and APIs.&lt;/p&gt;

&lt;p&gt;Before MCP, connecting an agent to a system like Postgres or GitHub meant custom API integrations or a bespoke function-calling schema per provider. Every new tool meant a new adapter; every new model meant rewriting that adapter to match whatever shape that provider's function-calling API expected. MCP replaces that with a universal bridge: build the connection once, as an MCP server, and any MCP-compatible client can use it without provider-specific glue code.&lt;/p&gt;

&lt;h3&gt;
  
  
  How it works
&lt;/h3&gt;

&lt;p&gt;MCP runs on a client-server architecture over JSON-RPC:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌────────────┐        MCP (JSON-RPC)        ┌──────────────────┐
│  AI Agent  │ ◄──────────────────────────► │  MCP Server      │
│  (client)  │                              │ (e.g. GitHub,    │
│            │                              │  Postgres, Slack)│
└────────────┘                              └──────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An MCP server exposes three primitives to any connected client:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Resources&lt;/strong&gt; — structured, read-only data the model can pull into context (a file, a database row, a ticket)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tools&lt;/strong&gt; — functions the model can actually invoke, with side effects (create a PR, run a query, send a message)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Prompts&lt;/strong&gt; — reusable, parameterized prompt templates the server offers to the client
A minimal client config for connecting an agent to a GitHub MCP server:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"mcpServers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"github"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"npx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"args"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"-y"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"@modelcontextprotocol/server-github"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"env"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"GITHUB_TOKEN"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"your_token_here"&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once connected, the agent can list open issues, read a file from a repo, or open a pull request — not because it memorized GitHub's REST API, but because the MCP server translated GitHub's API surface into a standard interface the agent already knows how to speak. Worth noting: the actual permission boundary here is &lt;code&gt;GITHUB_TOKEN&lt;/code&gt;, not the MCP layer itself — MCP standardized the calling convention, and whatever that token is scoped to do is what the agent can do.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MCP is the right layer when the problem is access to live, changing state&lt;/strong&gt;: current inventory counts, today's support tickets, a database that gets written to every minute. That data can't be baked into a prompt or a static file, because it's stale the moment you write it down.&lt;/p&gt;

&lt;h2&gt;
  
  
  What are AI Agent Skills?
&lt;/h2&gt;

&lt;p&gt;If MCP is about &lt;em&gt;connecting&lt;/em&gt; to systems, Skills are about &lt;em&gt;encoding expertise&lt;/em&gt;. A Skill is a folder — typically a &lt;code&gt;SKILL.md&lt;/code&gt; file plus optional scripts, templates, or reference documents — that teaches an agent how to perform a specific, repeatable task the way your team wants it done.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="nn"&gt;---&lt;/span&gt;
&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;pr-review-checklist&lt;/span&gt;
&lt;span class="na"&gt;description&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Use when reviewing a pull request before approval. Covers this team's standards for tests, security, and rollback safety.&lt;/span&gt;
&lt;span class="nn"&gt;---&lt;/span&gt;

&lt;span class="gh"&gt;# PR Review Checklist&lt;/span&gt;

Before approving, verify:
&lt;span class="p"&gt;1.&lt;/span&gt; Tests cover the new/changed logic, not just the happy path
&lt;span class="p"&gt;2.&lt;/span&gt; No secrets or credentials in the diff
&lt;span class="p"&gt;3.&lt;/span&gt; Migration steps are documented if the schema changed
&lt;span class="p"&gt;4.&lt;/span&gt; There's a rollback plan if this touches a production data path
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  How it works: progressive disclosure
&lt;/h3&gt;

&lt;p&gt;The architectural idea behind Skills is progressive disclosure. An agent doesn't load every Skill's full content into context at all times — that would burn tokens on procedures it isn't currently using.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Always in context:              Loaded only on demand:
┌─────────────────────┐         ┌──────────────────────────┐
│ pr-review: description │  ───► │ Full SKILL.md body      │
│ triage: description    │       │ + bundled scripts/      │
│ formatting: description│       │   templates, only when  │
└─────────────────────┘          │ the task actually matches│
                                 └──────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Only the name and description stay resident by default — a line or two each. When a task matches a Skill's description, the full body loads. If the Skill references bundled scripts, those load only when actually needed. That's what makes Skills cheap to accumulate: dozens of them can sit around — commit conventions, an incident-triage runbook, a data-visualization style guide — without a standing context-window tax for the ones not currently in use.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Skills are the right layer when the problem is repeatable procedure or expertise&lt;/strong&gt;: a style guide, a checklist, a domain-specific workflow. A Skill that's pure prose is genuinely static — it only changes when someone edits it. A Skill that bundles a script or calls tools on the agent's behalf is executable code riding along with a markdown file, and it's worth reviewing with the same rigor as any other code change: ownership, version, and what permissions it actually exercises.&lt;/p&gt;

&lt;h2&gt;
  
  
  MCP vs. Skills: the key differences
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;MCP&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Agent Skills&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Solves&lt;/td&gt;
&lt;td&gt;Access to external systems and live data&lt;/td&gt;
&lt;td&gt;Encoding repeatable procedures and expertise&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;What it actually controls&lt;/td&gt;
&lt;td&gt;The calling convention — permission comes from the credential behind it&lt;/td&gt;
&lt;td&gt;The agent's behavior; bundled scripts mean real code execution&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Requires infrastructure&lt;/td&gt;
&lt;td&gt;Yes — a running server, auth, network calls&lt;/td&gt;
&lt;td&gt;No — just files in a repo or agent config&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Data/artifact freshness&lt;/td&gt;
&lt;td&gt;The data fetched through it is live and dynamic&lt;/td&gt;
&lt;td&gt;The Skill file itself is static prose, or executable if it bundles scripts&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Context cost&lt;/td&gt;
&lt;td&gt;Tool/resource schemas loaded as needed&lt;/td&gt;
&lt;td&gt;Name + description only, until matched&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Typical use case&lt;/td&gt;
&lt;td&gt;Query a database, call an API, send a message&lt;/td&gt;
&lt;td&gt;Follow a style guide, run a checklist, format output consistently&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Portability&lt;/td&gt;
&lt;td&gt;Tied to the system it connects to&lt;/td&gt;
&lt;td&gt;A folder of files — copy it anywhere (though bundled scripts still carry their own assumptions)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  They aren't competitors — they work together
&lt;/h2&gt;

&lt;p&gt;The most common mistake is treating this as either/or. In production, the strongest agents use both, for different halves of the same job.&lt;/p&gt;

&lt;p&gt;Take a support agent handling refund requests:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;MCP servers&lt;/strong&gt; give it live access to Stripe (the actual charge), Zendesk (the actual ticket), and the order database (actual fulfillment status).&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;Skill&lt;/strong&gt; gives it your team's actual refund policy: which situations qualify for a full refund vs. store credit, what tone to use, when to escalate to a human instead of resolving automatically.
Strip out the Skill and the agent has perfect system access but no policy — it improvises, inconsistently, every time. Strip out MCP and it knows the policy perfectly but can't verify whether the charge even went through. And when both are wired together, it's worth making sure the Skill's conclusion doesn't directly trigger the MCP write with no review step in between — the policy decision and the action it authorizes are worth keeping separately inspectable.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌───────────────────────────────────────────────────────┐
│ Support Agent                                         │
│                                                       │
│ Skill: "refund-policy"        MCP: Stripe, Zendesk,   │
│ (how to decide, what to say)   order DB (what's true) │
│         │                              │              │
│         └──────────────┬───────────────┘              │
│                         ▼                             │
│          Grounded, policy-correct refund decision     │
└───────────────────────────────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  A decision framework: which do you actually need?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Does this task need information or actions from a live, external system?&lt;/strong&gt; A database that changes, an API that has to be called, a message that has to be sent — that's MCP territory.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Does this task need to be done the same specific way every time, based on knowledge that doesn't come from an external system?&lt;/strong&gt; A formatting convention, a checklist, a domain-specific procedure — that's a Skill.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Does it need both?&lt;/strong&gt; Most real production agents do. Answering system access and procedural knowledge as two separate questions is what keeps the architecture clean instead of cramming everything into one oversized prompt.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;MCP standardizes the &lt;em&gt;calling convention&lt;/em&gt;, not permissions — the actual access boundary is the credential behind the MCP server, not the protocol itself.&lt;/li&gt;
&lt;li&gt;Agent Skills standardize &lt;em&gt;knowledge&lt;/em&gt; — they package repeatable procedures into files an agent loads only when relevant, via progressive disclosure. Pure-prose Skills are static; Skills that bundle scripts are executable code and worth reviewing as such.&lt;/li&gt;
&lt;li&gt;MCP requires running infrastructure (a server, auth, a network connection); Skills are just files — no infrastructure required, and portable, though a bundled script's assumptions travel with it.&lt;/li&gt;
&lt;li&gt;The two solve different halves of the same problem: the strongest production agents combine both, Skills for the "how," MCP for "what's actually true right now."&lt;/li&gt;
&lt;li&gt;The fastest way to pick correctly: ask whether the task needs live external state (MCP), repeatable procedure (Skills), or both — most real agents need both.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Closing CTA
&lt;/h2&gt;

&lt;p&gt;If you're building an agent right now, take an honest inventory of what it's actually missing: is it fumbling because it can't reach a system it needs, or because it can reach everything but has no consistent playbook for what to do once it's there? Those are two different fixes, and reaching for the wrong one is the fastest way to burn a sprint on the wrong problem. What's your agent stack missing — access, procedure, or both?&lt;/p&gt;

</description>
      <category>ai</category>
      <category>architecture</category>
      <category>mcp</category>
      <category>softwaredevelopment</category>
    </item>
    <item>
      <title>Loop Engineering: The Six-Layer Architecture Behind Self-Improving Agents</title>
      <dc:creator>shakti mishra</dc:creator>
      <pubDate>Sun, 12 Jul 2026 20:39:06 +0000</pubDate>
      <link>https://dev.to/shakti_mishra_308e9f36b5d/loop-engineering-the-six-layer-architecture-behind-self-improving-agents-9m4</link>
      <guid>https://dev.to/shakti_mishra_308e9f36b5d/loop-engineering-the-six-layer-architecture-behind-self-improving-agents-9m4</guid>
      <description>&lt;h2&gt;
  
  
  Loop Engineering: The Six Architectural Layers That Separate Self-Improving Agents From Expensive Function Calls
&lt;/h2&gt;

&lt;p&gt;Most AI agents in production today are glorified function calls. They take an input, run inference, produce an output, and forget everything the moment the response streams back. Ship one on Monday, and it's exactly as smart on Friday six weeks later as it was on day one — same edge cases, same wrong answers, same manual overrides eating the ROI you promised leadership.&lt;/p&gt;

&lt;p&gt;There's a term circulating in the agent-building community for the architectural fix to this: &lt;strong&gt;loop engineering&lt;/strong&gt;. It's not a new model, a framework you &lt;code&gt;pip install&lt;/code&gt;, or a prompt technique. It's a way of thinking about the difference between a system that answers and a system that compounds. &lt;/p&gt;

&lt;p&gt;If you're running agents in production and they've stalled, this is almost certainly why.&lt;/p&gt;

&lt;h2&gt;
  
  
  The enterprise pain point, concretely
&lt;/h2&gt;

&lt;p&gt;Picture a claims-triage agent at a mid-sized insurance company. It reads incoming claims, classifies them, pulls the relevant policy, and drafts a recommendation for a human adjuster.&lt;/p&gt;

&lt;p&gt;Launch day: 60% of routine claims handled without escalation. Leadership is thrilled.&lt;/p&gt;

&lt;p&gt;Six weeks later: still 60%. The same ambiguous policy clauses get misread the same way, every Monday. Adjusters start double-checking everything, and the time savings evaporate.&lt;/p&gt;

&lt;p&gt;The diagnosis isn't the model. It's the architecture. This is an &lt;strong&gt;open-loop system&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Input → Process → Output → (stop)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Nothing flows back. The agent has no way to notice it was wrong, no way to learn from the adjuster's correction, no memory of last week's mistake. It's a very expensive function call.&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;closed-loop system&lt;/strong&gt; looks like this instead:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Input → Process → Output → Feedback → Improve → (back to Input)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That second arrow — the one that bends back to the start — is the entire game. But it isn't magic. People talk about self-improving agents as if you sprinkle a feedback step on top and intelligence emerges. It doesn't work that way. The loop is held together by six real architectural decisions, each with real trade-offs.&lt;/p&gt;

&lt;h2&gt;
  
  
  The six layers
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;flowchart LR
    A[Automations&amp;lt;br/&amp;gt;trigger layer] --&amp;gt; B[Worktrees&amp;lt;br/&amp;gt;parallel execution]
    B --&amp;gt; C[Skills&amp;lt;br/&amp;gt;procedural memory]
    C --&amp;gt; D[Connectors&amp;lt;br/&amp;gt;real-world links]
    D --&amp;gt; E[Sub-agents&amp;lt;br/&amp;gt;validation layer]
    E --&amp;gt; F[Memory&amp;lt;br/&amp;gt;state layer]
    F -.feedback.-&amp;gt; A
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Layer 1 — Automations: the trigger layer
&lt;/h3&gt;

&lt;p&gt;A self-improving system needs to start without you. Automations initiate workflows based on time, events, or system conditions — an email arrives, a database row updates, a claim lands in the queue.&lt;/p&gt;

&lt;p&gt;This is the shift from "I asked it" to "it noticed and started on its own." An agent you have to invoke is a tool. An agent that responds to the world is a system.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The catch:&lt;/strong&gt; triggers are where runaway loops are born. An event-driven agent that triggers another event can cascade. Before wiring automations, define the kill switch and the rate limit first. A loop that starts itself must also be a loop you can stop.&lt;/p&gt;

&lt;h3&gt;
  
  
  Layer 2 — Worktrees: the parallel execution layer
&lt;/h3&gt;

&lt;p&gt;Once work starts itself, you hit a throughput wall. One agent processing one task at a time doesn't scale to enterprise volume.&lt;/p&gt;

&lt;p&gt;The name borrows from git's worktree concept — the same one coding agents already use — where multiple branches exist side by side without stepping on each other. Applied to agents, it means multiple instances execute independently across isolated branches, with three properties that matter:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Task isolation&lt;/strong&gt; — branches don't interfere with each other, so one agent's work can't corrupt another's.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Concurrent processing&lt;/strong&gt; — speed improves without collision risk.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Independent state&lt;/strong&gt; — each branch carries its own context.
The common mistake: scaling vertically first (throwing a bigger model at a serial pipeline) when the real constraint is concurrency. Worktrees solve that at the architecture layer, not the model layer.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Layer 3 — Skills: the procedural memory layer
&lt;/h3&gt;

&lt;p&gt;This is where the loop starts to feel intelligent. Skills are reusable units of logic — the "how to do this" an agent shouldn't have to rediscover on every run. A skill is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Step-by-step&lt;/strong&gt; — an execution pattern that improves reasoning across workflows&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Modular&lt;/strong&gt; — plug-and-play, so agents adapt faster&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reusable&lt;/strong&gt; — written once, applied everywhere it fits
Picture a skill pool: code understanding, data analysis, web search, summarization, database queries. The agent core combines the right skills per task — a triage claim needs policy lookup plus summarization; an appeal needs document comparison plus precedent search. Same pool, different combinations.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The payoff: you stop stuffing every instruction into the prompt and instead give the agent a library of capabilities it composes on demand. Prompts get shorter, behavior gets more reliable, and the system gets cheaper to maintain.&lt;/p&gt;

&lt;h3&gt;
  
  
  Layer 4 — Connectors: the real-world links layer
&lt;/h3&gt;

&lt;p&gt;An agent reasoning in isolation is a chatbot. An agent that touches real systems is infrastructure. Connectors are the links out:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;APIs&lt;/strong&gt; — REST, GraphQL, custom endpoints for external data and actions&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data and databases&lt;/strong&gt; — SQL, NoSQL, cloud storage for persistence&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tools and protocols&lt;/strong&gt; — MCP servers, CLI commands, web search, enterprise systems
"What does the policy say?" is a retrieval question. "Flag this claim for fraud review and notify the adjuster" is a write action — and the second one demands you take security seriously. Every connector is an attack surface and a blast radius. The discipline that matters: least privilege and identity. Narrowest permissions that finish the job, every call authenticated, every action auditable.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The Model Context Protocol (MCP) has become the common standard here precisely because it bakes identity and policy into the connection instead of bolting it on afterward.&lt;/p&gt;

&lt;h3&gt;
  
  
  Layer 5 — Sub-agents: the validation layer
&lt;/h3&gt;

&lt;p&gt;This is the layer separating teams that ship reliable agents from teams that ship confident hallucinations. The pattern: separate the builder from the judge.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Generator → produces output
     ↓
Validator → checks against rules, policy, known failure modes
     ↓
Approval gate → only validated output moves forward
     ↓
Feedback loop → flagged issues route back for another pass
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One agent generates the claim recommendation. A separate agent — different prompt, different job — checks it against policy constraints, regulatory rules, and known failure cases. Pass, and it ships. Fail, and it goes back with a specific reason.&lt;/p&gt;

&lt;p&gt;Why two agents instead of one checking its own work? Because a model grading its own output shares the same blind spots that produced the error in the first place. Multiple eyes — even both models — catch more. This is the operational version of "your evals are your moat": the validator sub-agent is where your eval logic lives at &lt;em&gt;runtime&lt;/em&gt;, not just in a test suite. Continuous validation is what turns a 60% agent into a 90% agent without touching the underlying model.&lt;/p&gt;

&lt;h3&gt;
  
  
  Layer 6 — Memory: the state layer
&lt;/h3&gt;

&lt;p&gt;The final layer is what makes the loop a loop instead of a circle that resets to zero. Memory preserves state across passes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Context storage&lt;/strong&gt; — past interactions persist across conversations and runs&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Retrieval&lt;/strong&gt; — relevant history is fetched to inform the current decision&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Learning loop&lt;/strong&gt; — system behavior updates based on outcomes
Without memory, every pass starts fresh and the agent makes the same mistake forever.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here's the precise mechanism worth sitting with: the loop does not make the model smarter. The model weights never change. What changes is the &lt;em&gt;context&lt;/em&gt; the system carries into each pass. Memory is the substrate that lets feedback from layer five accumulate instead of evaporate. Each pass leaves something behind for the next one to use — that's the whole trick.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why no single layer is the magic
&lt;/h2&gt;

&lt;p&gt;Put all six on the loop and you see how they hand off:&lt;/p&gt;

&lt;p&gt;Automations start it. Worktrees parallelize it. Skills and connectors do the work. Sub-agents validate it. Memory carries the lesson forward to the next pass.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A trigger with no memory is just automation.&lt;/li&gt;
&lt;li&gt;Memory with no validation is a system that confidently remembers wrong answers.&lt;/li&gt;
&lt;li&gt;Validation with no connectors is an agent grading work it never actually did.
The loop only compounds when all six are present and wired in sequence. Skip one and you don't get a slightly worse loop — you get a different failure mode entirely.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What this means when you're staring at a stalled agent
&lt;/h2&gt;

&lt;p&gt;When reviewing an agent architecture, don't start by asking which model was chosen. Ask one question first: &lt;strong&gt;where does the loop close?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If the answer is "it doesn't," that's the entire diagnosis — and no amount of prompt tuning fixes a missing feedback layer. For most teams, the fix isn't a better model. It's three of the six layers they skipped. Add a connector to read the adjuster's accept-or-override signal, a validator sub-agent that enforces policy constraints before drafting, and a memory layer that stores every override as a new case. Within a month, the agent moves off its plateau — because for the first time, it can actually learn from the humans correcting it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The risk nobody's pricing in yet
&lt;/h2&gt;

&lt;p&gt;As loops improve and grow more autonomous, there's a real cost that gets ignored: humans stop understanding the underlying mechanics. As the human-in-the-loop gets eliminated, teams accumulate &lt;strong&gt;comprehension debt&lt;/strong&gt; — a widening gap between what the system does and what anyone actually understands about how it does it. Left unchecked, that becomes cognitive surrender: trusting these systems so completely that nobody's tracking what's happening at all.&lt;/p&gt;

&lt;p&gt;Staying the engineer — keeping a working mental model of the system even as it improves without you — is the part of loop engineering that doesn't show up in the architecture diagram but matters just as much.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Open-loop agents plateau by design.&lt;/strong&gt; Input → Process → Output → stop means the system is exactly as smart on day 100 as day one, no matter the model.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Six layers close the loop:&lt;/strong&gt; automations (trigger), worktrees (parallelism), skills (procedural memory), connectors (real-world actions), sub-agents (validation), and memory (state) — each is a distinct architectural decision, not a checkbox.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Validation beats a bigger model.&lt;/strong&gt; A separate sub-agent checking output against policy and known failure modes is what moves a 60% agent to 90%, because a model can't catch its own blind spots.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Memory doesn't change the weights — it changes the context.&lt;/strong&gt; The intelligence gain is entirely in what gets carried forward into the next pass, not in the model getting smarter.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Every connector is a blast radius.&lt;/strong&gt; Least privilege, authentication, and auditability aren't optional once an agent moves from reading data to writing actions.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Closing thought
&lt;/h2&gt;

&lt;p&gt;If your agent has stalled at some mediocre-but-tolerable accuracy for weeks, the fix probably isn't a bigger model or a cleverer prompt — it's a missing layer in the loop. Which of the six are you actually missing: the trigger, the parallelism, the skill, the connector, the validator, or the memory? And if you've closed all six, what's stopping your team from understanding the system it built?&lt;/p&gt;

</description>
      <category>ai</category>
      <category>agents</category>
      <category>architecture</category>
      <category>machinelearning</category>
    </item>
    <item>
      <title>The Missing Context Plane: Why Enterprise Data Architecture Needs a Third Layer for AI Agents</title>
      <dc:creator>shakti mishra</dc:creator>
      <pubDate>Sun, 28 Jun 2026 20:24:17 +0000</pubDate>
      <link>https://dev.to/shakti_mishra_308e9f36b5d/the-missing-context-plane-why-enterprise-data-architecture-needs-a-third-layer-for-ai-agents-1egc</link>
      <guid>https://dev.to/shakti_mishra_308e9f36b5d/the-missing-context-plane-why-enterprise-data-architecture-needs-a-third-layer-for-ai-agents-1egc</guid>
      <description>&lt;h2&gt;
  
  
  Your Data Stack Is Working Exactly As Designed — Here's Why Your AI Agents Keep Failing
&lt;/h2&gt;

&lt;p&gt;The data warehouse is not broken.&lt;br&gt;
The transformation layer is doing its job.&lt;br&gt;
The dashboards are accurate.&lt;br&gt;
And your AI agents are still making decisions that would make any experienced analyst wince.&lt;/p&gt;

&lt;p&gt;Here's the uncomfortable truth: everything your data stack was built to do, it does well. The problem is that it was built for a different reader — a human one. And when you swap that reader out for an autonomous agent, the gaps that humans quietly filled through judgment, institutional memory, and context become catastrophic failure points.&lt;/p&gt;


&lt;h2&gt;
  
  
  What the Stack Was Actually Built For
&lt;/h2&gt;

&lt;p&gt;For the past decade, the data architecture workflow looked like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Raw Sources → Ingestion → Warehouse → dbt Transform → Metrics Layer → Dashboard → Human Analyst
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That last arrow is load-bearing in ways we never had to make explicit.&lt;/p&gt;

&lt;p&gt;The human analyst brought what no pipeline could deliver: business context. They knew &lt;em&gt;why&lt;/em&gt; a metric moved — because of a pricing experiment, a large customer churn, or a one-time bulk order that skewed the averages. They knew which dashboard was canonical and which one the finance team secretly maintained with different definitions. They knew which policy could bend for a strategic account and which exception had been pre-approved by legal.&lt;/p&gt;

&lt;p&gt;None of that lived in the warehouse. It lived in people, Slack threads, one-on-one conversations, and the kind of organizational muscle memory that gets transferred through onboarding and osmosis.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;AI agents don't get onboarded.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  The seam, Agents Can't Navigate
&lt;/h2&gt;

&lt;p&gt;Modern enterprise data stacks are actually a collection of specialized tools stitched together:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ingestion&lt;/strong&gt;: Fivetran, Airbyte&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Storage&lt;/strong&gt;: Snowflake, BigQuery, Databricks&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Transformation&lt;/strong&gt;: dbt&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Metrics layer&lt;/strong&gt;: MetricFlow, Cube&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data catalog&lt;/strong&gt;: Alation, Collibra, Atlan&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Governance&lt;/strong&gt;: varied&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Observability&lt;/strong&gt;: Monte Carlo, Great Expectations&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;BI&lt;/strong&gt;: Tableau, Looker, Power BI
Each tool is good at its job. Together, they create seams. Humans learned to navigate those seams invisibly — knowing which field in which system was "the real one," or that the definition of "active customer" changed in Q3 2023 and the old reports haven't been backfilled.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When an AI agent queries a metric, it gets the number. It doesn't get:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The lineage of how that number was computed&lt;/li&gt;
&lt;li&gt;The definition revision history&lt;/li&gt;
&lt;li&gt;The exception carved out for Enterprise tier customers&lt;/li&gt;
&lt;li&gt;The operational judgment about when to trust it versus when to dig deeper
The agent sees data. It doesn't see the map that makes the data safe to act on.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Agent Query → Data Returned → [GAP: missing context, policy, memory] → Decision Made
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That gap is where the bad recommendations come from.&lt;/p&gt;




&lt;h2&gt;
  
  
  Governance Without Context Is Not Governance
&lt;/h2&gt;

&lt;p&gt;This is the part that catches most teams off guard.&lt;/p&gt;

&lt;p&gt;Traditional governance stacks treat the problem as a layering issue: put permissions here, lineage there, business glossary somewhere else, and tie them together through integrations. The assumption is that combining these artifacts produces governed data.&lt;/p&gt;

&lt;p&gt;It doesn't.&lt;/p&gt;

&lt;p&gt;Governance isn't a rule. It's the act of deciding how a rule applies &lt;em&gt;in context&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;A pricing policy applies until it doesn't — for a strategic customer, for a partner relationship, during a specific campaign window. An approval chain is correct unless the person who can override it has already done so verbally and the exception hasn't been captured anywhere structured.&lt;/p&gt;

&lt;p&gt;Those exceptions are not edge cases. They represent a significant portion of where the organization's real judgment, authority, and institutional knowledge actually lives. If that judgment exists only in a Slack thread or an email chain, an AI agent following the documented rule can be technically compliant and operationally wrong at the same time.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Enterprise Memory Gap
&lt;/h2&gt;

&lt;p&gt;Here's a dimension the traditional stack almost entirely ignores: &lt;em&gt;reasoning memory&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;The modern data stack is excellent at storing artifacts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Tables ✓&lt;/li&gt;
&lt;li&gt;Dashboards ✓&lt;/li&gt;
&lt;li&gt;Logs ✓&lt;/li&gt;
&lt;li&gt;Metrics ✓
It is weak at preserving the reasoning that produced them:&lt;/li&gt;
&lt;li&gt;Why was this definition changed?&lt;/li&gt;
&lt;li&gt;Who approved this exception and why?&lt;/li&gt;
&lt;li&gt;What happened the last time we made this type of decision?&lt;/li&gt;
&lt;li&gt;Which tradeoff was accepted and under what constraints?
For human teams, this doesn't matter much — people ask their colleagues, pull up old meeting notes, or rely on tribal knowledge. The cost is friction and occasional mistakes. For AI agents operating at scale, this is a structural failure. An agent without access to reasoning history will re-derive decisions that were previously made and rejected, repeat past mistakes, and miss constraints that were hard-won through prior experience.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Human Decision Process:
  [Data] + [Policy] + [Memory of Past Decisions] + [Contextual Judgment] → Action

AI Agent (current):
  [Data] + [Policy] → Action (missing memory + contextual judgment)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Retrieval-augmented approaches can pull fragments from unstructured sources, but it's brittle. A semantic search over Slack messages and Confluence docs is not the same as a structured memory layer that an agent can query with confidence.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Architecture Shift: Adding a Context Plane
&lt;/h2&gt;

&lt;p&gt;The framework that emerges from this analysis is a three-plane architecture:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌─────────────────────────────────────────────────┐
│                  CONTEXT PLANE                  │
│  Semantic models · Policies · Memory · Exceptions│
│  Lineage · Definitions · Governance rules        │
└─────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────┐
│                  CONTROL PLANE                  │
│  Permissions · Auth · Orchestration · Audit logs │
└─────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────┐
│                   DATA PLANE                    │
│  Ingestion · Storage · Transformation · Metrics  │
└─────────────────────────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The data plane is what you have today. The control plane handles auth and orchestration. The context plane is what's missing.&lt;/p&gt;

&lt;p&gt;The context plane isn't a search index bolted onto your existing stack. It needs to be:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Produced as work happens&lt;/strong&gt; — context captured at the point of decision, not reconstructed retroactively&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Governed alongside data&lt;/strong&gt; — with the same rigor as the data itself&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Queryable by agents&lt;/strong&gt; — structured enough that an agent can retrieve it with confidence, not just probabilistically&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Updated continuously&lt;/strong&gt; — because the business context changes as fast as the business does
Building this from scratch is hard. The practical path for most enterprises will be evolutionary: identify the workflows where agents are expected to act, map the context and governance those workflows require, and layer in an AI-ready context layer that can unify structured data, unstructured knowledge, policies, memory, and orchestration incrementally.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  What "Context-Driven" Actually Means in Practice
&lt;/h2&gt;

&lt;p&gt;The shift from "data-driven" to "context-driven" isn't marketing language — it's an architectural requirement that shows up concretely in how you design agent systems.&lt;/p&gt;

&lt;p&gt;A data-driven agent gets a number and acts on it.&lt;/p&gt;

&lt;p&gt;A context-driven agent gets a number, plus:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The semantic definition of that metric&lt;/li&gt;
&lt;li&gt;The lineage showing how it was computed&lt;/li&gt;
&lt;li&gt;The policies governing what actions are permitted&lt;/li&gt;
&lt;li&gt;The exceptions that apply in the current situation&lt;/li&gt;
&lt;li&gt;The memory of how similar situations were handled before&lt;/li&gt;
&lt;li&gt;The confidence signal about data freshness and reliability
The interface changes from &lt;code&gt;SELECT metric FROM table&lt;/code&gt; to something much closer to a business context API:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;context&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;get_business_context&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;metric&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;revenue&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;customer_tier&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;enterprise&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;exception_scope&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;current_campaign_window&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;include_reasoning_history&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Returns: value + definition + lineage + applicable policies + past decisions
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's a different architectural bet than most teams are making today.&lt;/p&gt;




&lt;h2&gt;
  
  
  Key Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The data stack was optimized for human interpretation&lt;/strong&gt; — it's working as designed, but the reader changed. AI agents don't inherit the tacit map humans use to navigate data safely.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The seams between tools are where agents fail&lt;/strong&gt; — permissions in one place, definitions in another, exceptions in a Slack thread. Humans navigate these invisibly; agents hit them hard.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Governance is contextual, not rule-based&lt;/strong&gt; — a rule that can't express its own exceptions is not enough for an agent operating at scale.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reasoning memory is the missing layer&lt;/strong&gt; — storing artifacts (tables, dashboards) is not the same as preserving the reasoning that produced decisions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The next data architecture adds a context plane&lt;/strong&gt; — alongside the data plane and control plane, a first-class layer for semantic models, policies, memory, and governed reasoning.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  The Question Worth Debating
&lt;/h2&gt;

&lt;p&gt;If context needs to be "produced as work happens" — captured at the point of decision — who owns that? Data engineering? The domain teams making the decisions? Platform teams building agent infrastructure?&lt;/p&gt;

&lt;p&gt;Most organizations aren't close to having a clear answer. And until they do, the agents will keep making technically correct but operationally wrong decisions.&lt;/p&gt;

&lt;p&gt;Where is your team with this? Are you building a context layer, patching it with RAG, or still hoping the warehouse is enough?&lt;/p&gt;

</description>
      <category>ai</category>
      <category>data</category>
      <category>architecture</category>
      <category>agents</category>
    </item>
    <item>
      <title>Microsoft AI Agent Architecture in 2026: A Decision Framework for Copilot Studio, Foundry, Agent Framework, and Logic Apps</title>
      <dc:creator>shakti mishra</dc:creator>
      <pubDate>Sun, 14 Jun 2026 19:15:12 +0000</pubDate>
      <link>https://dev.to/shakti_mishra_308e9f36b5d/microsoft-ai-agent-architecture-in-2026-a-decision-framework-for-copilot-studio-foundry-agent-582h</link>
      <guid>https://dev.to/shakti_mishra_308e9f36b5d/microsoft-ai-agent-architecture-in-2026-a-decision-framework-for-copilot-studio-foundry-agent-582h</guid>
      <description>&lt;h1&gt;
  
  
  Stop Picking AI Frameworks Before You Answer This One Question
&lt;/h1&gt;

&lt;p&gt;If you're building AI agents on Azure, you've been here: a kickoff meeting where someone asks "what framework should we use?" and the next 90 minutes becomes a debate between Semantic Kernel, AutoGen, Copilot Studio, Foundry, and Logic Apps — before anyone has agreed on what the agent actually needs to do.&lt;/p&gt;

&lt;p&gt;That is the wrong sequence. And it's why so many Azure AI projects start with the most sophisticated-sounding option and spend the next three months fighting the wrong abstraction.&lt;/p&gt;

&lt;p&gt;The Microsoft ecosystem gives you more agent architecture flexibility than any other cloud provider. Conversational or headless. Low-code or pro-code. M365-native or Azure-native. That flexibility is a genuine advantage — but only if you read the decision tree in the right order.&lt;/p&gt;

&lt;p&gt;This post walks through that tree. By the end you'll have a repeatable framework for choosing the right architecture the first time, plus a list of SDK retirement dates you need to know before you commit.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Platform Landscape First
&lt;/h2&gt;

&lt;p&gt;Before the decision tree, it helps to understand the three tiers Microsoft gives you:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌─────────────────────────────────────────────────────────────────┐
│               Microsoft Agent Platform Tiers                     │
│                                                                   │
│  ┌───────────────────┐  ┌──────────────────┐  ┌──────────────┐  │
│  │  Copilot Studio   │  │  Copilot Studio  │  │  Microsoft   │  │
│  │      Lite         │  │   (Pro Makers)   │  │   Foundry    │  │
│  │                   │  │                  │  │              │  │
│  │ M365 scenarios    │  │ More actions,    │  │ Pro devs,    │  │
│  │ Low complexity    │  │ channels,        │  │ custom code, │  │
│  │ No-code           │  │ orchestration    │  │ full control │  │
│  └───────────────────┘  └──────────────────┘  └──────────────┘  │
│        Simple ◄─────────────────────────────────► Advanced       │
└─────────────────────────────────────────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These aren't competing products. They're a spectrum. The question is which tier fits your team's constraints, not which one is "best."&lt;/p&gt;




&lt;h2&gt;
  
  
  The One Question That Drives Everything
&lt;/h2&gt;

&lt;p&gt;Before frameworks, before data layers, before deployment — the single most important decision is:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the interaction pattern?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are exactly three answers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                    ┌─────────────────────┐
                    │  What is the        │
                    │ interaction pattern? │
                    └──────────┬──────────┘
                               │
             ┌─────────────────┼─────────────────┐
             ▼                 ▼                 ▼
    ┌─────────────┐   ┌─────────────────┐  ┌──────────────┐
    │ Chat / UI   │   │   Autonomous /  │  │  Headless /  │
    │  (User      │   │  Event-Driven   │  │   API        │
    │  talks to   │   │  (Runs in the   │  │  (Systems    │
    │  the agent) │   │   background)   │  │  call it)    │
    └─────────────┘   └─────────────────┘  └──────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This fork determines nearly every downstream decision. Teams that skip it and jump straight to framework selection spend months fighting the wrong abstraction. Teams that start here make better choices in minutes.&lt;/p&gt;




&lt;h2&gt;
  
  
  Path 1: Chat / UI-Based Agents
&lt;/h2&gt;

&lt;p&gt;If a human will talk directly to the agent, follow this branch.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Where does the user live?
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Is the experience entirely within Microsoft 365?
│
├── YES → M365 Copilot
│         Best fit when users already work in the Microsoft
│         ecosystem and you want strong user-in-the-loop
│         experience without a custom application layer.
│
└── NO  → Does it need Teams or multi-channel support?
          │
          ├── YES (need speed) → Copilot Studio
          │                      Best for business workflows,
          │                      fast time-to-production,
          │                      avoiding a full engineering sprint.
          │
          └── YES (need control) → Pro-code path ↓
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: The pro-code fork
&lt;/h3&gt;

&lt;p&gt;When you need a conversational UI with full engineering control, one more decision determines the right SDK:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Is this M365-centric?
│
├── YES → M365 Agents SDK
│         Deepest integration with Teams, Outlook, SharePoint.
│         Handles auth, channel routing, and M365 data access
│         without custom plumbing.
│
└── NO  → Azure-centric path
          │
          Do you need a custom, interactive frontend
          (streaming, shared state, embedded web/app UI)?
          │
          ├── YES → Agent Framework + AG-UI
          │         AG-UI is an emerging protocol that gives
          │         agents a standard way to talk to modern
          │         frontends. Critical when your agent is
          │         embedded in a React app, not just a chat
          │         window.
          │
          └── NO  → Microsoft Foundry
                    Cleanest Azure-first path when you
                    don't need the custom UI protocol layer.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;The summary for UI-based agents comes down to four questions:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Is this conversational? (Yes — you're on this path)&lt;/li&gt;
&lt;li&gt;Where does the user interact? (M365, Teams, or custom?)&lt;/li&gt;
&lt;li&gt;Low-code or pro-code?&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  4. M365-first or Azure-first?
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Path 2: Autonomous / Event-Driven Agents
&lt;/h2&gt;

&lt;p&gt;These agents run in the background. They react to triggers. They process information and take action with minimal or no direct user interaction. The architecture here follows the workflow, not the chat UI.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Autonomous Agent Decision Tree:
│
├── Want low-code? → Copilot Studio with Event Triggers
│                    Good starting point for business-user-built
│                    automation with Power Automate triggers.
│
├── Need custom UI protocol? → Agent Framework + AG-UI
│                              Same AG-UI story as the chat path —
│                              richer app experiences with
│                              streaming and state.
│
├── Azure-centric + enterprise controls? → Microsoft Foundry
│                                          Deep governance,
│                                          model routing, tracing,
│                                          and evaluation built in.
│
└── Heavy enterprise system integration?
    (SAP, ServiceNow, Salesforce, etc.)
    → Logic Apps AI Agent Workflows
      Logic Apps gives agents access to 1,400+ enterprise connectors.
      When integration is the core problem — not model selection —
      the connector story matters more than the model story.
      These workflows can now be exposed as MCP tools for
      standardized agent access.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Key insight for this path:&lt;/strong&gt; Autonomous agents aren't chatbots with the chat stripped out. They are workflow systems. The architecture choice should follow the workflow shape, the trigger sources, and the integration surface — not the sophistication of the model you want to run.&lt;/p&gt;

&lt;p&gt;This matters especially for enterprise workflows where the agent's job is to call SAP, read from ServiceNow, and write back to Salesforce. The agent framework is almost irrelevant compared to the integration layer.&lt;/p&gt;




&lt;h2&gt;
  
  
  Path 3: Headless / API Services
&lt;/h2&gt;

&lt;p&gt;No chat window. No copilot interface. The agent exposes a backend service that other systems call. The main variable here is &lt;strong&gt;hosting requirements&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Headless Agent Hosting:
│
├── Managed platform service → Azure Container Apps
│                              Best default — handles scaling,
│                              secrets, and networking without
│                              managing Kubernetes directly.
│
├── Local / Edge deployment → Azure IoT Edge / Container Apps
│                              For agents that need to run
│                              close to data or offline.
│
└── Full self-hosting control → AKS
                               When you need full orchestration
                               control, custom networking, or
                               multi-agent mesh configurations.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This branch is less about user experience and more about &lt;strong&gt;runtime shape&lt;/strong&gt;. When the agent is infrastructure — called by other services, not by users — the deployment target and SLA requirements drive the decision.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Data Layer: Don't Treat It as an Implementation Detail
&lt;/h2&gt;

&lt;p&gt;Here is where most Azure AI projects underinvest. The quality of your agent's responses will depend far more on the retrieval layer than on the model you choose.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Does the agent need custom data?
│
├── Microsoft 365 data (emails, docs, SharePoint)
│   → Graph Connectors + M365 data layer
│
├── Unstructured documents at scale
│   → Azure AI Search (Agentic RAG)
│     Semantic ranking, hybrid search (dense + sparse),
│     integrated chunking and vectorization.
│     Critical when your knowledge base is PDFs, contracts,
│     or policy documents.
│
├── Vector search on structured/semi-structured data
│   → Choose based on existing infrastructure:
│     • Cosmos DB (NoSQL + vector)
│     • PostgreSQL with pgvector
│     • Azure SQL with vector support
│     • Fabric SQL (if analytics context needed)
│
└── Analytics context (dashboards, metrics, BI data)
    → Microsoft Fabric
      When the agent needs to reason over business intelligence
      or time-series data alongside documents.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A practical rule: if the agent answers questions by &lt;em&gt;retrieving information&lt;/em&gt;, the retrieval architecture is the most important design decision you'll make. The model is a commodity; how you feed it isn't.&lt;/p&gt;




&lt;h2&gt;
  
  
  Deployment: Where Does the Agent Need to Live?
&lt;/h2&gt;

&lt;p&gt;After interaction model, build approach, and data layer, the final decision is where users or systems reach the agent:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Target Audience&lt;/th&gt;
&lt;th&gt;Deployment Path&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;M365 users in Copilot&lt;/td&gt;
&lt;td&gt;M365 Copilot channel&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Teams users&lt;/td&gt;
&lt;td&gt;Teams channel&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Web or mobile users&lt;/td&gt;
&lt;td&gt;Web/mobile channel&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Multiple surfaces&lt;/td&gt;
&lt;td&gt;Multi-channel SDK route&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Other Azure services / APIs&lt;/td&gt;
&lt;td&gt;Azure Container Apps, App Service, or AKS&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;And once you've decided: &lt;strong&gt;don't skip monitoring&lt;/strong&gt;. Observability, governance, and cost visibility need to be part of the design from day one, not retrofitted after the first production incident.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Retirement Dates You Must Know Before You Commit
&lt;/h2&gt;

&lt;p&gt;This section belongs in every Azure AI architecture conversation right now. Three SDKs have announced or confirmed retirement dates within current planning horizons:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;SDK / Service&lt;/th&gt;
&lt;th&gt;Retirement Date&lt;/th&gt;
&lt;th&gt;Successor&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Bot Framework&lt;/td&gt;
&lt;td&gt;December 31, 2025&lt;/td&gt;
&lt;td&gt;M365 Agents SDK&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;azure-ai-inference SDK&lt;/td&gt;
&lt;td&gt;May 30, 2026&lt;/td&gt;
&lt;td&gt;openai SDK&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Assistants API&lt;/td&gt;
&lt;td&gt;August 26, 2026&lt;/td&gt;
&lt;td&gt;Foundry Agent Service / Responses API&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;If any of these are in your current stack or your evaluation shortlist, start the migration now.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The cost of discovering a retirement date mid-project — after you've trained your team on the SDK, written documentation, and built integrations — is always higher than starting on the right platform. This is especially true for teams with multi-quarter planning cycles.&lt;/p&gt;

&lt;p&gt;The Bot Framework retirement is already past as of this writing. If you're still on it, the M365 Agents SDK migration is not optional.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Short Version (Put This on Your Whiteboard)
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;STEP 1: What is the interaction pattern?
        Chat UI → go to Step 2
        Autonomous → go to Step 3
        Headless → go to Step 4

STEP 2: Chat UI path
        M365 only? → M365 Copilot
        Low-code + multi-channel? → Copilot Studio
        Pro-code + M365-first? → M365 Agents SDK
        Pro-code + custom UI? → Agent Framework + AG-UI
        Pro-code + Azure-first? → Foundry

STEP 3: Autonomous path
        Low-code → Copilot Studio + Event Triggers
        Enterprise integrations → Logic Apps AI Agent Workflows
        Custom UI protocol → Agent Framework + AG-UI
        Azure-first + governance → Foundry

STEP 4: Headless path
        Managed → Container Apps
        Edge → IoT Edge / Container Apps
        Full control → AKS

Then: Choose your data layer based on data type.
Then: Choose your deployment channel based on who/what calls the agent.
Then: Wire in monitoring and governance before you ship.

Check retirement dates. Start on the right platform.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Key Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The single most important decision in Azure AI agent architecture is the &lt;strong&gt;interaction pattern&lt;/strong&gt; (Chat/UI, Autonomous, Headless). Every other choice flows from it — framework debates before this question is answered are premature.&lt;/li&gt;
&lt;li&gt;Low-code (Copilot Studio) is a strategic choice, not a compromise. If your users already live in Teams and M365, it often gets you to production faster than a custom pro-code solution with equivalent results.&lt;/li&gt;
&lt;li&gt;The data layer determines agent quality more than the model tier. Choosing Azure AI Search, pgvector, Cosmos DB, or Fabric depends on the shape of your data — decide this early.&lt;/li&gt;
&lt;li&gt;Three SDKs have confirmed retirement dates within 2026 planning horizons: Bot Framework (retired Dec 2025), azure-ai-inference SDK (May 2026), and Assistants API (Aug 2026). Audit your stack now.&lt;/li&gt;
&lt;li&gt;Logic Apps AI Agent Workflows with 1,400+ enterprise connectors is the right path when the core problem is integration, not model selection. The connector story matters more than the model story in those scenarios.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  The Question Worth Sitting With
&lt;/h2&gt;

&lt;p&gt;Every team I've seen debate Azure AI frameworks starts with "which one is most powerful?" The right question is "which one fits the shape of what we're actually building?"&lt;/p&gt;

&lt;p&gt;If you've been through an Azure AI architecture decision recently — what forced the framework choice? Was it the interaction model, the data layer, team skill, time pressure, or something else entirely?&lt;/p&gt;

&lt;p&gt;Drop it in the comments. Hearing what drove real decisions is more useful than any decision tree.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>azure</category>
      <category>architecture</category>
      <category>microsoft</category>
    </item>
    <item>
      <title>12 Engineering Habits That Cut LLM Token Spend at Production Scale</title>
      <dc:creator>shakti mishra</dc:creator>
      <pubDate>Sun, 31 May 2026 22:23:02 +0000</pubDate>
      <link>https://dev.to/shakti_mishra_308e9f36b5d/12-engineering-habits-that-cut-llm-token-spend-at-production-scale-24jp</link>
      <guid>https://dev.to/shakti_mishra_308e9f36b5d/12-engineering-habits-that-cut-llm-token-spend-at-production-scale-24jp</guid>
      <description>&lt;h2&gt;
  
  
  Your LLM Bill Isn't One Big Leak. It's Twelve Small Ones.
&lt;/h2&gt;

&lt;h3&gt;
  
  
  A team shipped a great AI feature in their product. The cost had quietly tripled in six weeks — same model, same product, no obvious explanation.
&lt;/h3&gt;

&lt;p&gt;That is not a model problem. That is a habits problem.&lt;/p&gt;

&lt;p&gt;Token prices are falling. Enterprise AI bills are climbing. That apparent contradiction resolves instantly when you look at the real culprit: volume grows faster than price drops. Google now processes over a quadrillion tokens a month. Deloitte's 2026 CFO guidance names AI the fastest-growing line item in tech budgets. You can have cheaper tokens and a higher bill simultaneously — and most teams do.&lt;/p&gt;

&lt;p&gt;The teams that survive this are not the ones with the cheapest model or the best negotiated rate. They are the ones who have engineered clean habits into how they build. Every call. Every feature. Every deploy.&lt;/p&gt;

&lt;p&gt;Here are the twelve habits that matter.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Token Prices Falling Doesn't Save You
&lt;/h2&gt;

&lt;p&gt;Before the tactics, let's understand the structural trap.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Token price per 1M: $15 → $8 → $4 (falling fast)
Monthly token volume: 10M → 80M → 600M (growing faster)

Month 1 bill: 10M × $15/M = $150
Month 4 bill: 600M × $4/M = $2,400
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is not hypothetical. It is the trajectory of every team that ships an AI feature without cost discipline. The price per token drops. The total bill explodes. And nobody notices until the CFO asks why the AI line item tripled.&lt;/p&gt;

&lt;p&gt;The fix is not a cheaper model. The fix is twelve cleaner habits.&lt;/p&gt;




&lt;h2&gt;
  
  
  The 12 Engineering Habits
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Choose the Right Model for the Task
&lt;/h3&gt;

&lt;p&gt;Most teams reach for the biggest model by default. Big mistake.&lt;/p&gt;

&lt;p&gt;The biggest model is rarely the right one — it is just the safest-feeling one. Every request deserves to be routed to the smallest, cheapest model that still clears the quality bar.&lt;/p&gt;

&lt;p&gt;Here is the routing heuristic I use:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Task Type&lt;/th&gt;
&lt;th&gt;Model Tier&lt;/th&gt;
&lt;th&gt;Examples&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Routing, classifying, extracting&lt;/td&gt;
&lt;td&gt;Small&lt;/td&gt;
&lt;td&gt;GPT-5.4-mini, Claude Haiku 4.5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Drafting, summarizing&lt;/td&gt;
&lt;td&gt;Mid&lt;/td&gt;
&lt;td&gt;GPT-5.4, Claude Sonnet 4.6&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hard reasoning, final answers&lt;/td&gt;
&lt;td&gt;Large&lt;/td&gt;
&lt;td&gt;GPT-5.5, Claude Opus 4.8&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Most production workloads are small-model work wearing a large-model price tag. Map your request types, measure output quality at each tier, then route accordingly. A simple classifier — yes, possibly a small model — can do this routing cheaply.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;route_model&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;task_type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;routing_map&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;classify&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;claude-haiku-4-5&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;extract&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;claude-haiku-4-5&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;summarize&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;claude-sonnet-4-6&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;draft&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;claude-sonnet-4-6&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;reason&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;claude-opus-4-8&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;generate_final&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;claude-opus-4-8&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;routing_map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;task_type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;claude-sonnet-4-6&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Reduce Input Tokens
&lt;/h3&gt;

&lt;p&gt;You pay for every token you send — not just the ones you get back.&lt;/p&gt;

&lt;p&gt;A 2,000-token system prompt on every call is a permanent tax. You pay it on every single request, forever. Teams pile on examples, repeat instructions across calls, and paste in giant context blocks "just in case." The model does not need your life story.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Audit your system prompts.&lt;/strong&gt; Run them through a tokenizer. Most teams find 30–50% is cuttable on first pass — redundant examples, stale instructions, context the model never uses.&lt;/p&gt;

&lt;p&gt;Write tight. Send less. Then measure whether quality actually dropped. Usually it doesn't.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Limit Output Tokens
&lt;/h3&gt;

&lt;p&gt;Long answers feel thorough. They are also expensive.&lt;/p&gt;

&lt;p&gt;Set hard output token caps. Ask for bullet points, structured responses, or explicit length constraints in your prompts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Instead of open-ended generation
&lt;/span&gt;&lt;span class="n"&gt;messages&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;role&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;user&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;content&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Explain how X works.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}]&lt;/span&gt;

&lt;span class="c1"&gt;# Be explicit about length
&lt;/span&gt;&lt;span class="n"&gt;messages&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;role&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;user&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;content&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Explain how X works. Answer in 3 concise sentences, no more.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A 50-token answer beats a 500-token one — for the bill and, often, for the user. Verbose model outputs frequently bury the signal in filler. Constraining output length improves both cost and quality.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Use Caching Aggressively
&lt;/h3&gt;

&lt;p&gt;Your users ask the same questions over and over. Stop re-generating the same answers.&lt;/p&gt;

&lt;p&gt;Two caching layers matter here:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Exact-match caching:&lt;/strong&gt; Hash the prompt, cache the response. Trivial to implement, immediate ROI for any FAQ-style traffic.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Semantic caching:&lt;/strong&gt; Use embedding similarity to catch near-duplicate prompts even when the wording varies. A question about "how do I reset my password" and "I forgot my password, what do I do?" should hit the same cached response.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prompt prefix caching:&lt;/strong&gt; Most providers now offer cached prefixes for the static portion of long system prompts. If you have a 1,500-token system prompt on every call, prompt caching alone can cut your input cost in half. This is free money. Take it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Architecture with semantic cache:

User Query
    │
    ▼
[Embedding Model] ──→ [Vector Cache Lookup]
                              │
                    ┌─────────┴──────────┐
                    │ HIT (similarity&amp;gt;0.92)│  MISS
                    ▼                     ▼
             [Cached Response]    [LLM API Call] ──→ [Store in Cache]
                    │                     │
                    └──────────┬──────────┘
                               ▼
                         [User Response]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5. RAG Done Right
&lt;/h3&gt;

&lt;p&gt;Bad RAG is a silent budget killer. Teams dump huge context chunks and hope the model sorts it out. The model does sort it out — and charges you for every token while doing so.&lt;/p&gt;

&lt;p&gt;The fix is surgical retrieval:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Chunk small:&lt;/strong&gt; Smaller, focused chunks mean tighter retrieval. A 256-token chunk beats a 2,000-token chunk if it's more semantically precise.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Retrieve only what the current question needs:&lt;/strong&gt; Don't retrieve your entire knowledge base. Top-K retrieval with a relevance threshold, not a fixed K.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Trim before you send:&lt;/strong&gt; After retrieval, run a lightweight reranker or even a cheap model pass to strip irrelevant retrieved chunks before they hit the main context window.
Good RAG is not "more context." It is less, but exactly right.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  6. Batch Requests
&lt;/h3&gt;

&lt;p&gt;One-by-one API calls carry overhead. Batching eliminates it.&lt;/p&gt;

&lt;p&gt;Most providers offer a batch API tier at steep discounts (often 50% off) for non-time-sensitive jobs. If you are processing documents, embedding a corpus, or running evaluations, there is no reason to pay real-time pricing.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Don't do this for batch workloads
&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;document&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;documents&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(...)&lt;/span&gt;  &lt;span class="c1"&gt;# sequential, real-time pricing
&lt;/span&gt;
&lt;span class="c1"&gt;# Do this instead
&lt;/span&gt;&lt;span class="n"&gt;batch_response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;beta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;batches&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;custom_id&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;params&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;model&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;...&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;messages&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[...]}}&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;doc&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;documents&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# Runs async, often 50% cheaper
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Overnight processing jobs do not need real-time pricing. Route them to the batch tier.&lt;/p&gt;

&lt;h3&gt;
  
  
  7. Use Function Calling and Structured Output
&lt;/h3&gt;

&lt;p&gt;Free-text answers are expensive to parse. The workflow becomes: generate verbose text → write parsing code → handle edge cases → re-ask when it breaks. Every layer adds tokens.&lt;/p&gt;

&lt;p&gt;Function calling and structured output collapse this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Expensive: free-text answer you then parse
&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;The user&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;s sentiment is positive, their intent is to purchase...&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

&lt;span class="c1"&gt;# Cheap: structured output with zero parsing overhead
&lt;/span&gt;&lt;span class="n"&gt;response_schema&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;sentiment&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;positive | negative | neutral&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;intent&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;purchase | browse | support | other&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;confidence&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;  &lt;span class="c1"&gt;# float
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Define a schema. Ask for clean JSON. Skip the natural-language wrapper. Fewer tokens, fewer retries, zero glue code.&lt;/p&gt;

&lt;h3&gt;
  
  
  8. Build a Prompt Library
&lt;/h3&gt;

&lt;p&gt;Every team rewrites the same prompt five slightly different ways. Each version drifts. Each one gets longer. Nobody owns it.&lt;/p&gt;

&lt;p&gt;Build a library of proven, parameterized templates instead:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;PROMPT_LIBRARY&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;classify_support_ticket&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;
Classify this support ticket into exactly one category: {categories}.
Respond with the category name only, no explanation.

Ticket: {ticket_text}
&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;summarize_document&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;
Summarize the following document in {max_sentences} sentences.
Focus on: {focus_areas}.

Document: {document_text}
&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Write the prompt once, tune it once, measure it once, reuse it everywhere. This is a cost win, a quality win, and a maintainability win.&lt;/p&gt;

&lt;h3&gt;
  
  
  9. Use a Tiered, Two-Step Approach
&lt;/h3&gt;

&lt;p&gt;Not every request deserves your most expensive model. Filter first.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                    All Requests
                         │
                         ▼
                [Cheap Model — Triage]
                  classify / draft / filter
                         │
               ┌─────────┴──────────┐
               │                    │
         [Simple Case]        [Complex Case]
        ← 80% of traffic →    ← 20% of traffic →
         Return cheap          Escalate to
          model output        expensive model
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Most traffic never needs the expensive model. A cheap triage pass — classifying request complexity, filtering noise, handling simple cases directly — routes only the genuinely hard problems up the cost stack. The savings are often dramatic: 60–80% of production traffic handled at small-model cost.&lt;/p&gt;

&lt;h3&gt;
  
  
  10. Monitor Token Spend by Feature
&lt;/h3&gt;

&lt;p&gt;You cannot fix what you cannot see.&lt;/p&gt;

&lt;p&gt;Most teams have no idea which feature burns the most tokens. They guess, they guess wrong, and then they optimize the wrong thing.&lt;/p&gt;

&lt;p&gt;Instrument at the feature level:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;tracked_completion&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;feature&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;kwargs&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;start&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;time&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;kwargs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&gt;# Emit to your metrics system
&lt;/span&gt;    &lt;span class="n"&gt;metrics&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;increment&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;llm.input_tokens&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
                       &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;usage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;input_tokens&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                       &lt;span class="n"&gt;tags&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;feature&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;feature&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="n"&gt;metrics&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;increment&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;llm.output_tokens&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                       &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;usage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;output_tokens&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                       &lt;span class="n"&gt;tags&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;feature&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;feature&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="n"&gt;metrics&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;timing&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;llm.latency_ms&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                   &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;time&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;start&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                   &lt;span class="n"&gt;tags&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;feature&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;feature&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Track spend by feature, by user tier, by request type. Find the top three cost offenders. Fix those first. A dashboard you check weekly beats a heroic cleanup after the bill explodes.&lt;/p&gt;

&lt;h3&gt;
  
  
  11. Treat Provider Pricing as a Procurement Decision
&lt;/h3&gt;

&lt;p&gt;Provider pricing is not static. It changes by model, by region, by commitment tier, by workload type. Most teams pick a provider once and never revisit it.&lt;/p&gt;

&lt;p&gt;Treat this like infrastructure procurement:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Compare providers on your actual workload mix before committing to production volume&lt;/li&gt;
&lt;li&gt;Evaluate reserved capacity and committed-use discounts (often 30–60% off on-demand)&lt;/li&gt;
&lt;li&gt;Consider whether a different region offers lower latency AND lower cost&lt;/li&gt;
&lt;li&gt;Run periodic cost-per-quality benchmarks across providers as models evolve
This is a procurement decision that engineering should own, not just ops. The savings potential is often larger than all twelve other habits combined.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  12. Optimize Embeddings Usage
&lt;/h3&gt;

&lt;p&gt;Embeddings feel cheap per call. At scale, they are not.&lt;/p&gt;

&lt;p&gt;The most common waste patterns:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Re-embedding the same content repeatedly (no caching)&lt;/li&gt;
&lt;li&gt;Embedding near-duplicates separately (no deduplication)&lt;/li&gt;
&lt;li&gt;Making individual embedding calls instead of batching&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Fix all three:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;hashlib&lt;/span&gt;

&lt;span class="c1"&gt;# Cache embeddings by content hash
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_embedding&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;content_hash&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;hashlib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sha256&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;()).&lt;/span&gt;&lt;span class="nf"&gt;hexdigest&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;content_hash&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;content_hash&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;  &lt;span class="c1"&gt;# Free — already computed
&lt;/span&gt;
    &lt;span class="n"&gt;embedding&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;embedding_client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;embed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;content_hash&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;embedding&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;embedding&lt;/span&gt;

&lt;span class="c1"&gt;# Batch embedding generation
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;batch_embed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;texts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;]]:&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;embedding_client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;embed_batch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;texts&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Single API call, batch pricing
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Small per-call cost, massive total cost at production volume. Worth the cleanup.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Pattern Under All Twelve
&lt;/h2&gt;

&lt;p&gt;Read the list again. Notice something?&lt;/p&gt;

&lt;p&gt;None of these are clever. There is no secret model flag, no undocumented API parameter, no vendor trick. Every single strategy reduces to the same move: &lt;strong&gt;send fewer tokens, and only the ones that matter.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;LLM cost optimization is not a one-time project. It is a discipline you bake into how your team builds — the same way you bake in logging, testing, and error handling.&lt;/p&gt;




&lt;h2&gt;
  
  
  How These Map to Azure
&lt;/h2&gt;

&lt;p&gt;If you are building on Azure, the platform has native homes for most of these strategies:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Strategy&lt;/th&gt;
&lt;th&gt;Azure Service&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Model routing (small/mid/large)&lt;/td&gt;
&lt;td&gt;Azure AI Foundry model catalog — deploy mixed tiers, route between them&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Caching + input token reduction&lt;/td&gt;
&lt;td&gt;Azure API Management (AI gateway) — semantic caching, token limits, token metrics&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;RAG optimization&lt;/td&gt;
&lt;td&gt;Azure AI Search — hybrid retrieval, tight chunking&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Monitoring + token spend tracking&lt;/td&gt;
&lt;td&gt;Azure Monitor + API Management token metrics&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Embeddings caching&lt;/td&gt;
&lt;td&gt;Azure Cosmos DB or Azure AI Search vector store&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Batch processing&lt;/td&gt;
&lt;td&gt;Azure AI Foundry batch deployment tier&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;You do not have to wire all twelve by hand. Wire the platform.&lt;/p&gt;




&lt;h2&gt;
  
  
  Key Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Token prices are falling; your bill is rising.&lt;/strong&gt; Volume grows faster than price drops — this is structural, not accidental.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Most LLM costs are habits, not features.&lt;/strong&gt; Oversized models, verbose prompts, uncached repeated calls, and sequential batching are the main culprits.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Start with three this week:&lt;/strong&gt; right-size your model routing, cap output tokens, and enable prompt prefix caching. Those three alone typically cut the bill by a third.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Monitor at the feature level.&lt;/strong&gt; You cannot optimize what you cannot measure. Token spend dashboards by feature reveal the 20% of requests driving 80% of cost.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cost optimization is a design choice made on every API call&lt;/strong&gt; — not a quarterly cleanup project.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  The Question Worth Arguing About
&lt;/h2&gt;

&lt;p&gt;Here is something I genuinely wrestle with: as models get cheaper and context windows get larger, some of these habits become less critical. Maybe in two years, sending a 10,000-token context window on every call will cost pennies and nobody will care.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Or maybe volume will grow to fill any price decrease, and the discipline matters more than ever.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Where do you land on this? Are you actively optimizing LLM costs in production, or betting that price curves solve the problem for you? Tell me in the comments — I am genuinely curious whether teams are treating this as engineering infrastructure or hoping the market handles it.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>architecture</category>
      <category>agents</category>
    </item>
    <item>
      <title>The 5-Layer Architecture Every Production Multi-Agent System Needs (And Why Most Skip Layers 4 and 5)</title>
      <dc:creator>shakti mishra</dc:creator>
      <pubDate>Mon, 25 May 2026 23:15:27 +0000</pubDate>
      <link>https://dev.to/shakti_mishra_308e9f36b5d/the-5-layer-architecture-every-production-multi-agent-system-needs-and-why-most-skip-layers-4-and-n9h</link>
      <guid>https://dev.to/shakti_mishra_308e9f36b5d/the-5-layer-architecture-every-production-multi-agent-system-needs-and-why-most-skip-layers-4-and-n9h</guid>
      <description>&lt;h1&gt;
  
  
  Your Multi-Agent AI System Is Just a Dinner Party With No One in Charge
&lt;/h1&gt;

&lt;p&gt;Picture this. Dinner guests arriving in an hour. Four people, each capable, each assigned a job.&lt;/p&gt;

&lt;p&gt;One handles the grill. One sets the table. One makes the salad. One runs the music.&lt;/p&gt;

&lt;p&gt;Thirty minutes in: the grill isn't heating because nobody opened the propane valve. The salad person is waiting on ingredients that were never passed over. The appetizers are cold because the reheating was supposed to happen ten minutes ago. The DJ paired to the wrong speaker and is now blasting techno into the baby's room.&lt;/p&gt;

&lt;p&gt;No one was incompetent. Everyone knew their job. The whole thing fell apart because &lt;strong&gt;there was no system for coordination&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;That is a near-perfect description of most multi-agent AI systems running in production today.&lt;/p&gt;

&lt;p&gt;Each agent is capable — a coder, a researcher, a planner, a writer. But without shared memory, deliberate orchestration, and proper state management, capable agents produce incoherent results. The failure isn't in the intelligence of the individual agents. It's in the architecture that's supposed to make them a team.&lt;/p&gt;

&lt;p&gt;This post breaks down the five-layer architecture that separates production multi-agent systems from expensive demos — and names the specific failure modes you will hit if you skip any of them.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Three Ways Multi-Agent Systems Fail Before You Ship
&lt;/h2&gt;

&lt;p&gt;Before the architecture, the failure taxonomy. These three problems appear, in some combination, in nearly every multi-agent system that didn't make it to production:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Chaos Problem.&lt;/strong&gt; No orchestration means agents act in parallel without coordination. One agent fetches data while another modifies it. One writes a response while another has already decided the query requires escalation. The outputs contradict each other, or worse — they corrupt shared state.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Amnesia Problem.&lt;/strong&gt; Agents can't access context from previous steps in the workflow. Each call starts fresh. An agent that just retrieved customer history has no way to pass that context to the agent writing the response — unless you explicitly build the memory layer. Most teams don't, until it's too late.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Black Box Problem.&lt;/strong&gt; Something goes wrong. You have no trace of which agent made which decision, what state the system was in, or what inputs triggered the failure. You can't reproduce it. You can't fix it. You can only watch it happen again.&lt;/p&gt;

&lt;p&gt;If any of these sound familiar from your own experiments, keep reading — the architecture below is designed to close all three gaps.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Five-Layer Architecture
&lt;/h2&gt;

&lt;p&gt;Here's the framework: five layers that must all be functional before a multi-agent system can deliver consistent value in production. Think of them as load-bearing walls. You can skip one in a prototype. You cannot skip one in production.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌─────────────────────────────────────────────────────┐
│          Layer 1: Orchestration                     │
│   Orchestrator · Classifier · Agent Registry       │
├─────────────────────────────────────────────────────┤
│          Layer 2: Knowledge                         │
│      Source Bases (RAG) · Vector DBs               │
├─────────────────────────────────────────────────────┤
│          Layer 3: Agents                            │
│   Specialized Agents · MCP Client · Local/Remote   │
├─────────────────────────────────────────────────────┤
│          Layer 4: Storage                           │
│  Conversation History · Agent State · Registry DB  │
├─────────────────────────────────────────────────────┤
│          Layer 5: Integration &amp;amp; Observability       │
│    MCP Server · External Tools · Trace · Evals     │
└─────────────────────────────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Layer 1 — The Orchestration Layer: Your AI Conductor
&lt;/h2&gt;

&lt;p&gt;This is the component that kills the dinner party chaos problem. Without it, you have a group chat where everyone shouts simultaneously. With it, you have a conductor who decides who plays, when, and with what information.&lt;/p&gt;

&lt;p&gt;The orchestrator is responsible for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Routing tasks to the correct agent(s)&lt;/li&gt;
&lt;li&gt;Managing execution order and sequencing&lt;/li&gt;
&lt;li&gt;Preventing duplicate or conflicting work&lt;/li&gt;
&lt;li&gt;Synthesizing outputs from multiple agents into a coherent result
Embedded within the orchestration layer is a &lt;strong&gt;Classifier&lt;/strong&gt; — a component using NLU or LLM-based intent detection to understand what kind of request just arrived. "This needs the research agent." "This needs both the research and writing agents, in sequence." "This is ambiguous and requires a clarification step before routing."&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;strong&gt;Agent Registry&lt;/strong&gt; is the orchestrator's phonebook. It knows what agents exist, what capabilities each one exposes, and whether each agent is currently available. At small scale (2–3 agents), this is trivial. At production scale with dozens of specialized agents, a governed registry is the only way to keep routing reliable without hard-coding every path.&lt;/p&gt;

&lt;p&gt;Microsoft's Agent Framework (MAF) — a fusion of Semantic Kernel and AutoGen — implements this pattern. But the concepts apply regardless of framework. LangGraph's node-based routing, CrewAI's role-based delegation, and custom orchestrators all need to solve the same problem: &lt;strong&gt;deterministic routing with dynamic capability discovery&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Layer 2 — The Knowledge Layer: Institutional Memory
&lt;/h2&gt;

&lt;p&gt;Agents need two kinds of knowledge access: &lt;strong&gt;domain-specific content&lt;/strong&gt; and &lt;strong&gt;semantic search over unstructured data&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Source Bases&lt;/strong&gt; are where you store the specialized content that transforms general-purpose AI responses into expert answers. Policy documents. Product FAQs. Regulatory guidelines. Internal runbooks. The implementation varies — knowledge graphs, document repositories, fine-tuned models — but the goal is consistent: give agents the specific information they need to be right about your domain, not just right in general.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Vector databases&lt;/strong&gt; enable semantic search over that content. When a support agent searches "issues with login after password reset," vector search understands the semantic relationship between authentication state and credential management. Keyword matching doesn't.&lt;/p&gt;

&lt;p&gt;The critical retrieval decision that most teams get wrong: &lt;strong&gt;RAG vs. MCP is not a style preference. It is a functional distinction.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Use RAG when:
  - Content is static or semi-static (policy docs, FAQs, guides)
  - Search relevance is the primary quality lever
  - You need to synthesize across multiple documents

Use MCP when:
  - The agent needs real-time system state
  - The operation writes or modifies data
  - You need live API access (inventory, CRM, ERP)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;"How many units of SKU-123 are in stock right now?" is not a search question. It's an API call to your ERP. Routing it through RAG produces a stale answer. Routing it through an MCP tool call produces the live value.&lt;/p&gt;

&lt;p&gt;The mistake teams make: reaching for RAG everywhere because it's simpler to set up, then spending three months debugging why the agent keeps giving wrong inventory data. The answer isn't better embeddings. The answer is the wrong retrieval pattern.&lt;/p&gt;




&lt;h2&gt;
  
  
  Layer 3 — The Agent Layer: Specialized Workers
&lt;/h2&gt;

&lt;p&gt;Each agent in the system is a specialist. A finance agent. A coding agent. A research agent. A customer-facing support agent. Each is fine-tuned or prompted for its domain, with access to the relevant subset of the knowledge layer.&lt;/p&gt;

&lt;p&gt;Agents communicate with external tools via &lt;strong&gt;MCP Client&lt;/strong&gt; — a standardized interface that handles authentication, manages connections, and formats requests consistently regardless of the target tool. This abstraction is what lets you swap out the underlying tool (say, switching from one search provider to another) without rewriting every agent that uses it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Local vs. Remote Agents: The Security Distinction That Matters
&lt;/h3&gt;

&lt;p&gt;This is the architectural decision most teams don't think about until something goes wrong.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Local agents&lt;/strong&gt; run in the same execution environment as the orchestrator. They communicate in-memory. They inherit the orchestrator's trust context. Fast, low-latency, straightforward to reason about.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Remote agents&lt;/strong&gt; operate across a network boundary. They might live in a different security zone, be owned by a different team, or be an external service. This creates five security requirements that don't apply to local agents:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. Authentication:  Verify the remote agent's identity before accepting its outputs
2. Authorization:   Enforce what data and tools the remote agent can access
3. Trust boundary:  Never assume a remote agent has the same permissions as the orchestrator
4. Data in transit: Encrypt everything crossing the network boundary
5. Audit:           Log every cross-boundary call with identity and payload
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Think of local agents as colleagues sharing an office — implicit trust, fast coordination. Remote agents are external contractors calling in. They need a badge, credentials, and an access review before you hand them anything sensitive.&lt;/p&gt;

&lt;p&gt;Agent-to-Agent (A2A) protocol handles the standardized communication pattern for remote agents. Microsoft Entra Agent Identity provides the identity infrastructure on Azure. But the discipline is organizational, not just technical — you need policy decisions about which agents can call which other agents before you write a single line of orchestration code.&lt;/p&gt;




&lt;h2&gt;
  
  
  Layer 4 — The Storage Layer: Where Most Systems Fail Quietly
&lt;/h2&gt;

&lt;p&gt;This is the layer that kills the amnesia problem. It is also, consistently, the layer teams underbuild first.&lt;/p&gt;

&lt;p&gt;A production multi-agent system requires three distinct types of persistent storage:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conversation History&lt;/strong&gt; — Every interaction, decision, and intermediate output across the workflow. This is what lets an agent in step 7 know what the agent in step 2 found. Without it, each agent starts from zero. With it, context accumulates across the full workflow.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Agent State&lt;/strong&gt; — The operational status and working configuration of each agent instance. If an agent crashes mid-task, agent state is what lets it recover — or lets a replacement agent pick up exactly where it left off. Without this, a transient failure means restarting the entire workflow.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Registry Storage&lt;/strong&gt; — Persistent metadata about what agents exist, what capabilities they expose, what their current health status is, and what their recent performance looks like. This is what backs the Agent Registry in Layer 1.&lt;/p&gt;

&lt;p&gt;The typical failure pattern: teams build agent state in memory. Works fine in development. Works fine in testing. Falls apart the first time an agent crashes in production, because the state was ephemeral and the workflow can't resume.&lt;/p&gt;

&lt;p&gt;Build persistent storage from day one. Retrofitting it into a production system that was designed around ephemeral state is significantly harder than building it correctly at the start.&lt;/p&gt;




&lt;h2&gt;
  
  
  Layer 5 — Integration and Observability: How You Stop Flying Blind
&lt;/h2&gt;

&lt;p&gt;This is the layer that kills the black box problem. It is also, almost universally, treated as an afterthought — and then desperately retrofitted after the first production incident that nobody could debug.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MCP Server&lt;/strong&gt; — the standardized interface that external tools expose to your agents. Databases, APIs, web search, calculators, code execution environments. The MCP Server pattern means agents interact with external tools through a consistent interface, with authentication and audit controls baked in, rather than through a proliferation of custom integrations that each have their own auth model and failure mode.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Observability&lt;/strong&gt; — real-time visibility into every agent action in the system:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Which agents are currently active?&lt;/li&gt;
&lt;li&gt;What tasks are in progress?&lt;/li&gt;
&lt;li&gt;Where are the latency bottlenecks?&lt;/li&gt;
&lt;li&gt;What is the per-agent token consumption and cost?&lt;/li&gt;
&lt;li&gt;Where do failures cluster?
Without this, you're flying blind. You will know something is wrong when a customer complains. You will not know which agent caused it, what state the system was in, or how to reproduce it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Evals (Evaluation Layer)&lt;/strong&gt; — the feedback loop that makes your system better over time. How accurately are agents completing their assigned tasks? Where are they making errors? What types of inputs cause failures? This data feeds back into the orchestration layer and the knowledge layer, enabling continuous improvement.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Without evals: you know your system is broken when users tell you
With evals:    you know your system is degrading before users notice
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The evaluation layer is how you close the loop between production behavior and system improvement. Without it, you're not iterating on a system — you're waiting for complaints.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why This Architecture Is Engineering Pragmatism, Not Research
&lt;/h2&gt;

&lt;p&gt;What makes this five-layer model compelling isn't novelty. It's that it solves the concrete problems that show up in real production deployments:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scalability&lt;/strong&gt; — New agents can be added without rewriting orchestration logic. The registry discovers new capabilities automatically. The routing classifier routes to them without hardcoded rules.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Debuggability&lt;/strong&gt; — Proper observability and persistent state mean that when something fails, you can trace exactly what happened. Every agent action is logged. Every state transition is recorded. Failure is reproducible.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reliability&lt;/strong&gt; — Persistent agent state means individual failures don't cascade. A crashed agent can be restarted and resume where it left off. The supervisor pattern in the orchestration layer catches local failures before they propagate.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Flexibility&lt;/strong&gt; — Local and remote agent separation means different parts of the system can scale independently based on load and security requirements. The knowledge layer can be updated without touching the agent layer.&lt;/p&gt;




&lt;h2&gt;
  
  
  Key Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The failure is almost never in the model.&lt;/strong&gt; The three failure modes — chaos (no orchestration), amnesia (no memory), black box (no observability) — are architectural failures. Upgrading to a better model doesn't fix them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Build the storage layer first.&lt;/strong&gt; Agent state persistence is the most commonly underfed layer and the hardest to retrofit. Design for it from day one, even if your first version is simple.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;RAG and MCP are not interchangeable.&lt;/strong&gt; One retrieves from static content via search. The other calls live systems via APIs. Using the wrong one for the job produces wrong answers that look right.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Remote agents need explicit security architecture.&lt;/strong&gt; Authentication, authorization, trust boundary enforcement, and audit logging are not optional once you cross a network boundary. Plan the policy before you write the routing code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Observability is not an afterthought.&lt;/strong&gt; You cannot improve a system you cannot see. Trace every agent action. Measure token cost and latency per agent. Feed production failures back into your eval set within the week.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Closing Thought
&lt;/h2&gt;

&lt;p&gt;The dinner party didn't fail because the guests were bad at cooking. It failed because there was no system — no shared plan, no handoff protocol, no one tracking dependencies.&lt;/p&gt;

&lt;p&gt;Multi-agent AI systems fail the same way, for the same reason. Not because the models are weak. Because the architecture isn't there.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The question worth sitting with: which of these five layers is the weakest link in the system you're currently building?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you've shipped a multi-agent system and hit one of these failure modes — or found a pattern that works better than what's described here — I want to hear about it. Drop it in the comments.&lt;/p&gt;




</description>
      <category>ai</category>
      <category>architecture</category>
      <category>agents</category>
      <category>programming</category>
    </item>
    <item>
      <title>How AI Agents Will Reshape E-Commerce Architecture — And What Developers Need to Build Now</title>
      <dc:creator>shakti mishra</dc:creator>
      <pubDate>Sun, 17 May 2026 22:01:13 +0000</pubDate>
      <link>https://dev.to/shakti_mishra_308e9f36b5d/how-ai-agents-will-reshape-e-commerce-architecture-and-what-developers-need-to-build-now-5h1i</link>
      <guid>https://dev.to/shakti_mishra_308e9f36b5d/how-ai-agents-will-reshape-e-commerce-architecture-and-what-developers-need-to-build-now-5h1i</guid>
      <description>&lt;h2&gt;
  
  
  Your Next Customer Won't Click. They'll Delegate.
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The commerce interface is changing. And it's not another redesign.
&lt;/h3&gt;

&lt;p&gt;Think about the last time you booked a business trip.&lt;/p&gt;

&lt;p&gt;You opened six tabs. You compared prices on three airline sites. You checked your credit card rewards portal. You pulled up the hotel loyalty app. You looked at Google Maps for the office address. You Googled cancellation policies. You re-entered your corporate card number on the fourth checkout page.&lt;/p&gt;

&lt;p&gt;Now consider this instead:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Book my Chicago trip. Keep it under travel policy. Prioritize hotels near the board office. Use loyalty points only if the redemption value makes sense. Book dinner for four on Tuesday. Ask me before the final purchase."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;One instruction. An AI agent handles the rest — comparing options, checking policy compliance, querying loyalty status, booking the restaurant, creating the itinerary, then surfacing a single approval screen.&lt;/p&gt;

&lt;p&gt;You don't browse. You delegate intent.&lt;/p&gt;

&lt;p&gt;That shift — from human navigation to agent execution — is the premise behind agentic commerce. And if you're an engineer building systems that touch retail, payments, loyalty, fulfillment, or customer identity, this isn't a future-state thought experiment. The protocol stack making this possible is being standardized right now.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why This Is an Architectural Problem, Not a UX Problem
&lt;/h2&gt;

&lt;p&gt;Most discussions about AI agents in commerce focus on the customer experience side: "What will shopping feel like?" That's the wrong frame for engineers.&lt;/p&gt;

&lt;p&gt;The more useful question is: &lt;strong&gt;What does your system need to expose for an AI agent to trust and transact with it?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Your landing pages, checkout flows, and banner ads were designed for a human with 200ms of attention. An AI agent has different requirements:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Structured, machine-readable product data&lt;/li&gt;
&lt;li&gt;Programmatic access to pricing, inventory, cancellation policies, and promotions&lt;/li&gt;
&lt;li&gt;A secure, permissioned payment layer with auditable authorization&lt;/li&gt;
&lt;li&gt;Real-time fulfillment status with clear SLA signals
If any of these are locked inside a human-facing frontend with no API surface, you don't just have a bad UX — you're invisible to agents.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  The Six-Layer Stack Enabling Agentic Commerce
&lt;/h2&gt;

&lt;p&gt;The acceleration here isn't coming from one model. It's coming from a stack of interoperability protocols converging at the same time.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Model Context Protocol (MCP)
&lt;/h3&gt;

&lt;p&gt;Agents need more than prompts. They need a standardized way to call tools, retrieve context, and operate across systems without every team building one-off integrations.&lt;/p&gt;

&lt;p&gt;In a commerce context, MCP means an agent can check your live inventory, apply a loyalty rule, read a return policy, and create a support case — all through a consistent interface. Think of it as the "USB standard" for agent-to-system communication.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Agent-to-Agent Protocol (A2A)
&lt;/h3&gt;

&lt;p&gt;Commerce won't stay as one agent talking to one website.&lt;/p&gt;

&lt;p&gt;Customer agents will negotiate with merchant agents. Broker agents will aggregate options across providers. Fulfillment agents will coordinate between inventory, shipping, and support. A2A, pushed forward by Google and the broader ecosystem, defines how agents exchange capabilities, task status, context, and multimodal outputs across vendor boundaries.&lt;/p&gt;

&lt;p&gt;Without A2A, every agent integration is a bespoke negotiation. With it, agents interoperate like services in a well-designed microservices architecture.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Agent Payments Protocol (AP2)
&lt;/h3&gt;

&lt;p&gt;This is the clearest sign that agentic commerce is leaving demo territory and entering the transaction layer.&lt;/p&gt;

&lt;p&gt;The core primitive is the &lt;strong&gt;mandate&lt;/strong&gt; — a structured object that ties together user intent, cart details, spending limits, and payment authorization into a single auditable unit.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"agent_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"travel_agent_789"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"customer_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"customer_123"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"allowed_category"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"business_travel"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"max_transaction_amount"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"approval_required_above"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"valid_until"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2026-06-30"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"purpose"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Chicago board meeting"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This isn't just payment data. It's &lt;strong&gt;identity + consent + policy + fraud control in one verifiable package.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Merchants need to know the agent had authority. Customers need revocation controls and spending floors. Payment networks need fraud signals. Enterprises need audit trails. The mandate solves all of these at once — without requiring a human to be in the loop for every transaction.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Computer-Use Agents
&lt;/h3&gt;

&lt;p&gt;When APIs don't exist, agents use the browser.&lt;/p&gt;

&lt;p&gt;Computer-use agents can click buttons, fill forms, and navigate UI flows — effectively automating workflows that were never designed for programmatic access. It's fragile at scale and hard to govern, but for niche domains where building a formal API isn't cost-justified, it's a working bridge to the agentic future.&lt;/p&gt;

&lt;p&gt;The implication: even if you haven't invested in an API layer, agents will find a way in. Better to build the surface intentionally.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Contextual Personalization with Memory
&lt;/h3&gt;

&lt;p&gt;Traditional personalization asks: "What did this user click last week?"&lt;/p&gt;

&lt;p&gt;Agentic personalization asks: "What is this person trying to accomplish right now, given their current context, stated constraints, historical preferences, and active policy rules?"&lt;/p&gt;

&lt;p&gt;The architectural shift is from collaborative filtering over past behavior to &lt;strong&gt;intent inference over live context&lt;/strong&gt;. This requires memory architectures, preference stores, vector search, and policy-aware recommendation layers — not just a recommendation engine.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Dynamic Real-Time Planning
&lt;/h3&gt;

&lt;p&gt;What makes the travel scenario actually work isn't the flight booking. It's the replanning.&lt;/p&gt;

&lt;p&gt;If the flight changes, the itinerary adjusts. If the hotel sells out, the agent finds the next best option that still satisfies the policy constraints. If an expense crosses a threshold, the workflow escalates to a human approval step.&lt;/p&gt;

&lt;p&gt;This is orchestration with conditional branching across external state — not a linear task list. The agent manages a live plan, not a static sequence.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Three Ways Agents Interact With Your Business
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌─────────────────────────────────────────────────────────┐
│                 AGENTIC COMMERCE INTERACTION MODELS      │
├─────────────────┬──────────────────┬────────────────────┤
│  AGENT-TO-SITE  │ AGENT-TO-AGENT   │  BROKERED A2A      │
│                 │                  │                    │
│ Customer agent  │ Customer agent   │ Broker agent sits  │
│ visits your     │ talks directly   │ between customer   │
│ website via     │ to your business │ and multiple       │
│ browser or API  │ agent            │ merchants          │
│                 │                  │                    │
│ Your site is a  │ Negotiation and  │ Your business is   │
│ machine-readable│ real-time offer  │ one option in      │
│ decision surface│ exchange layer   │ someone else's     │
│                 │                  │ ranking system     │
└─────────────────┴──────────────────┴────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Agent-to-site&lt;/strong&gt; is the starting point: an agent scrapes your catalog, reads your policies, and completes checkout via your existing interface or API. Your website stops being a purely human experience and becomes a machine-readable decision surface.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Agent-to-agent&lt;/strong&gt; is where it gets commercially interesting. Instead of scraping, the customer's agent contacts your business agent directly:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Customer agent:&lt;/strong&gt; "I need a hotel near downtown Chicago for three nights. My traveler has Gold status. Can you improve the offer if they add breakfast?"&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Merchant agent:&lt;/strong&gt; "Yes. 12% off if breakfast is bundled and the reservation is prepaid."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That's not a chatbot interaction. That's a &lt;strong&gt;commerce negotiation layer&lt;/strong&gt; — requiring access to inventory, pricing, loyalty rules, margin thresholds, fraud signals, and payment authorization.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Brokered agent-to-site&lt;/strong&gt; is the model every product leader should be paying attention to. A third-party broker agent sits between the customer and many businesses, comparing options and recommending a transaction. Think Expedia or Instacart, but generalized across categories and powered by agents instead of static search.&lt;/p&gt;

&lt;p&gt;If the broker owns the customer relationship, your business becomes an option in someone else's ranking function. That ranking function will score on price, availability, reliability, refund flexibility, fulfillment confidence, and API quality — not brand loyalty.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Six Domains to Audit Right Now
&lt;/h2&gt;

&lt;p&gt;Agentic commerce isn't a marketing channel upgrade. It's an infrastructure readiness problem. Here's where to look first:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Agent Discoverability
&lt;/h3&gt;

&lt;p&gt;Your catalog needs to be legible to agents — not just humans. That means structured metadata, accurate availability signals, machine-readable policies, and programmatic access via APIs or MCPs.&lt;/p&gt;

&lt;p&gt;SEO doesn't disappear, but the question shifts from "can Google index this?" to "can an agent confidently determine when my offer is the best fit for a user's stated intent?"&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Loyalty and Clienteling APIs
&lt;/h3&gt;

&lt;p&gt;Most loyalty systems were built for humans checking points in a mobile app. Agents need to query loyalty tier status, unused reward balances, eligible promotions, redemption rules, and personalized offers — programmatically, with proper permissioning.&lt;/p&gt;

&lt;p&gt;If your loyalty program is human-only, agents will skip it. If it exposes clean, secured APIs, agents can actively use it to make better decisions on behalf of the customer.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Payment Mandates and Fraud Defense
&lt;/h3&gt;

&lt;p&gt;This is the hardest surface to get right.&lt;/p&gt;

&lt;p&gt;Recommending a product is one thing. Spending money is another. Your payment system needs to answer: who authorized this agent, what is the spending limit, what categories are allowed, when is human approval required, and how does the merchant verify the agent had authority?&lt;/p&gt;

&lt;p&gt;The mandate structure in the AP2 spec (see JSON above) gives you a template. The implementation details — token management, revocation, fraud signal integration, audit logging — are where most teams will underestimate the work.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. API-First Commerce Platform
&lt;/h3&gt;

&lt;p&gt;If core commerce actions (search, cart, pricing, promotions, checkout, order status, returns, support escalation) live only inside a frontend, agents will struggle or fall back to fragile browser automation.&lt;/p&gt;

&lt;p&gt;The architectural shift is from &lt;strong&gt;website-first commerce&lt;/strong&gt; to &lt;strong&gt;capability-first commerce&lt;/strong&gt;. The website becomes one client. Agents become another. Both consume the same underlying APIs.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. In-Store and Physical Handoff
&lt;/h3&gt;

&lt;p&gt;Agentic commerce won't stay digital. A customer agent may pre-authorize a purchase, apply a loyalty benefit, and schedule a pickup — all before the customer walks into a store. If the in-store POS can't read that agent-initiated context, the handoff breaks.&lt;/p&gt;

&lt;p&gt;Omnichannel isn't a new idea, but agentic commerce makes agent-initiated online journeys completing in physical channels a first-class requirement rather than a nice-to-have.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Real-Time Fulfillment and Returns APIs
&lt;/h3&gt;

&lt;p&gt;Agents will track, change, cancel, return, and escalate on behalf of customers. That requires real-time visibility into order state, inventory, shipping, return eligibility, and replacement availability.&lt;/p&gt;

&lt;p&gt;A slow or poorly documented fulfillment API doesn't just create a bad experience — it can cost you the sale before a human customer ever sees your brand, because the broker agent ranked you lower based on fulfillment confidence.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Market Signal Behind This
&lt;/h2&gt;

&lt;p&gt;McKinsey projects that by 2030, the US B2C retail market could see up to &lt;strong&gt;$1 trillion in orchestrated revenue from agentic commerce&lt;/strong&gt;, with global projections reaching &lt;strong&gt;$3–5 trillion&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;That's not a number to build a product roadmap around directly. But it's a signal worth taking seriously when deciding whether API-first commerce infrastructure is a 2-year investment or a 5-year one.&lt;/p&gt;

&lt;p&gt;Claude's recent releases of finance-focused and small business agents is an early indicator of how quickly vertical specialization is happening. When vertical-specific agents exist and are being actively used, your industry isn't far behind on the adoption curve.&lt;/p&gt;




&lt;h2&gt;
  
  
  Key Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The customer interface is shifting from clicks to delegated intent.&lt;/strong&gt; Agents browse, compare, negotiate, and transact on behalf of users. Your checkout button may become an artifact of the human-browsing era.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Three interaction models define agentic commerce:&lt;/strong&gt; agent-to-site (machine-readable storefronts), agent-to-agent (negotiation layers), and brokered agent-to-site (third-party ranking systems you don't control).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;MCP, A2A, and AP2 are the protocol foundation.&lt;/strong&gt; These three specifications are converging to make agents interoperable, transactable, and auditable at scale.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Payment mandates are the trust primitive.&lt;/strong&gt; AP2 mandates combine identity, consent, policy, and fraud control into a single auditable object — the unit of authorization for autonomous purchases.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Six audit domains matter most right now:&lt;/strong&gt; agent discoverability, loyalty APIs, payment mandates, API-first platforms, physical POS integration, and real-time fulfillment. Falling behind on any one of them makes you invisible or low-ranked in the agentic commerce stack.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Closing CTA
&lt;/h2&gt;

&lt;p&gt;If agentic commerce scales the way the protocol investment suggests, the question for most product and engineering teams isn't whether to prepare — it's &lt;em&gt;which surface to expose first.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So here's what I'm curious about:&lt;/strong&gt; If an AI agent were evaluating your system right now, what would it find hardest to interpret — your pricing, your policies, your loyalty system, or your payment layer? And is that the same problem your human customers complain about?&lt;/p&gt;

&lt;p&gt;Drop your answer in the comments. I suspect the answer is the same surface in both cases.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>webdev</category>
      <category>architecture</category>
      <category>agents</category>
    </item>
  </channel>
</rss>
