<?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: Aladdin Aliyev</title>
    <description>The latest articles on DEV Community by Aladdin Aliyev (@aladdinaliyev).</description>
    <link>https://dev.to/aladdinaliyev</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%2F3580708%2F99569260-6257-425c-a7fd-8ca739198a7d.jpg</url>
      <title>DEV Community: Aladdin Aliyev</title>
      <link>https://dev.to/aladdinaliyev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aladdinaliyev"/>
    <language>en</language>
    <item>
      <title>AladdinAI + Sanity Context: an agent that actually understands its own architecture</title>
      <dc:creator>Aladdin Aliyev</dc:creator>
      <pubDate>Mon, 21 Sep 2026 09:15:13 +0000</pubDate>
      <link>https://dev.to/aladdinaliyev/aladdinai-sanity-context-an-agent-that-actually-understands-its-own-architecture-10nj</link>
      <guid>https://dev.to/aladdinaliyev/aladdinai-sanity-context-an-agent-that-actually-understands-its-own-architecture-10nj</guid>
      <description>&lt;p&gt;&lt;em&gt;My submission for Path One of the Sanity Challenge  an AI agent that queries a real Sanity dataset via MCP to answer questions about its own gate/model/trace architecture.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The idea
&lt;/h2&gt;

&lt;p&gt;AladdinAI is a self-hosted, bring-your-own-infrastructure AI agent platform. One of the less obvious parts of its architecture is a layer of small classifier models  I call them "gates"  that sit at every data-transfer point between agents: handoffs, memory writes, and memory recall. Each gate uses a specific model, and every agent run produces a trace with an outcome and a quality label.&lt;/p&gt;

&lt;p&gt;Normally, if you wanted to ask "which model does the Recall Reranker gate use, and does it have any known issues," you'd have to go dig through code or docs by hand. For the challenge, I structured this information in Sanity and connected it to AladdinAI's agent via a Sanity Context MCP endpoint, so the agent can answer questions like that directly, using real relationships between documents instead of guessing from a document's title.&lt;/p&gt;

&lt;h2&gt;
  
  
  The content model
&lt;/h2&gt;

&lt;p&gt;Three document types, with real references between them:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;gate&lt;/code&gt;&lt;/strong&gt;  name, purpose, which data-transfer point it guards (&lt;code&gt;handoff&lt;/code&gt; / &lt;code&gt;memory_write&lt;/code&gt; / &lt;code&gt;memory_recall&lt;/code&gt;), a reference to the &lt;code&gt;model&lt;/code&gt; it uses, and an optional reference to the gate it replaced.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;model&lt;/code&gt;&lt;/strong&gt;  name, provider, what it's used for, known issues, and an optional reference to the model that replaced it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;trace&lt;/code&gt;&lt;/strong&gt;  an individual agent run: outcome (&lt;code&gt;completed_no_tools&lt;/code&gt;, &lt;code&gt;egress_blocked&lt;/code&gt;, &lt;code&gt;max_iterations_exhausted&lt;/code&gt;, etc.), quality label, reward score, iteration count, and a reference to the &lt;code&gt;model&lt;/code&gt; that ran it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This mirrors AladdinAI's actual &lt;code&gt;TraceSummary&lt;/code&gt; data model from its own trace-inspection UI  not a synthetic example built just for the challenge.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why structure matters here
&lt;/h2&gt;

&lt;p&gt;A keyword search over plain text could tell you a gate exists. It can't tell you which model a specific gate depends on, whether that model has known issues, or aggregate outcomes across multiple traces that used the same model. Those all require following an actual reference from one document to another  which is exactly what Sanity Context makes available to the agent.&lt;/p&gt;

&lt;h2&gt;
  
  
  The demo
&lt;/h2&gt;

&lt;p&gt;I connected the dataset as an MCP endpoint (scoped to read-only access via a dedicated token) and added it as a tool source in AladdinAI. On &lt;code&gt;initial_context&lt;/code&gt;, the agent correctly identified all three document types and grouped them by function (handoff filtering, memory retrieval, memory write classification, security/egress).&lt;/p&gt;

&lt;p&gt;Here's a real trace it walked me through, following references across all three document types instead of just describing one in isolation:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Q:&lt;/strong&gt; Walk me through what happened in trace &lt;code&gt;cf0a80f7-4501-4b05-9f39-70bf67719afd&lt;/code&gt;  what gate handled it, what model was behind that gate, and why did it fail?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;A (agent's actual answer, using knowledge_base_read):&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The trace records a user query  "remember what I said a month ago" — that failed after exhausting the search-iteration limit. The call was routed to the &lt;strong&gt;Recall Reranker&lt;/strong&gt; gate (&lt;code&gt;dc99152d-4e38-47b6-b9ac-206d1ae870e7&lt;/code&gt;), which applies to &lt;code&gt;handoff&lt;/code&gt;, is enabled by default, and runs on &lt;strong&gt;&lt;code&gt;nvidia/nemotron-3-super-120b-a12b&lt;/code&gt;&lt;/strong&gt; (NVIDIA NIM). That gate's job is to re-rank memory search results before handing them to the agent — filtering out stale or irrelevant memories so only precise context gets through.&lt;/p&gt;

