<?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: OckhamNode</title>
    <description>The latest articles on DEV Community by OckhamNode (@ockhamnode).</description>
    <link>https://dev.to/ockhamnode</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3886977%2Fe8798b0d-1207-4da9-a385-b81322d8d941.png</url>
      <title>DEV Community: OckhamNode</title>
      <link>https://dev.to/ockhamnode</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ockhamnode"/>
    <language>en</language>
    <item>
      <title>Why we stopped passing JSON between AI Agents (and built a Concurrent Trie instead)</title>
      <dc:creator>OckhamNode</dc:creator>
      <pubDate>Sun, 19 Apr 2026 06:38:51 +0000</pubDate>
      <link>https://dev.to/ockhamnode/why-we-stopped-passing-json-between-ai-agents-and-built-a-concurrent-trie-instead-2d9d</link>
      <guid>https://dev.to/ockhamnode/why-we-stopped-passing-json-between-ai-agents-and-built-a-concurrent-trie-instead-2d9d</guid>
      <description>&lt;p&gt;If you’ve spent any time building multi-agent AI systems recently (using frameworks like AutoGen, CrewAI, or LangGraph), you’ve probably hit the exact same wall we did. &lt;/p&gt;

&lt;p&gt;It starts great. You chain three agents together: a &lt;strong&gt;Researcher&lt;/strong&gt;, a &lt;strong&gt;Writer&lt;/strong&gt;, and a &lt;strong&gt;Reviewer&lt;/strong&gt;. But as the context grows, the architecture begins to collapse under its own weight. &lt;/p&gt;

&lt;p&gt;We realized the standard way of handling state in AI swarms is fundamentally broken. Here is why, and how we engineered our way out of it by building a tier-1 concurrent state broker in Go called &lt;a href="https://github.com/OckhamNode/hyperloom" rel="noopener noreferrer"&gt;Hyperloom&lt;/a&gt;.&lt;/p&gt;




&lt;h3&gt;
  
  
  The Bottleneck: The "Token Tax"
&lt;/h3&gt;

&lt;p&gt;Right now, the industry standard for multi-agent communication is passing massive JSON objects around. &lt;br&gt;
If your swarm has generated 50,000 tokens of context, Agent 4 receives &lt;em&gt;all&lt;/em&gt; 50,000 tokens, parses them, appends its own 2,000 tokens, and passes 52,000 tokens to Agent 5.&lt;/p&gt;

&lt;p&gt;This is an architectural anti-pattern. It’s the equivalent of sending an entire Postgres database over a REST API just to update a single column. It results in massive API bills and horrific latency. &lt;/p&gt;

&lt;h3&gt;
  
  
  The Breaking Point: Cascading Hallucinations
&lt;/h3&gt;

&lt;p&gt;The breaking point for us wasn't just the cost; it was the brittleness. &lt;/p&gt;

&lt;p&gt;If Agent 4 in a 5-step pipeline hallucinates a corrupted JSON schema, the workflow crashes. Because the state is passed linearly, a failure at Step 4 destroys the compute and API costs spent on Steps 1, 2, and 3. You have to restart the entire loop. &lt;/p&gt;

&lt;p&gt;Using traditional databases (Redis/Postgres) to store this state didn't work either. If you have 20 agents trying to read and write to a shared memory pool simultaneously, locking an entire JSON row in a database creates a massive swarm-wide bottleneck.&lt;/p&gt;




&lt;h3&gt;
  
  
  The Shift: Treating AI State like Tier-1 Infrastructure
&lt;/h3&gt;

&lt;p&gt;We decided to stop treating LLM context as a massive string and start treating it as a highly concurrent distributed system. &lt;/p&gt;

&lt;p&gt;We built &lt;strong&gt;Hyperloom&lt;/strong&gt; a Memory Graph and Context Broker that uses a &lt;strong&gt;Concurrent Trie Forest&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Instead of agents passing state directly to each other, they act as decoupled microservices. They subscribe to the broker. When an agent finishes a thought, it doesn't pass the whole history; it publishes a localized &lt;code&gt;context_diff&lt;/code&gt; (e.g., just the new paragraph it wrote).&lt;/p&gt;

&lt;h4&gt;
  
  
  Fine-Grained Locking in Go
&lt;/h4&gt;

&lt;p&gt;Instead of locking the entire memory tree during a write, we implemented &lt;code&gt;sync.RWMutex&lt;/code&gt; locks at the &lt;em&gt;node level&lt;/em&gt; of the Trie. &lt;/p&gt;

&lt;p&gt;This means Agent A can update the &lt;code&gt;/session_1/memory&lt;/code&gt; path while Agent B simultaneously appends to &lt;code&gt;/session_1/intent&lt;/code&gt; without ever blocking each other. The swarm can scale to thousands of concurrent reads/writes.&lt;/p&gt;

&lt;h4&gt;
  
  
  The Rollback Engine ("Ghost Branches")
&lt;/h4&gt;

&lt;p&gt;To solve the hallucination problem, we implemented Speculative Execution.&lt;br&gt;
When an agent submits an action, it writes to a "Ghost Branch" (a shadow state). If your verification logic flags a 400 error (e.g., bad JSON, failed tool call), the broker calls &lt;code&gt;Revert()&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;The broker instantly drops the corrupted pointer in $&amp;lt; 1ms$. The bad memory is cleanly severed from the graph, and the agent is forced to retry from the last valid checkpoint. No pipeline crashes. No wasted downstream compute.&lt;/p&gt;




&lt;h3&gt;
  
  
  The Result: The Time-Travel Debugger
&lt;/h3&gt;

&lt;p&gt;Because the backend is essentially an append-only event stream of state diffs, we realized we had accidentally built a version control system for AI thoughts.&lt;/p&gt;

&lt;p&gt;To make this usable, we built a Next.js/React Flow frontend that hooks into Hyperloom's WebSocket stream. &lt;/p&gt;

&lt;p&gt;You can visually watch the tree of agent thoughts grow in real-time. If an agent hallucinates, the node flashes red and is pruned. Even better you can grab a timeline slider, scrub backward through the swarm's execution, and click on any node to see exactly what context an agent was looking at before it made a mistake.&lt;/p&gt;




&lt;h3&gt;
  
  
  Try it out (We Open-Sourced it)
&lt;/h3&gt;

&lt;p&gt;We kept the broker entirely in-memory for now to hit ~2,000 req/s, but we are actively exploring the best way to implement a zero-blocking Write-Ahead Log (WAL) for durability. &lt;/p&gt;

&lt;p&gt;We also shipped it with a native &lt;strong&gt;MCP (Model Context Protocol)&lt;/strong&gt; bridge, so Claude Desktop can read/write to the graph directly.&lt;/p&gt;

&lt;p&gt;You can spin up the entire broker locally with one command:&lt;br&gt;
&lt;code&gt;docker run hyperloom&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Check out the repo here:&lt;/strong&gt; &lt;a href="https://github.com/OckhamNode/hyperloom" rel="noopener noreferrer"&gt;OckhamNode/hyperloom&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I’d love for the Go engineers and AI builders here to tear the architecture apart. Are we crazy for using &lt;code&gt;sync.RWMutex&lt;/code&gt; at the node level instead of a purely lock-free data structure? Let me know in the comments.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>opensource</category>
      <category>architecture</category>
      <category>go</category>
    </item>
  </channel>
</rss>