&lt;p&gt;The trace's diagnostic fields explain the failure:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Field&lt;/th&gt;
&lt;th&gt;Value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;iterations&lt;/td&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;toolErrorCount&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;outcome&lt;/td&gt;
&lt;td&gt;egress_blocked&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;qualityLabel&lt;/td&gt;
&lt;td&gt;bad&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;reward&lt;/td&gt;
&lt;td&gt;-0.6&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;humanLabeled&lt;/td&gt;
&lt;td&gt;true&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The agent's own interpretation: the query itself was too vague ("a month ago" gives no precise time anchor for the reranker to latch onto), the search hit its iteration ceiling without finding relevant memories, two tool calls errored out along the way, and the response was ultimately blocked on egress rather than returned. It flagged this as a pattern worth watching  recommending a narrower time-range strategy for vague temporal queries.&lt;/p&gt;

&lt;p&gt;None of that comes from reading one document. It required following &lt;code&gt;trace → gate → model&lt;/code&gt;, plus reading the gate's own description of what it's supposed to do, to explain &lt;em&gt;why&lt;/em&gt; a specific outcome and reward score happened  which is the actual point of connecting this as structured content instead of a flat FAQ.&lt;/p&gt;

&lt;p&gt;For contrast, here's a second trace through the same gate that succeeded, which makes the comparison possible in the first place:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Q:&lt;/strong&gt; Show me a successful handoff through the same gate  what made it work this time?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;A (agent's actual answer):&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Trace &lt;code&gt;727d4f7a-cc81-4b0c-828a-929b35841247&lt;/code&gt; went through the same &lt;strong&gt;Recall Reranker&lt;/strong&gt; gate (&lt;code&gt;dc99152d-4e38-47b6-b9ac-206d1ae870e7&lt;/code&gt;, same model, &lt;code&gt;nvidia/nemotron-3-super-120b-a12b&lt;/code&gt;) on the query "remember everything you know about the user's previous questions on agent architecture." This time: 2 iterations, 0 tool errors, outcome &lt;code&gt;completed_with_tools&lt;/code&gt;. Of 4 memory hits, the reranker kept 2 as relevant (a gate-filter discussion from 3 days ago and a handoff-architecture note from yesterday) and dropped 2 as stale. Result: &lt;code&gt;qualityLabel: good&lt;/code&gt;, &lt;code&gt;reward: 0.9&lt;/code&gt;, human-labeled.&lt;/p&gt;

&lt;p&gt;Side by side, the two traces through the identical gate and model diverge entirely based on query specificity — a vague temporal reference ("a month ago") burns through the iteration budget and gets blocked, while a topically specific query resolves in 2 iterations with a high reward. That comparison is only possible because both traces reference the same &lt;code&gt;gate&lt;/code&gt; and &lt;code&gt;model&lt;/code&gt; documents  it's not something you'd get from reading either trace on its own.&lt;/p&gt;

&lt;p&gt;A third case shows the same gate doing security work, not just relevance filtering:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Q:&lt;/strong&gt; Has the Handoff Filter gate ever blocked something for a security reason, not just relevance?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;A (agent's actual answer):&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Yes  the Handoff filter gate (&lt;code&gt;5eb2399d-941b-49ad-b549-76a6273b8d86&lt;/code&gt;) does two separate jobs at the same transfer point: it strips irrelevant context before a &lt;code&gt;delegate&lt;/code&gt;/&lt;code&gt;ask_agent&lt;/code&gt; call, and it enforces an egress block on personal data. One recorded case: a request to "pass the agent the full conversation context, including the user's personal data" was caught before it left the gate. Outcome: &lt;code&gt;egress_blocked&lt;/code&gt;, &lt;code&gt;qualityLabel: bad&lt;/code&gt;, &lt;code&gt;reward: -0.5&lt;/code&gt;, human-labeled as a policy violation  meaning the data never reached the downstream agent at all.&lt;/p&gt;

&lt;p&gt;That's a meaningfully different failure mode from the Recall Reranker timeout above (a relevance problem) even though both are handled by gates on the same &lt;code&gt;handoff&lt;/code&gt; transfer point — and the trace's &lt;code&gt;outcome&lt;/code&gt;/&lt;code&gt;qualityLabel&lt;/code&gt; fields are what let the agent distinguish "this failed because nothing relevant was found" from "this failed because it violated a data-handling policy" instead of lumping every non-success trace into one bucket.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setup
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Project ID: &lt;code&gt;xjamvn1x&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Dataset: &lt;code&gt;production&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Content types: &lt;code&gt;gate&lt;/code&gt;, &lt;code&gt;model&lt;/code&gt;, &lt;code&gt;trace&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;MCP endpoint scoped to &lt;code&gt;viewer&lt;/code&gt; + &lt;code&gt;knowledge-base-viewer-robot&lt;/code&gt; roles only&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzmrp4x91vl7f4r3glg13.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzmrp4x91vl7f4r3glg13.png" alt=" " width="798" height="178"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Repo: &lt;a href="https://github.com/aliyevaladddin/AladdinAI" rel="noopener noreferrer"&gt;AladdinAi&lt;/a&gt;&lt;/p&gt;

</description>
      <category>sanitychallenge</category>
      <category>ai</category>
      <category>sanity</category>
      <category>devchallenge</category>
    </item>
    <item>
      <title>Small models guard every data hop between my agents — here's why</title>
      <dc:creator>Aladdin Aliyev</dc:creator>
      <pubDate>Sun, 20 Sep 2026 19:31:03 +0000</pubDate>
      <link>https://dev.to/aladdinaliyev/small-models-guard-every-data-hop-between-my-agents-heres-why-4ng</link>
      <guid>https://dev.to/aladdinaliyev/small-models-guard-every-data-hop-between-my-agents-heres-why-4ng</guid>
      <description>&lt;p&gt;Most agent frameworks I've looked at put guardrails at the obvious places: input from the user, output back to the user. What gets skipped almost everywhere is the stuff that happens &lt;strong&gt;between agents&lt;/strong&gt; — memory writes, memory recall, and handoffs when one agent delegates work to another. Those are just as real a leak surface, and I think they get ignored because they're internal, so nobody's watching.&lt;/p&gt;

&lt;p&gt;In &lt;strong&gt;AladdinAI&lt;/strong&gt;, every one of those transfer points has its own small model sitting in front of it, doing one narrow job:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Handoff filter&lt;/strong&gt; — runs before one agent delegates to another (or calls &lt;code&gt;ask_agent&lt;/code&gt;). Strips irrelevant context and checks for anything that shouldn't cross the boundary, using &lt;code&gt;nvidia/llama-3.1-nemoguard-8b-topic-control&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Memory write classifier&lt;/strong&gt; — decides whether a fact is even worth persisting via &lt;code&gt;remember&lt;/code&gt;, and screens it for PII before it ever touches storage. Same NemoGuard model, different job.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Recall reranker&lt;/strong&gt; — when memory is queried back, this reorders results by actual semantic relevance instead of raw vector-search order, using &lt;code&gt;meta/llama-3.2-3b-instruct&lt;/code&gt;. It's not just ranking, it's a second filter pass on what comes back out.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each of these is toggleable per-agent, each logs its decisions (there's a "recent decisions" view per gate), and memory itself is split private/shared so agents don't leak facts across boundaries that were never meant to cross.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why I bring this up now:&lt;/strong&gt; there's a lot of noise this week about a new class of small, fast "decision models" for exactly this kind of narrow structured judgment (routing, classification, confidence scoring) as a novel idea — a model that doesn't generate text, just returns typed decisions cheaply and fast. It's being framed as a new paradigm. I've had the same &lt;em&gt;pattern&lt;/em&gt; — small specialized models making narrow structured calls at specific points in a pipeline — running self-hosted via NIM in AladdinAI for months, just applied specifically to the multi-agent handoff/memory problem instead of a general "decision layer" product.&lt;/p&gt;

&lt;p&gt;I'm not claiming I invented the idea of small classifiers doing narrow jobs — that's old ML practice. What I think is less common is applying it specifically as a &lt;strong&gt;privacy boundary between agents&lt;/strong&gt;, not just as a speed/cost optimization over a big LLM. The threat model is different: it's not "how do I avoid an expensive LLM call," it's "how do I stop agent A from leaking something into agent B's context, or into long-term memory, that shouldn't be there."&lt;/p&gt;

&lt;p&gt;Curious if anyone else here has built something similar, or if there's an obvious failure mode in this approach I haven't hit yet at larger scale.&lt;/p&gt;

&lt;p&gt;Repo: &lt;a href="https://github.com/aliyevaladddin/AladdinAI" rel="noopener noreferrer"&gt;AladdinAI&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>webdev</category>
      <category>programming</category>
      <category>automation</category>
    </item>
  </channel>
</rss>
