<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:googleplay="http://www.google.com/schemas/play-podcasts/1.0"><channel><title><![CDATA[sohit’s Newsletter]]></title><description><![CDATA[Tech]]></description><link>https://sohit.substack.com</link><image><url>https://substackcdn.com/image/fetch/$s_!QTwG!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsohit.substack.com%2Fimg%2Fsubstack.png</url><title>sohit’s Newsletter</title><link>https://sohit.substack.com</link></image><generator>Substack</generator><lastBuildDate>Mon, 22 Jun 2026 16:55:18 GMT</lastBuildDate><atom:link href="https://sohit.substack.com/feed" rel="self" type="application/rss+xml"/><copyright><![CDATA[sohit kumar]]></copyright><language><![CDATA[en]]></language><webMaster><![CDATA[sohit@substack.com]]></webMaster><itunes:owner><itunes:email><![CDATA[sohit@substack.com]]></itunes:email><itunes:name><![CDATA[sohit kumar]]></itunes:name></itunes:owner><itunes:author><![CDATA[sohit kumar]]></itunes:author><googleplay:owner><![CDATA[sohit@substack.com]]></googleplay:owner><googleplay:email><![CDATA[sohit@substack.com]]></googleplay:email><googleplay:author><![CDATA[sohit kumar]]></googleplay:author><itunes:block><![CDATA[Yes]]></itunes:block><item><title><![CDATA[Domain Understanding is Moat.]]></title><description><![CDATA[We have been hearing a lot about what the moat is.]]></description><link>https://sohit.substack.com/p/domain-understanding-in-moat</link><guid isPermaLink="false">https://sohit.substack.com/p/domain-understanding-in-moat</guid><dc:creator><![CDATA[sohit kumar]]></dc:creator><pubDate>Thu, 28 May 2026 17:58:15 GMT</pubDate><content:encoded><![CDATA[<p>We have been hearing a lot  about what the moat is. Some say the harness is the moat. Some say the model is the moat. It keeps changing every day.</p><p>What I believe is - <strong>the moat is domain understanding.</strong></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://sohit.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading sohit&#8217;s Newsletter! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>Domain understanding means knowing the customer&#8217;s workflows, constraints, edge cases, goals, failure modes, and what &#8220;good&#8221; actually means in their world.</p><p>You encode domain understanding into software.</p><p>Earlier, you encoded domain knowledge into workflows, databases, and CRUD APIs packaged as SaaS. The knowledge you were able to capture was limited because you could only read/write data and represent it through workflows. That is why we needed humans to work on top of SaaS to provide additional domain understanding which we could not encode.</p><p>Today, that domain understanding is being encoded in evals, prompts, and harnesses.</p><p>When folks say the harness is the moat -  they mean that during compaction, when you hit the context window, it is important to have past summaries to meet the outcome, so you use summarisation instead of a sliding window. This is nothing but domain understanding encoded in the harness. Claude Code&#8217;s harness understands the coding domain really well.</p><p>When folks say the model is the moat - they mean encoding domain understanding into model weights because we need to deliver value quickly and latency is important.</p><p>And may be tomorrow we can have specific chips which will help optimize and solve problem in certain domain.</p><p>But you get the idea. It is all about understanding the domain to deliver value to the customer. The shape and form can keep changing.</p><p>More you understand that, more value you can provide value to the customer. This is business 101 - provide value to the customer.</p><p>This why you want to have feedback loop - iterate fast and get feedback from customer/traces so that you can understand more about the domain you are operating in and encode that into your software and offload work from them as much as possible and provide more value. <em><strong>Feedback loop compounds your moat.</strong></em></p><p>And when you have constraints, you pick the best place to encode that domain understanding.</p><p>If training a model does not make business sense because of Capex, you encode it elsewhere: in the harness, prompts, skills, evals, memory, and context layer.</p><p>The form changes. The goal stays the same - capture domain understanding and deliver value to the customer.</p><p><em>The moat is how much domain understanding you can capture, encode, and compound inside the product.</em></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://sohit.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading sohit&#8217;s Newsletter! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Coding Agents Need Software Factories]]></title><description><![CDATA[Most engineering teams are making the same mistake with coding agents - confusing faster code generation with faster software delivery.]]></description><link>https://sohit.substack.com/p/coding-agents-need-software-factories</link><guid isPermaLink="false">https://sohit.substack.com/p/coding-agents-need-software-factories</guid><dc:creator><![CDATA[sohit kumar]]></dc:creator><pubDate>Wed, 20 May 2026 15:55:04 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!niAa!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72a482a9-eadd-4690-9e83-4515b6dff43c_1448x1086.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Most engineering teams are making the same mistake with coding agents - confusing faster code generation with faster software delivery.</p><p>The bottleneck was never just writing code. It was turning code into software the organization can trust and deploy.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://sohit.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading sohit&#8217;s Newsletter! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>A real software change often touches frontend, APIs, database migrations, infra, rollout flags, integration tests, monitoring, and deployment plans. It has to fit the architecture, respect service contracts, work across repos, pass the right tests, survive rollout, and be trusted in production.</p><p>This is where most coding agent workflows still break.</p><p>The agent writes the code, but the developer still carries the engineering system context - architecture, repo ownership, service contracts, verification paths, rollout risks, and memory of what failed last time.</p><p>I have seen agents open 10,000-line PRs and changes with multiple consumers. At that point, no one can confidently say whether the change works, what it breaks, or whether it still follows the architecture. PRs start queuing up. Reviews take days or weeks. Verification becomes the bottleneck.</p><p><strong>The real gap is between generating code and delivering software the organization can trust.</strong></p><p>This is why coding agents need software factories.</p><p><em><strong>A Software Factory is a control plane around coding agents. It preserves context, coordinates work, verifies outcomes, learns from every run, and improves itself.</strong></em></p><p>A Software Factory needs three things around coding agents:</p><ul><li><p><strong>A brain</strong> that holds the engineering context - repos, architecture, contracts, infra, ownership, decisions, failures, and verification paths.</p></li><li><p><strong>A sandbox</strong> where the factory can bring up the system, run checks, validate integrations, and prove the change works.</p></li><li><p><strong>A learning loop</strong> that turns failed runs and repeated manual work into better workflows, skills, and agents.</p></li></ul><p>Without this, agents produce changes that look right locally but fail at integration points. Developers still carry the context, risk, and memory. Every session starts from zero.</p><h2>Example: Cross-Repo Feature Development</h2><p>Imagine a feature touches three repositories owned by three teams.</p><p>The code changes are easy.</p><p>The problem is knowing what changes first, what depends on what, which contract can break, which tests need to run, and what has to be deployed in what order.</p><p>Today, a developer opens Codex or Claude in each repo and asks for the local change.</p><p>But the real coordination still happens in the developer&#8217;s head.</p><blockquote><p>This API is changing here.</p><p>This frontend needs to consume it.</p><p>This worker needs to emit a new event. Current infra setup needs to be considered.</p><p>This test needs to run after all three changes land.</p><p>This rollout should happen after the backend is deployed.</p><p>The agents are writing code. The developer is still doing the delivery work - coordinating branches, tests, PRs, dependencies, and hidden integration risks.</p></blockquote><p>In a Software Factory model, you ask once:</p><blockquote><p>Build this feature across the affected repos.</p></blockquote><p>The factory runs a simple loop:</p><p><strong>Spec &#8594; Build &#8594; Verify &#8594; Learn &#8594; Evolve</strong></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!niAa!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72a482a9-eadd-4690-9e83-4515b6dff43c_1448x1086.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!niAa!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72a482a9-eadd-4690-9e83-4515b6dff43c_1448x1086.png 424w, https://substackcdn.com/image/fetch/$s_!niAa!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72a482a9-eadd-4690-9e83-4515b6dff43c_1448x1086.png 848w, https://substackcdn.com/image/fetch/$s_!niAa!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72a482a9-eadd-4690-9e83-4515b6dff43c_1448x1086.png 1272w, https://substackcdn.com/image/fetch/$s_!niAa!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72a482a9-eadd-4690-9e83-4515b6dff43c_1448x1086.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!niAa!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72a482a9-eadd-4690-9e83-4515b6dff43c_1448x1086.png" width="1448" height="1086" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/72a482a9-eadd-4690-9e83-4515b6dff43c_1448x1086.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1086,&quot;width&quot;:1448,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1333282,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://sohit.substack.com/i/198578961?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72a482a9-eadd-4690-9e83-4515b6dff43c_1448x1086.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!niAa!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72a482a9-eadd-4690-9e83-4515b6dff43c_1448x1086.png 424w, https://substackcdn.com/image/fetch/$s_!niAa!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72a482a9-eadd-4690-9e83-4515b6dff43c_1448x1086.png 848w, https://substackcdn.com/image/fetch/$s_!niAa!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72a482a9-eadd-4690-9e83-4515b6dff43c_1448x1086.png 1272w, https://substackcdn.com/image/fetch/$s_!niAa!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72a482a9-eadd-4690-9e83-4515b6dff43c_1448x1086.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><p></p><ul><li><p>Spec Agent brainstorms and defines the outcome.</p></li><li><p>Build Agents brainstorms and turns the spec into coordinated changes across repos, contracts, data flows, and rollout paths and implement them.</p></li><li><p>Verification Agent proves whether the change actually works.</p></li><li><p>Learning Agent captures what was missing, what failed, and what needs to improve next time.</p></li><li><p>Evolve Agnet updates the factory so the next run is better.</p></li></ul><p>Human coordinates and brainstorm with these agents to ship the feature.</p><p>I ran this on a real change spanning four services, including frontend. The architect agent identified the repositories that needed to change, came up with high level design. It delegated the work to lead agents, who broke the request into steps, designed the implementation, and made the changes.</p><p>Then a verifier agent spun up the services, tested them, validated the frontend-backend integration, captured screenshots of the working flow using Playwright MCP, and produced a PR summary reviewers could trust.</p><p>The system did not just generate code. It coordinated the change, verified the outcome, and produced evidence for review.</p><p><em><strong>Instead of asking an agent to make a code change, you ask the factory to deliver a change.</strong></em></p><h2>The Factory Is Not Just For Code Changes</h2><p>Once the factory has the engineering brain, it is not limited to feature work.</p><p>It can diagnose production, cost, reliability, security, and compliance issues because all of them are connected to code, infra, data flows, ownership, policies, and deployment history.</p><p>For example, I asked the factory for the top three cost drivers from last month and the reason behind each spike.</p><p>The main agent connected to AWS, pulled last month&#8217;s cost data, identified the top three services driving spend, checked metrics and infra configuration, correlated the spike with code changes and deployment history, and was able to pinpoint the repo and module where the increase came from.</p><p>A normal coding agent cannot do that by only reading the codebase.</p><p>A shallow answer would be:</p><blockquote><p>Your database costs are high.</p></blockquote><p>A useful answer is:</p><blockquote><p>Cost increased after this deployment by 28%.</p><p>The spike came from this worker because a filter moved from the database layer to application code.</p><p>The affected repos are <code>backend-api</code> and <code>reporting-worker</code>.</p><p>Verification should include query plan comparison, worker runtime tests, and a cost estimate after replaying the workload.</p></blockquote><p>The useful part is that it can trace the issue back properly - which deployment caused the spike, which service changed, which repo owns it, and what needs to be tested before the fix goes out.</p><p>The same factory that helps ship features can also help debug cost, reliability, security, and compliance issues.</p><p>The foundation is the same - <em>connected context, verification, and learning loop.</em></p><h2>The Brain Is The Engineering Context Layer</h2><p>The brain gives the factory its engineering memory.</p><p>It cannot be a folder of docs or one long prompt. It needs to behave like a knowledge graph: repos, services, contracts, workflows, infra, tests, owners, decisions, failures, and skills connected to each other.</p><p>This is important because engineering knowledge is not flat.</p><ul><li><p>A code change depends on architecture.</p></li><li><p>Architecture depends on infra.</p></li><li><p>Infra affects cost, reliability, and security.</p></li><li><p>Verification depends on service contracts.</p></li><li><p>Future work depends on decisions made today.</p></li></ul><p>The knowledge graph helps the factory understand these connections: which repo owns an API, which service consumes an event, which migration affects a workflow, which test proves a contract still works, which past failure needs to be considered, and which agent or skill fits the work.</p><p><em><strong>If agents do not have access to that connected system context, they will keep producing changes that pass locally and fail in production</strong></em></p><p>Once it knows the affected repos, contracts, workflows, and verification paths, it decides which agents are involved, what each agent does, which repos need changes, what order the work happens in, and how the final change comes together.</p><p>Every meaningful change gets checked against the architecture, contracts, ownership boundaries, operational patterns, and previous decisions.</p><p>For simple work, the factory keeps the path lightweight -one agent, one repo, one clear verification step.</p><p>For larger work, it coordinates multiple agents across frontend, backend, infra, tests, and documentation.</p><p>Developers should not be the coordination layer. They should not have to remember which repo changed, which branch depends on what, which test proves the contract, or which dependency can break the release.</p><p>The factory coordinates the run.</p><p>Developers should guide the system when judgment is needed, not manually coordinate every repo, branch, test, and rollout step.</p><h2>The Sandbox Verifies The Work</h2><p>The sandbox is where the factory verifies work.</p><p>The system brings up all the services, runs tests, checks contracts, validates integration paths, and proves whether the change works.</p><p>This does not mean every change goes through a heavy process.</p><p>A good factory has two lanes.</p><p>Fast lane handles small fixes: one repo, low risk, obvious verification.</p><p>Full lane handles work with real coordination risk - cross-repo features, API changes, infra changes, data migrations, cost work, and anything that affects rollout confidence.</p><p>The factory chooses the lane, runs the right checks, and produces evidence.</p><p>The developer reviews the evidence and makes the final release call.</p><h2>How The Factory Improves</h2><p>Each run should make the next one easier.</p><p>After every run, the factory asks:</p><ul><li><p>What context was missing?</p></li><li><p>Which workflow was too manual?</p></li><li><p>Which verification step failed too late?</p></li><li><p>Which repeated step should become a skill?</p></li><li><p>Which area needs a specialized agent?</p></li><li><p>Which decision needs to be recorded for future runs?</p></li></ul><p>After each run, feedback is incorporated back into the system.</p><p>If a cross-repo change fails because one service emits <code>created_at</code> but another expects <code>createdAt</code>, the factory does not just fix the bug. It records the contract mismatch, updates the verification workflow, and checks that boundary before future PRs.</p><p>If local setup fails because seed data is missing, the factory should update the setup skill so future runs start from a working sandbox.</p><p>For example, if the authentication flow requires a dummy user and password, the factory should seed those credentials during setup and update the local setup instructions. The next time an agent runs the workflow, it should not have to rediscover the same missing dependency again.</p><p>If frontend-heavy work repeatedly needs the same review pattern, the factory turns that pattern into a reusable frontend verification skill, or <strong>proposes and create a specialized frontend lead agent.</strong></p><p>For example, if an agent needs a skill that does not exist, such as <code>python-best-practices</code>, it can propose it, create it, and use it before writing code.</p><p>The factory is version-controlled so that skills, workflows, verification rules, setup instructions, architecture decisions, and lessons from failed runs are all reviewable and teams can collaborate.</p><p>Developers and agents work together and improve the factory together, which compounds the system.</p><h2>The Shift</h2><p>The unit of work changes from &#8220;make this edit&#8221; to &#8220;ship this outcome safely.&#8221;</p><p>You no longer ask an agent to make the code change. You ask the factory to take an outcome and carry it through spec, build, verification, and learning.</p><p>Claude, Codex, and Cursor are not the factory.</p><p>They are the workers inside it.</p><p>The factory is the control plane around them: <strong>one shared engineering brain for every kind of engineering work, where agents coordinate, the sandbox proves changes, and the system improves with every run.</strong></p><p>A prompt gives you output.</p><p>A factory gives you a change with tests, screenshots, affected repos, rollout order, and a trail reviewers can trust.</p><p><strong>Build your own factory using <a href="http://prinevo.ai/">prinevo.ai</a>.</strong></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://sohit.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading sohit&#8217;s Newsletter! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Why DDD Will Come Back for AI Agents?]]></title><description><![CDATA[DDD will come back because agents need a model of the domain they are operating in.]]></description><link>https://sohit.substack.com/p/why-ddd-will-come-back-for-ai-agents</link><guid isPermaLink="false">https://sohit.substack.com/p/why-ddd-will-come-back-for-ai-agents</guid><dc:creator><![CDATA[sohit kumar]]></dc:creator><pubDate>Tue, 12 May 2026 20:40:23 GMT</pubDate><content:encoded><![CDATA[<p>DDD will come back because agents need a model of the domain they are operating in.</p><p>What are we doing when we are creating different skills for different process and giving access to the agent? We are passing business context - the context for the domain your business operates in.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://sohit.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading sohit&#8217;s Newsletter! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>Payment should happen in 30 days, else charge 10% extra - this is a business invariant you need to pass to the agent, as a skill, prompt, static logic, or whatever the case may be.</p><p>When people talk about context, the deeper point is not just &#8220;give the agent more context.&#8221;</p><p>The real point is: <em><strong>the agent needs a structured model of the business.</strong></em></p><p>Not just files, docs, embeddings, or tool descriptions. It needs to understand <em><strong>how the domain is shaped ?</strong></em></p><p>For example:</p><ul><li><p>What is a customer?</p></li><li><p>What is a user?</p></li><li><p>Are they the same thing?</p></li><li><p>When are they different?</p></li><li><p>What is an account?</p></li><li><p>What state can an invoice move through?</p></li><li><p>Which actions are allowed before approval?</p></li><li><p>Which events matter?</p></li><li><p>Which policy applies in which context?</p></li></ul><p><em><strong>That is why DDD will come back.</strong></em></p><p>DDD gave us language for:</p><ul><li><p>ubiquitous language</p></li><li><p>entities</p></li><li><p>value objects</p></li><li><p>aggregates</p></li><li><p>bounded contexts</p></li><li><p>domain events</p></li><li><p>invariants</p></li></ul><p>Because when an agent operates inside a business, it cannot rely only on code syntax or generic reasoning.</p><p>It has to know the meaning of the system.</p><p>If the agent collapses these concepts incorrectly, it will make bad decisions.</p><p><strong>This is where context graphs (Domain Model represented as graph ) and DDD meet.</strong></p><p>A context graph is not just a retrieval graph.</p><p>It becomes a living domain model:</p><pre><code><code>Customer
  -&gt; belongs to Account
  -&gt; has Users
  -&gt; has Contracts
  -&gt; receives Invoices
  -&gt; opens Support Tickets
</code></code></pre><p>But the graph also needs boundaries:</p><pre><code><code>Billing.Customer != CRM.Customer
Auth.User != Workspace.Member
Finance.Account != Product.Account
</code></code></pre><p><em><strong>That is bounded context.</strong></em></p><p><em><strong>Without bounded context, the agent will over-generalize.</strong></em></p><p><em><strong>It will see the same word in two places and assume it means the same thing.</strong></em></p><p>Or it will see two different words and miss that they refer to the same business concept.</p><p>So the real job is not just &#8220;stuff more context into the model.&#8221;</p><p>The job is to help the agent build and evolve a correct domain model.</p><p>And this model will not be perfect on day one.</p><p>You start with a baseline:</p><ul><li><p>existing code</p></li><li><p>docs</p></li><li><p>database schemas</p></li><li><p>API contracts</p></li><li><p>workflows</p></li><li><p>product language</p></li><li><p>support docs</p></li><li><p>analytics events</p></li><li><p>tribal knowledge</p></li></ul><p>If you are building a one-off agent, you may not see the need. But if you are automating a business process or making a function autonomous, then you need to understand the shape of the domain and design your multi-agent system around these bounded contexts.</p><p><em><strong>Once the domain model exists, evals also need to operate against that model.</strong></em></p><p>Right now, evals are more focused on prompts, tool calling, and whether the model gave the correct output. That is true to a certain extent.</p><p>But what we really want to validate is:</p><p><strong>Did the agent complete the business process as expected?</strong></p><p><strong>Eval traces should also contain domain events.</strong> Traces containing domain events that agents emit when they complete certain tasks. This <strong>Event Source</strong> becomes evidence of how the agent understood and acted inside the domain.</p><p>A trace should not only say:</p><pre><code><code>Tool called: update_invoice
</code></code></pre><p>It should say:</p><pre><code><code>{
  "actor": "agent",
  "action": "approve",
  "entity": {
    "type": "invoice",
    "id": "INV-123",
    "attributes": {
      "bounded_context": "finance",
      "state": "validated",
      "amount": "1200"
    }
  },
  "outcome": {
    "result": "blocked",
    "reason": "approval_required"
  }
}
</code></code></pre><p>Then every run teaches the system more:</p><ul><li><p>this term was ambiguous</p></li><li><p>this workflow had a hidden gate</p></li><li><p>this entity was misclassified</p></li><li><p>this repo owns this concept</p></li><li><p>this policy applies only in this context</p></li><li><p>this event means something different in another service</p></li></ul><p>That learning should update the domain model.</p><pre><code><code>Context graph -&gt; domain model -&gt; domain events -&gt; eval traces -&gt; learning loop
</code></code></pre><p>The context helps the agent reason.</p><p>The domain model gives meaning to the context.</p><p>The trace records how the agent acted against that model.</p><p>The eval checks whether the action was valid.</p><p>The learning loop updates the model when the trace reveals ambiguity or drift.</p><p>DDD will come back as the practical operating system for AI agents inside real businesses.</p><p>Because the bottleneck will not be whether the model can write code.</p><p>The bottleneck will be whether the system understands business concepts well enough to act safely.</p><p>In the old world, DDD helped humans align around software.</p><p><em><strong>In the agentic world, DDD helps humans and agents align around the business.</strong></em></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://sohit.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading sohit&#8217;s Newsletter! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Building a Software Factory: From Prompts to Compounding Systems]]></title><description><![CDATA[As coding agents get better, the bottleneck shifts.]]></description><link>https://sohit.substack.com/p/coding-agents-need-compounding-systems</link><guid isPermaLink="false">https://sohit.substack.com/p/coding-agents-need-compounding-systems</guid><dc:creator><![CDATA[sohit kumar]]></dc:creator><pubDate>Sun, 26 Apr 2026 12:28:18 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!5lj5!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36d1c9c5-9c5d-489b-827a-c46c55de07c3_1536x1024.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!5lj5!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36d1c9c5-9c5d-489b-827a-c46c55de07c3_1536x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!5lj5!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36d1c9c5-9c5d-489b-827a-c46c55de07c3_1536x1024.png 424w, https://substackcdn.com/image/fetch/$s_!5lj5!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36d1c9c5-9c5d-489b-827a-c46c55de07c3_1536x1024.png 848w, https://substackcdn.com/image/fetch/$s_!5lj5!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36d1c9c5-9c5d-489b-827a-c46c55de07c3_1536x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!5lj5!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36d1c9c5-9c5d-489b-827a-c46c55de07c3_1536x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!5lj5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36d1c9c5-9c5d-489b-827a-c46c55de07c3_1536x1024.png" width="1456" height="971" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/36d1c9c5-9c5d-489b-827a-c46c55de07c3_1536x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:971,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1675155,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://sohit.substack.com/i/195517851?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36d1c9c5-9c5d-489b-827a-c46c55de07c3_1536x1024.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!5lj5!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36d1c9c5-9c5d-489b-827a-c46c55de07c3_1536x1024.png 424w, https://substackcdn.com/image/fetch/$s_!5lj5!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36d1c9c5-9c5d-489b-827a-c46c55de07c3_1536x1024.png 848w, https://substackcdn.com/image/fetch/$s_!5lj5!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36d1c9c5-9c5d-489b-827a-c46c55de07c3_1536x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!5lj5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36d1c9c5-9c5d-489b-827a-c46c55de07c3_1536x1024.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><p>As coding agents get better, the bottleneck shifts. Code generation is commoditizing. Planning what to build, defining guardrails and context for how to build it, and verifying the change become the work.</p><p>Here&#8217;s a metric most teams aren&#8217;t tracking: changes to your agent setup (CLAUDE.md, skills, sub-agents) vs changes to your codebase. Does your agent need less instruction over time? That&#8217;s the only signal proving your setup is compounding.</p><p>Most teams aren&#8217;t measuring this. Engineers are prompting on top of the codebase, shipping fast, feeling productive. But the system isn&#8217;t getting smarter. Everyone is prompting the same things over and over.</p><p>That&#8217;s individual speedup with zero org-level compounding. Your team may feel faster, but the system itself isn&#8217;t improving.</p><p>Compounding starts when repeated prompts become shared system behavior. Before the two shifts that make it happen, a frame worth naming.</p><p>A compounding setup has two layers.</p><p>The brain holds context, policy, and decisions. CLAUDE.md, skills, sub-agents, architecture rules, security posture. This is where org knowledge lives.</p><p>The sandbox is where the agent executes and verifies. Local services, seed data, integration tests, the ability to bring the system up and watch it break.</p><p>Most teams have neither. They have a chat window and a codebase. That&#8217;s why prompting feels productive but never compounds. There&#8217;s nowhere for the learning to land, and nowhere for the agent to test what it built.</p><p>The two shifts below are how you build each layer.</p><h3>1. Invest in the verification layer (this is the sandbox)</h3><p>How fast can you verify what the agent shipped? Unit tests, integration tests, e2e automation, the ability to bring services up locally with seed data.</p><p>This mattered when humans wrote code. It&#8217;s 10x more important now.</p><p>Last week an agent shipped a multi-repo change where one service emitted <code>created_at</code> and the consumer expected <code>createdAt</code>. Code looked clean in both repos. Tests passed in isolation. An integration test caught it in the sandbox before it hit higher environments.</p><p>Most failures aren&#8217;t generation failures. They&#8217;re verification failures at integration boundaries.</p><p>A real feedback loop moves the human up the stack. The agent completes the task, brings services up locally, tests, iterates when it fails, and keeps going until acceptance criteria are met.</p><h3>2. Turn prompts into policy (this is the brain)</h3><p>When an agent misbehaves, don&#8217;t just re-prompt and move on. Pass the feedback into the system. Update CLAUDE.md, agent.md, sub-agent skills.</p><p>Re-prompting is individual work. Updating the context and guardrail layer is org work.</p><p>The team&#8217;s job becomes managing how the agent builds: security posture, architecture patterns, migration strategy. Every mistake the agent makes is input for the guardrail layer.</p><p>Once both layers are in place, you can build a compounding software factory above the codebase: an agent with context across repos and infra, taking a request, making multi-repo changes, bringing services up, testing, and shipping end to end.</p><p>Code generation is no longer the hard part. It&#8217;s managing shared context across repos and having a verification layer that lets the agent iterate until it converges.</p><p>The <code>created_at</code> vs <code>createdAt</code> story is the small version. At scale it&#8217;s schema drift, contract mismatches, and infra assumptions that only show up when services talk.</p><p>Teams that treat coding agents as individual productivity tools will get speed.</p><p>Teams that treat them as compounding software factories will get leverage.</p><p>This is Part 1. Next: how to actually build the brain and sandbox layers. Verification loops, feedback systems, shared context, and what has to be in place for agents to compound.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://sohit.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://sohit.substack.com/subscribe?"><span>Subscribe now</span></a></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://sohit.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading sohit&#8217;s Newsletter! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p></p>]]></content:encoded></item><item><title><![CDATA[Context Tiering for Claude Code: The CLAUDE.md Setup That Survives Long Sessions]]></title><description><![CDATA[TL;DR: Claude Code has 3 context tiers.]]></description><link>https://sohit.substack.com/p/context-tiering-for-claude-code-the</link><guid isPermaLink="false">https://sohit.substack.com/p/context-tiering-for-claude-code-the</guid><dc:creator><![CDATA[sohit kumar]]></dc:creator><pubDate>Fri, 10 Apr 2026 11:44:22 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/3b680630-62b8-4bac-96bf-4ef4f40cb4b3_1536x1024.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><em>TL;DR: Claude Code has 3 context tiers. Put rules in the wrong tier and Claude &#8220;forgets.&#8221; This is the Context Tiering setup that took me from a 470-line CLAUDE.md and constant reminders to 94 lines and ~99% first-try eval pass.</em></p><p>I had a rule in CLAUDE.md saying &#8220;every PR touching ORM models MUST include a migration.&#8221; Claude followed it for 20 turns. By turn 40, it was happily adding model fields without migrations. Bold warnings, checklists, repetition: none of it worked.</p><p>The fix wasn&#8217;t a better prompt. It was moving the rule out of CLAUDE.md entirely.</p><p>Claude Code doesn&#8217;t forget. It compresses. And if your rules live in the wrong tier, they get compressed first, which is why your 470-line CLAUDE.md feels like it works for 20 turns and then quietly stops.</p><p>3 months running Claude Code in production, mostly on Opus, building real systems for real users. Started at 470 lines of CLAUDE.md. Ended at 94 lines plus a layered system of rules, skills, and guidelines. First-try eval pass rate went from ~70% to ~99%. I used to write &#8220;don&#8217;t forget the migration&#8221; or &#8220;add eval cases&#8221; in almost every prompt. Now I write it zero times. The system handles it.</p><p>The model didn&#8217;t get smarter. The context architecture did.</p><h2><strong>The Mistake Everyone Makes</strong></h2><p>You start by dumping everything into CLAUDE.md: architecture, coding standards, workflows, security rules, eval framework, design patterns. Then Claude:</p><ul><li><p>Forgets your migration checklist on long conversations</p></li><li><p>Doesn&#8217;t follow coding standards 50 messages deep</p></li><li><p>Lets subagents invent their own rules</p></li></ul><p>I wrote the same rule three times hoping repetition would help. It didn&#8217;t. <strong>Repetition isn&#8217;t reinforcement. Placement is.</strong></p><p>You&#8217;re treating CLAUDE.md like a knowledge base. It&#8217;s not. It&#8217;s permanent context, loaded every single turn, never compressed. A 470-line file eats ~2000 tokens per message and Claude&#8217;s attention to any individual rule drops as the file grows past ~200 lines.</p><h2><strong>The Mental Model: Context Tiering</strong></h2><p>Claude Code has three context tiers, each with a different lifetime:</p><p>markdown</p><pre><code><code>PERMANENT (every turn, never compressed)
  CLAUDE.md                      keep TINY
  .claude/rules/* (glob-scoped)  auto-loaded invariants
  Memory index                   cross-session recall

ON DEMAND (loaded when read, compressed over time)
  guidelines files               reference docs
  skill bodies                   workflow instructions

TEMPORARY (compressed first when context fills)
  conversation, file reads, search results</code></code></pre><p>Critical rules go where they&#8217;ll never be compressed. Reference knowledge loads only when needed. Everything else is temporary, and that&#8217;s fine.</p><p>Get this wrong and Claude &#8220;forgets.&#8221; Get this right and Claude behaves like a senior engineer who actually reads the docs.</p><h2><strong>The Decision Framework (the most reusable thing in this post)</strong></h2><p>For any instruction, ask in order:</p><p>markdown</p><pre><code><code>Q1: If Claude violates this, does something BREAK?
    YES -&gt; RULE (.claude/rules/)

Q2: Is this triggered by a specific task with ordered steps?
    YES -&gt; SKILL (.claude/skills/)

Q3: Is this reference knowledge Claude looks up while coding?
    YES -&gt; GUIDELINE (&lt;topic&gt;-guidelines.md)

Q4: Does Claude need this every single turn to understand the project?
    YES -&gt; CLAUDE.md (keep it SHORT)

Q5: Is this an isolated, parallelizable task that would bloat main context?
    YES -&gt; SUBAGENT (fresh instance, brief it like a new hire)

NO to all -&gt; don't add it.</code></code></pre><p>Examples:</p><ul><li><p>&#8220;Never import from customers/ in platform code&#8221; &#8594; breaks multi-tenancy &#8594; <strong>Rule</strong></p></li><li><p>&#8220;When building a skill: add tracing, write evals, register, sync to Langfuse&#8221; &#8594; 7 ordered steps with a clear trigger &#8594; <strong>Skill</strong></p></li><li><p>&#8220;PascalCase classes, snake_case functions&#8221; &#8594; reference, no trigger &#8594; <strong>Guideline</strong></p></li><li><p>&#8220;B2B SaaS for insurance document processing&#8221; &#8594; needed every turn for context &#8594; <strong>CLAUDE.md</strong></p></li><li><p>&#8220;Audit all Dockerfiles and report inconsistencies&#8221; &#8594; isolated, read-heavy, parallelizable &#8594; <strong>Subagent</strong></p></li></ul><p>If you remember nothing else from this post, remember this framework.</p><h2><strong>The Five File Types</strong></h2><p><strong>1. CLAUDE.md (~100 lines)</strong>: identity and navigation. Project overview, essential commands, folder structure, pointers to other docs. Nothing else. Past 100 lines, Claude&#8217;s attention to any single rule starts dropping.</p><p><strong>2. Rules files (~30 lines, in .claude/rules/)</strong>: hard constraints, glob-scoped, never compressed.</p><p>markdown</p><pre><code><code>.claude/rules/no-customer-imports.md

globs: src/myapp/**

Platform code must NEVER import from customers/. Breaks multi-tenancy.</code></code></pre><p>This completely solved my migration problem. The 48-line Alembic section that Claude forgot in CLAUDE.md became a 12-line rule that fires every time Claude touches models.py. Haven&#8217;t missed a migration since.</p><p><strong>Glob scope is the lever: globs: ** = permanent everywhere (use sparingly). globs: **/Dockerfile = nearly free.</strong></p><p><strong>3. Guidelines files (~250 lines)</strong>: coding standards, design patterns. Loaded on demand, compressed over time. Fine, because rules catch the critical stuff.</p><p><strong>Split by concern</strong>. My original coding-guidelines.md was 727 lines. Every time Claude needed to check a naming convention, it loaded 727 lines covering Python, architecture, skills, migrations, and security. ~3000 tokens for a 20-line answer. I split it into 3 files. Now &#8220;fix a Python bug&#8221; loads 215 lines. &#8220;Design a feature&#8221; loads 91. &#8220;Build a skill&#8221; loads 145.</p><p><strong>4. Skills (~200 lines, in .claude/skills/)</strong>: workflows with a trigger and ordered steps. The ~50-token description is always in context so Claude auto-detects when to fire. The body loads only when invoked. Test: can you describe the trigger in one sentence? Are there 3+ ordered steps? Yes to both = skill.</p><p><strong>5. Per-directory CLAUDE.md (~50 lines)</strong>: only what&#8217;s <em>unique</em> to that module. I audited my project and found 74 CLAUDE.md files that were nothing but auto-generated activity logs with zero instructions. Deleted all of them. Kept 31 that had real documentation. Empty per-directory files are noise tax on every session.</p><h2><strong>Subagents: The Insight That Changes Everything</strong></h2><p>Subagents are fresh Claude instances. They inherit your CLAUDE.md and rules. They inherit <em>zero</em> conversation history.</p><p>If a constraint only exists in your chat, it doesn&#8217;t exist for the subagent.</p><p>BAD:  &#8220;Based on our earlier research, fix the bug&#8221;<br><br>GOOD: &#8220;In src/myapp/skills/extract_core.py line 280,<br>       extract_from_classified() fails when classified images<br>       contain duplicate tags. Fix: deduplicate by image path<br>       before the extraction loop.&#8221;</p><p>I use subagents heavily. When I needed to audit all my Dockerfiles, CLAUDE.md files, and coding guidelines, I launched 4 in parallel. Each explored a different area and came back with findings. Main context stayed clean. If I&#8217;d done it inline, file reads alone would have eaten half my window.</p><h2><strong>The 70% &#8594; 99% Trick: Triple Reinforcement</strong></h2><p>&#8220;Always add evals&#8221; written in CLAUDE.md alone works ~70% of the time. To reach ~99%:</p><p>markdown</p><pre><code><code>Layer 1: Skill DESCRIPTION (always in context)
  Auto-detects "I'm building a skill" and triggers /eval-design

Layer 2: CLAUDE.md INSTRUCTION
  "Every change to LLM code MUST use /eval-design"

Layer 3: Rule FILE (auto-loaded on skills/** edits)
  "Every skill needs tracing + evals + tests + registry"</code></code></pre><p>This is how I solved the eval problem. Our pipeline can silently degrade accuracy on any prompt change. Just writing the rule wasn&#8217;t enough. Claude would build a skill, write tests, and forget evals. With three layers, compliance is ~99%. If any one fails, the other two catch it.</p><h2><strong>Build Rules Reactively</strong></h2><p>Start with zero. Add them when things break:</p><p>markdown</p><pre><code><code>Week 1: Claude commits a .env file       -&gt; no-secrets rule
Week 2: Claude skips a migration         -&gt; migration-required rule
Week 3: Skill ships without evals        -&gt; skill-completeness rule
Week 4: Platform imports customer code   -&gt; isolation rule
</code></code></pre><p>All 7 of my rules came from real incidents. The platform isolation rule? Claude imported a customer-specific config parser into the platform module. Broke the second customer&#8217;s integration. The dependency pinning rule? Claude added litellm&gt;=1.0 and the next build pulled a breaking version. Each rule paid for itself within a week.</p><p>Don&#8217;t pre-create 20 hypothetical rules. They bloat permanent context and dilute attention across the rules that actually matter.</p><h2><strong>Cheat Sheet</strong></h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!qlrl!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d28423d-e27f-4f29-a015-21a2db9e10ea_692x605.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!qlrl!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d28423d-e27f-4f29-a015-21a2db9e10ea_692x605.png 424w, https://substackcdn.com/image/fetch/$s_!qlrl!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d28423d-e27f-4f29-a015-21a2db9e10ea_692x605.png 848w, https://substackcdn.com/image/fetch/$s_!qlrl!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d28423d-e27f-4f29-a015-21a2db9e10ea_692x605.png 1272w, https://substackcdn.com/image/fetch/$s_!qlrl!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d28423d-e27f-4f29-a015-21a2db9e10ea_692x605.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!qlrl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d28423d-e27f-4f29-a015-21a2db9e10ea_692x605.png" width="692" height="605" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4d28423d-e27f-4f29-a015-21a2db9e10ea_692x605.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:605,&quot;width&quot;:692,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:77481,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://sohit.substack.com/i/193785392?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d28423d-e27f-4f29-a015-21a2db9e10ea_692x605.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!qlrl!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d28423d-e27f-4f29-a015-21a2db9e10ea_692x605.png 424w, https://substackcdn.com/image/fetch/$s_!qlrl!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d28423d-e27f-4f29-a015-21a2db9e10ea_692x605.png 848w, https://substackcdn.com/image/fetch/$s_!qlrl!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d28423d-e27f-4f29-a015-21a2db9e10ea_692x605.png 1272w, https://substackcdn.com/image/fetch/$s_!qlrl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d28423d-e27f-4f29-a015-21a2db9e10ea_692x605.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><h2><strong>The Real Lesson - Feedback Loop</strong></h2><p><code>One of the key for this setup is feedback loop, every time I merge a PR a hook runs which collects all the learning from the session and update the setup following the guidelines - your setup evolves with your codebase.</code><br><br>Writing code with an LLM is becoming commodity. Anyone can spin up Claude Code in 5 minutes. The leverage isn&#8217;t in the model anymore. It&#8217;s in the context architecture  and feedback loop you build around it</p><p>Context is the moat. The rules, skills, guidelines, and glob-scoped invariants are the asset. They compound. They make every future session better. They turn a flaky genius into a predictable senior engineer.</p><p>If your AI workflow feels magical-but-fragile, you don&#8217;t need a better model. You need a better context architecture.</p><p></p><p></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://sohit.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://sohit.substack.com/subscribe?"><span>Subscribe now</span></a></p><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://sohit.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading sohit&#8217;s Newsletter! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://sohit.substack.com/?utm_source=substack&amp;utm_medium=email&amp;utm_content=share&amp;action=share&quot;,&quot;text&quot;:&quot;Share sohit&#8217;s Newsletter&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://sohit.substack.com/?utm_source=substack&amp;utm_medium=email&amp;utm_content=share&amp;action=share"><span>Share sohit&#8217;s Newsletter</span></a></p><p>This refactor will take one afternoon. It saves that much every single day.</p>]]></content:encoded></item><item><title><![CDATA[Building a Context Graph That Makes Your AI Agent Smarter With Every Run]]></title><description><![CDATA[Building the judgment layer that lives in a surveyor's head]]></description><link>https://sohit.substack.com/p/building-a-context-graph-that-makes</link><guid isPermaLink="false">https://sohit.substack.com/p/building-a-context-graph-that-makes</guid><dc:creator><![CDATA[sohit kumar]]></dc:creator><pubDate>Sun, 29 Mar 2026 16:39:28 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!tPla!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6dbacfd2-3f8b-4ae4-9955-b7d91d24e880_1485x819.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2>Summary</h2><p>Most AI agents are stateless wrappers around LLMs. They process each request in isolation, with no context from what they decided yesterday or why. In regulated domains like insurance, this is a dead-end.</p><p>I built a context graph for motor insurance claims, a knowledge structure where every case the agent processes makes the next case smarter. Entities, parts, costs, decisions, and the reasoning behind them accumulate into a judgment layer that mirrors what experienced surveyors carry in their heads.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://sohit.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading sohit&#8217;s Newsletter! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>By case 5, the agent was finding its own precedents. By case 20, it was flagging cost anomalies and suspicious part combinations that nobody programmed. Not from rules. From the graph growing.</p><p>The core thesis: <strong>prompt engineering is a ceiling. A context graph is a flywheel.</strong></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!tPla!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6dbacfd2-3f8b-4ae4-9955-b7d91d24e880_1485x819.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!tPla!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6dbacfd2-3f8b-4ae4-9955-b7d91d24e880_1485x819.png 424w, https://substackcdn.com/image/fetch/$s_!tPla!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6dbacfd2-3f8b-4ae4-9955-b7d91d24e880_1485x819.png 848w, https://substackcdn.com/image/fetch/$s_!tPla!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6dbacfd2-3f8b-4ae4-9955-b7d91d24e880_1485x819.png 1272w, https://substackcdn.com/image/fetch/$s_!tPla!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6dbacfd2-3f8b-4ae4-9955-b7d91d24e880_1485x819.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!tPla!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6dbacfd2-3f8b-4ae4-9955-b7d91d24e880_1485x819.png" width="1456" height="803" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6dbacfd2-3f8b-4ae4-9955-b7d91d24e880_1485x819.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:803,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:415864,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://sohit.substack.com/i/192519430?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6dbacfd2-3f8b-4ae4-9955-b7d91d24e880_1485x819.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!tPla!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6dbacfd2-3f8b-4ae4-9955-b7d91d24e880_1485x819.png 424w, https://substackcdn.com/image/fetch/$s_!tPla!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6dbacfd2-3f8b-4ae4-9955-b7d91d24e880_1485x819.png 848w, https://substackcdn.com/image/fetch/$s_!tPla!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6dbacfd2-3f8b-4ae4-9955-b7d91d24e880_1485x819.png 1272w, https://substackcdn.com/image/fetch/$s_!tPla!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6dbacfd2-3f8b-4ae4-9955-b7d91d24e880_1485x819.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><div><hr></div><h2>The Two Knowledge Systems</h2><p>Every organization runs on two knowledge systems.</p><p>The one in the database. And the one in people&#8217;s heads.</p><p>The database stores what happened: transactions, records, timestamps. But the person who&#8217;s been doing the job for fifteen years knows <em>why</em> things happened the way they did. Which exceptions were granted. Which patterns to watch for. Which rules matter on paper and which ones actually matter.</p><p>That second knowledge system runs most of the real decision-making. And it has no backup.</p><p>This is the reason AI agents hit a ceiling. You can give an agent access to every database, every document, every API. But if the judgment layer lives in someone&#8217;s head (the pattern recognition, the institutional memory, the &#8220;this doesn&#8217;t smell right&#8221; instinct) the agent will keep making technically correct decisions that any experienced person would override in seconds.</p><p><strong>Agents without a context graph are just stateless wrappers around LLMs.</strong> The missing piece isn&#8217;t better models. It&#8217;s structured knowledge that compounds.</p><h2>The Gap in Motor Insurance</h2><p>When a surveyor assesses a claim, they don&#8217;t just check if the policy is valid and the documents are in order. They remember that the garage on MG Road always inflates bumper costs. That a rear-end collision claiming both a tail light and a boot lid usually means the damage is real. That a vehicle with three claims in two months deserves closer scrutiny, even if each individual claim checks out.</p><p>None of this lives in any database. It lives in experience.</p><p>So I ran an experiment. An AI agent that processes motor insurance claims one by one, building a context graph as it goes. Every case adds to the collective knowledge: entities, parts, costs, decisions, and the reasoning behind them.</p><p>The term &#8220;context graph&#8221; comes from Jaya Gupta. The idea is that what makes AI agents truly capable isn&#8217;t the model, it&#8217;s the structured context they accumulate over time.</p><p>Here&#8217;s what I didn&#8217;t expect.</p><p>By case 5, the agent started finding its own precedents. Similar accident, similar vehicle, similar amount, and it pulled the past decision to calibrate its confidence.</p><p>By case 20, it was flagging things nobody told it to flag:</p><ul><li><p>Cost patterns that didn&#8217;t match what it had learned from prior cases</p></li><li><p>Part combinations that seemed unusual for the type of accident</p></li><li><p>Repair patterns at specific garages that looked suspiciously consistent</p></li></ul><p>None of these were hardcoded rules. They emerged from the graph growing.</p><p>The biggest surprise: making the agent <em>navigate</em> the graph (follow relationships, inspect connected entities, check cross-case statistics) produced far better reasoning than putting everything into a prompt. <strong>The structure itself encodes knowledge that flat text loses.</strong></p><div><hr></div><h2>What I Built</h2><p>A system where:</p><ul><li><p>Every insurance claim becomes a graph: entities (person, vehicle, garage), evidence (invoice, documents), parts (bumper, headlight), and relationships between them</p></li><li><p>The agent validates claims against knowledge rules (IRDAI regulations, vehicle parts ontology, document requirements)</p></li><li><p>The agent searches for precedent, including similar past cases, entity history, and human overrides</p></li><li><p>The agent navigates the graph using tools. It decides what to investigate, follows edges, checks cross-case statistics</p></li><li><p>Every decision is stored as a decision trace: what was read, what was compared, what the reasoning was</p></li><li><p>The knowledge graph grows automatically with every case</p></li></ul><p><strong>The flywheel: more cases &#8594; richer graph &#8594; better precedent &#8594; smarter decisions &#8594; more trustworthy traces.</strong></p><h3>Modeling the Graph</h3><p>Nodes are what a surveyor would recognize: Person, Vehicle, Policy, Accident, Garage, Part, Invoice, Documents. Each gets a deterministic ID from the most reliable field available:</p><pre><code><code>Person  &#8594; dl_number &#8594; aadhar_no &#8594; pan_no &#8594; mobile &#8594; name
Vehicle &#8594; registration_number &#8594; chassis_number &#8594; engine_number
</code></code></pre><p>When the same vehicle appears in case 5 and case 15, it&#8217;s the same node. You can ask &#8220;how many claims has this vehicle had?&#8221;</p><p>Edges represent real-world relationships: person DRIVES vehicle, vehicle REPAIRED_AT garage, part DAMAGED_IN accident. Each edge is something a surveyor would draw on a whiteboard.</p><h3>The Global Layer (Where the Magic Happens)</h3><p>Beyond per-case graphs, global nodes accumulate across cases:</p><p><strong>GlobalPart</strong> tracks cost benchmarks:</p><pre><code><code>(:GlobalPart {part_id: "rear_bumper", claim_count: 19,
              avg_claimed: 7200, min: 7200, max: 7200})
</code></code></pre><p><strong>CO_OCCURS_WITH</strong> captures which parts appear together:</p><pre><code><code>(:GlobalPart {front_bumper}) -[:CO_OCCURS_WITH {count: 11}]&#8594; (:GlobalPart {radiator_grill})
(:GlobalPart {rear_bumper}) -[:CO_OCCURS_WITH {count: 10}]&#8594; (:GlobalPart {tail_light})
</code></code></pre><p>After 20 cases, the agent knows: &#8220;rear_bumper is typically Rs.7,200, always in rear_center zone, and 53% of the time appears with tail_light.&#8221; <strong>Nobody programmed this. The graph learned it from data.</strong></p><h3>The Validation Layer</h3><p>IRDAI regulations and domain knowledge encoded as rules that read specific nodes and produce VERIFIED, CONFLICT, or ANOMALY edges:</p><p>Rule What It Checks Source policy_active policy.end_date &gt;= accident.date IRDAI Regulations 2024 dl_valid DL expiry &gt;= accident date Motor Vehicles Act 1988 parts_plausibility Claimed parts reachable from impact zone Vehicle parts spatial ontology document_completeness All required documents present IRDAI regulations</p><p>The parts plausibility check uses a spatial ontology: 74 parts and 206 adjacency edges modeling how damage propagates through a vehicle. Rear bumper claimed for a rear impact? Propagation score 1.0, consistent. Front bumper claimed for a rear impact? Propagation score 0.015, anomalous.</p><p><strong>The ontology is a reference graph the agent consults: spatial reasoning, not hardcoded logic.</strong></p><div><hr></div><h2>The Agent Loop (Where Context Graph Meets Agentic Reasoning)</h2><p>The key design choice: the agent is not a linear pipeline. It&#8217;s a loop where the LLM has tools to navigate the graph and decides for itself what to explore.</p><h3>Tools the LLM Can Call</h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!t3W0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6bc665c0-6c8c-482b-aa6f-7c825c029fb7_1404x844.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!t3W0!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6bc665c0-6c8c-482b-aa6f-7c825c029fb7_1404x844.png 424w, https://substackcdn.com/image/fetch/$s_!t3W0!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6bc665c0-6c8c-482b-aa6f-7c825c029fb7_1404x844.png 848w, https://substackcdn.com/image/fetch/$s_!t3W0!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6bc665c0-6c8c-482b-aa6f-7c825c029fb7_1404x844.png 1272w, https://substackcdn.com/image/fetch/$s_!t3W0!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6bc665c0-6c8c-482b-aa6f-7c825c029fb7_1404x844.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!t3W0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6bc665c0-6c8c-482b-aa6f-7c825c029fb7_1404x844.png" width="1404" height="844" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6bc665c0-6c8c-482b-aa6f-7c825c029fb7_1404x844.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:844,&quot;width&quot;:1404,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:141010,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://sohit.substack.com/i/192519430?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6bc665c0-6c8c-482b-aa6f-7c825c029fb7_1404x844.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!t3W0!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6bc665c0-6c8c-482b-aa6f-7c825c029fb7_1404x844.png 424w, https://substackcdn.com/image/fetch/$s_!t3W0!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6bc665c0-6c8c-482b-aa6f-7c825c029fb7_1404x844.png 848w, https://substackcdn.com/image/fetch/$s_!t3W0!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6bc665c0-6c8c-482b-aa6f-7c825c029fb7_1404x844.png 1272w, https://substackcdn.com/image/fetch/$s_!t3W0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6bc665c0-6c8c-482b-aa6f-7c825c029fb7_1404x844.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>The LLM typically makes 4-8 tool calls per case. For clean cases, it checks a couple of parts and decides. For suspicious cases, it digs deeper, following edges, checking history, profiling the garage.</p><p><strong>Nobody told the LLM to check part costs or co-occurrences. The LLM decides what&#8217;s worth investigating based on what it sees in the graph.</strong> This is what makes it agentic rather than scripted.</p><div><hr></div><h2>Watching the Agent Investigate (A Real Case)</h2><p>Case C-002: Rajesh K. is driving a vehicle insured under Suresh M.&#8217;s policy. Side impact at an intersection. Three parts claimed: side mirror (Rs.2,800), door panel (Rs.12,000), running board (Rs.3,500). Total: Rs.18,300.</p><p>The agent&#8217;s actual investigation:</p><pre><code><code>[THINK] "I see a driver-policyholder mismatch. Let me investigate."

[ACT]  inspect_node(person:TN31XXXXXXXX)
       &#8594; name=Rajesh K., relation_to_insured=self, insured_name=Suresh M.

[ACT]  inspect_node(policy:0407XXXXXXXX)
       &#8594; insurer=Insurer Co. Ltd, sum_insured=388864, active

[ACT]  query_global_part(rear_view_mirror)
       &#8594; 17 past claims, avg Rs.2,800

[ACT]  query_global_part(door_panel)
       &#8594; 16 past claims, avg Rs.12,000

[ACT]  query_global_part(running_board)
       &#8594; 11 past claims, avg Rs.3,500

[ACT]  get_part_cooccurrences(rear_view_mirror)
       &#8594; door_panel co-occurs 8 times, running_board 8 times
       &#8594; Pattern is typical for side impacts

[ACT]  make_decision(APPROVE, confidence=0.95)
       &#8594; "Driver-policyholder mismatch noted but AUTHORIZED_BY edge exists.
          Parts costs match cross-case averages exactly.
          Part combination typical for side impacts.
          4 similar precedent cases all APPROVED."
</code></code></pre><p>Notice: the agent <em>chose</em> to inspect the person node because it saw the mismatch. It <em>chose</em> to verify every part cost. It <em>chose</em> to check co-occurrence patterns. The graph gave it the information. The tools gave it the agency. The LLM connected the dots.</p><div><hr></div><h2>How Precedent Makes the Agent Learn</h2><p>Before deciding, the agent queries four sources:</p><p><strong>1. Entity History.</strong> Has this vehicle, person, or garage been in a claim before? A vehicle with 3 claims in 2 months is different from one with its first claim.</p><p><strong>2. Tag-Based Similar Cases.</strong> Past cases with overlapping tags (impact zone, severity, vehicle type). Four similar cases all APPROVED? High confidence. Two DENIED? Mixed signals, lower confidence or escalate.</p><p><strong>3. Dimension Matching.</strong> Numerical similarity across case attributes. Architecture supports vector/cosine search for scale.</p><p><strong>4. Human Override History.</strong> Cases where a human corrected the agent. If a human changed APPROVE to ESCALATE because &#8220;front bumper at Rs.12,000 but market rate for Swift hatchback is Rs.6,000,&#8221; the agent sees this correction and adjusts on similar patterns.</p><p>All four sources merge into the LLM context before it decides. The LLM doesn&#8217;t follow a formula. It weighs everything contextually. <strong>This is how precedent compounds. Case 1 has zero precedent. Case 20 finds 4+ similar cases. At case 1,000, the agent would have deep precedent for every pattern: not just &#8220;similar cases&#8221; but &#8220;similar cases at this garage, with this vehicle type, in this impact zone, with these parts.&#8221;</strong></p><div><hr></div><h2>How the Graph Evolves</h2><div><hr></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!_KKF!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4aa454a4-4d68-4ee5-a2fe-120f27df86ee_1508x390.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!_KKF!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4aa454a4-4d68-4ee5-a2fe-120f27df86ee_1508x390.png 424w, https://substackcdn.com/image/fetch/$s_!_KKF!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4aa454a4-4d68-4ee5-a2fe-120f27df86ee_1508x390.png 848w, https://substackcdn.com/image/fetch/$s_!_KKF!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4aa454a4-4d68-4ee5-a2fe-120f27df86ee_1508x390.png 1272w, https://substackcdn.com/image/fetch/$s_!_KKF!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4aa454a4-4d68-4ee5-a2fe-120f27df86ee_1508x390.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!_KKF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4aa454a4-4d68-4ee5-a2fe-120f27df86ee_1508x390.png" width="1456" height="377" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4aa454a4-4d68-4ee5-a2fe-120f27df86ee_1508x390.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:377,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:56371,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://sohit.substack.com/i/192519430?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4aa454a4-4d68-4ee5-a2fe-120f27df86ee_1508x390.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!_KKF!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4aa454a4-4d68-4ee5-a2fe-120f27df86ee_1508x390.png 424w, https://substackcdn.com/image/fetch/$s_!_KKF!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4aa454a4-4d68-4ee5-a2fe-120f27df86ee_1508x390.png 848w, https://substackcdn.com/image/fetch/$s_!_KKF!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4aa454a4-4d68-4ee5-a2fe-120f27df86ee_1508x390.png 1272w, https://substackcdn.com/image/fetch/$s_!_KKF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4aa454a4-4d68-4ee5-a2fe-120f27df86ee_1508x390.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><h2>Business Impact: What This Unlocks</h2><p>This isn&#8217;t just a technical exercise. The context graph creates measurable business outcomes:</p><p><strong>Speed.</strong> Clean cases (strong precedent, no anomalies, low amount) can be fast-tracked. The graph provides the confidence signal. A claim that matches 10 prior approvals with identical part costs doesn&#8217;t need 30 minutes of human review.</p><p><strong>Fraud detection that emerges, not programmed.</strong> The agent catches a garage that always claims the same three parts at identical prices. Not because someone wrote a fraud rule. Because the graph made the pattern visible. This is cheaper and more adaptive than rule-based fraud systems.</p><p><strong>Reduced human dependency without removing humans.</strong> Surveyors review the hard cases instead of every case. The decision trace means they can see exactly why the agent decided what it did, and correct it. Those corrections feed back into the graph.</p><p><strong>Regulatory defensibility.</strong> Every decision has a full audit trail: which nodes were read, which rules applied, what precedent was found, what the reasoning was. In a regulated industry, &#8220;the AI said so&#8221; isn&#8217;t acceptable. &#8220;The AI checked these 6 rules, found 4 similar precedents, verified costs against 16 data points, and here&#8217;s the reasoning&#8221; is.</p><p><strong>Directional hypothesis</strong>: A mature context graph processing 1,000+ claims should reduce average claim processing time by 40-60% while catching cost anomalies that manual review misses at scale.</p><div><hr></div><h2>What Worked and What Didn&#8217;t (Honest Assessment)</h2><p><strong>What worked:</strong></p><ul><li><p>The LLM genuinely navigates the graph. It&#8217;s not a fancy database. The agent follows edges, checks cross-case stats, references specific nodes in its reasoning</p></li><li><p>Decision traces are powerful for audit and trust</p></li><li><p>Part co-occurrence patterns and cost benchmarks emerged naturally from data</p></li><li><p>The tool-calling loop gives the agent real investigative agency</p></li></ul><p><strong>What didn&#8217;t work yet:</strong></p><ul><li><p>All 20 cases approved (the test data had no critical conflicts: valid DLs, active policies, reasonable costs). This validated the happy path. Adversarial testing with expired policies, inflated costs, and invalid documents is next</p></li><li><p>Tags are too uniform. Precedent search finds too many matches because tags aren&#8217;t discriminating enough</p></li><li><p>Missing data is the biggest problem: 100% of cases had no impact_zone, severity, or vehicle body_type in the ground truth</p></li></ul><p><strong>The gap I haven&#8217;t closed yet:</strong> image reasoning. A real surveyor looks at photos. Tying visual evidence to graph nodes (&#8221;this dent pattern is consistent with a side impact&#8221;) is the next frontier. Part can be tied to 1000 images and other cases which can be used for reasoning.</p><div><hr></div><h2>What I Intentionally Kept Simple</h2><ul><li><p><strong>NetworkX</strong> for in-memory per-case graphs (fast, no server needed for prototyping)</p></li><li><p><strong>Neo4j</strong> for persistent cross-case graph storage</p></li><li><p><strong>Custom ReAct loop with litellm</strong> (not LangChain/CrewAI. I wanted full control over graph construction and trace capture)</p></li><li><p><strong>No vector database.</strong> Overkill for 20 cases. In-memory dimension matching is sufficient. Would add for 1,000+ cases</p></li><li><p><strong>No LLM fine-tuning.</strong> The context graph gives the LLM enough information to reason well. Structured context beats fine-tuning for this use case</p></li></ul><div><hr></div><h2>Conclusion: The Context Graph Flywheel</h2><p>The next generation of agents won&#8217;t be better because of better models. They&#8217;ll be better because they accumulate context.</p><p>Every case processed adds entities to the global graph, cost data points for benchmarking, co-occurrence patterns, decision traces for precedent, and validation results that test rule effectiveness. The agent&#8217;s first case is a cold start. By case 20, it&#8217;s checking costs against 15+ data points and finding 4+ similar past cases. By case 1,000, it would have garage profiles, seasonal patterns, segment-specific cost curves, and a library of human corrections teaching it where its initial judgments were wrong.</p><p>The surveyor&#8217;s intuition isn&#8217;t magic. It&#8217;s pattern recognition from hundreds of cases, compounding silently over a career. A context graph captures that same compounding, except it never degrades, never retires, and every new case makes every future case smarter.</p><p><strong>The hard part isn&#8217;t the technology. It&#8217;s modeling the domain correctly and feeding the system enough real data.</strong> The flywheel of knowledge graph, agent learns, agent gets better: that&#8217;s buildable today.</p><p>I&#8217;m just getting started.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://sohit.substack.com/p/building-a-context-graph-that-makes?utm_source=substack&utm_medium=email&utm_content=share&action=share&quot;,&quot;text&quot;:&quot;Share&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://sohit.substack.com/p/building-a-context-graph-that-makes?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://sohit.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://sohit.substack.com/subscribe?"><span>Subscribe now</span></a></p><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://sohit.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading sohit&#8217;s Newsletter! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Retrieval Debt: The Technical Debt Your Agent Is Paying Right Now]]></title><description><![CDATA[Retrieval Debt is how much context an agent must load to safely understand, change, and verify a single unit of behavior. Lower is better. Always.]]></description><link>https://sohit.substack.com/p/retrieval-debt-the-technical-debt</link><guid isPermaLink="false">https://sohit.substack.com/p/retrieval-debt-the-technical-debt</guid><dc:creator><![CDATA[sohit kumar]]></dc:creator><pubDate>Wed, 25 Feb 2026 07:38:44 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/757df3be-93f9-40ed-8ce1-89922a4e8752_1536x1024.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!OROX!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4625724-33ad-4be7-8cd1-681753f8f4c5_1536x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!OROX!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4625724-33ad-4be7-8cd1-681753f8f4c5_1536x1024.png 424w, https://substackcdn.com/image/fetch/$s_!OROX!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4625724-33ad-4be7-8cd1-681753f8f4c5_1536x1024.png 848w, https://substackcdn.com/image/fetch/$s_!OROX!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4625724-33ad-4be7-8cd1-681753f8f4c5_1536x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!OROX!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4625724-33ad-4be7-8cd1-681753f8f4c5_1536x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!OROX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4625724-33ad-4be7-8cd1-681753f8f4c5_1536x1024.png" width="1456" height="971" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a4625724-33ad-4be7-8cd1-681753f8f4c5_1536x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:971,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:2455910,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://sohit.substack.com/i/189043210?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4625724-33ad-4be7-8cd1-681753f8f4c5_1536x1024.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!OROX!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4625724-33ad-4be7-8cd1-681753f8f4c5_1536x1024.png 424w, https://substackcdn.com/image/fetch/$s_!OROX!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4625724-33ad-4be7-8cd1-681753f8f4c5_1536x1024.png 848w, https://substackcdn.com/image/fetch/$s_!OROX!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4625724-33ad-4be7-8cd1-681753f8f4c5_1536x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!OROX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4625724-33ad-4be7-8cd1-681753f8f4c5_1536x1024.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><p>I started thinking about a simple question: will software design principles still matter when AI agents do most of the coding?</p><p><strong>The answer I kept coming back to was: more than ever.</strong> Not because the principles changed. Because the reader did.</p><p>Your agent indexes your codebase once. But every session it reasons from scratch. No memory of last week&#8217;s decisions. No context about why that tradeoff was made. Just retrieval and a best guess.</p><p>Token costs spike. Wrong files get edited. You end up guiding your agent through your own codebase like onboarding a new hire who cannot ask questions and never remembers the answers.</p><p>Most teams think this is an AI problem. It is a design problem.</p><div><hr></div><h2>Agents Inherit Your Design Decisions</h2><p>Software design principles were never about aesthetics. They existed to manage ambiguity for whoever changes the code next. The audience was always the next reader who needs to understand this and modify it safely.</p><p>That reader is now an agent. And agents suffer from ambiguity more than humans do, not less.</p><p>A human encountering unclear code slows down. They hesitate. They ask questions. An agent does the opposite. It makes a confident decision and moves forward.</p><p>Ambiguity doesn&#8217;t create caution in agents. It creates confident mistakes at scale.</p><p>Good design amplifies good agent output. Bad design amplifies bad agent output. The principles didn&#8217;t become irrelevant. They became more expensive to ignore.</p><div><hr></div><h2>Three Constraints That Make Violations Expensive</h2><p>Agents operate under three hard constraints humans never had, and understanding these is why the rest of this post matters.</p><p><strong>Context window</strong> means agents can only reason about what they retrieve. Scattered logic means partial picture, wrong assumptions, missed files. What a human fills with intuition and experience, an agent either retrieves correctly or gets wrong confidently. There is no middle ground.</p><p><strong>Cost</strong> means every token loaded is a line item on your bill. Poor design is no longer just slow. A messy codebase costs significantly more to operate on than a clean one. Bad architecture now has a direct, measurable infrastructure cost.</p><p><strong>Accuracy</strong> is the dangerous one. A human who encounters ambiguous code slows down, double checks, asks questions. An agent encountering the same ambiguity does not hesitate. It makes a confident decision and moves forward. A human who misses something feels unsure. An agent that misses something believes it is done.</p><p>Every principle that helped humans manage complexity maps directly onto these three constraints.</p><div><hr></div><h2>Every Principle, Through the Agent Lens</h2><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!EpoS!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc71b04a2-6760-4932-a16c-5ba54b834ec9_720x309.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!EpoS!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc71b04a2-6760-4932-a16c-5ba54b834ec9_720x309.png 424w, https://substackcdn.com/image/fetch/$s_!EpoS!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc71b04a2-6760-4932-a16c-5ba54b834ec9_720x309.png 848w, https://substackcdn.com/image/fetch/$s_!EpoS!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc71b04a2-6760-4932-a16c-5ba54b834ec9_720x309.png 1272w, https://substackcdn.com/image/fetch/$s_!EpoS!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc71b04a2-6760-4932-a16c-5ba54b834ec9_720x309.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!EpoS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc71b04a2-6760-4932-a16c-5ba54b834ec9_720x309.png" width="720" height="309" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c71b04a2-6760-4932-a16c-5ba54b834ec9_720x309.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:309,&quot;width&quot;:720,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:58261,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://sohit.substack.com/i/189043210?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc71b04a2-6760-4932-a16c-5ba54b834ec9_720x309.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!EpoS!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc71b04a2-6760-4932-a16c-5ba54b834ec9_720x309.png 424w, https://substackcdn.com/image/fetch/$s_!EpoS!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc71b04a2-6760-4932-a16c-5ba54b834ec9_720x309.png 848w, https://substackcdn.com/image/fetch/$s_!EpoS!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc71b04a2-6760-4932-a16c-5ba54b834ec9_720x309.png 1272w, https://substackcdn.com/image/fetch/$s_!EpoS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc71b04a2-6760-4932-a16c-5ba54b834ec9_720x309.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>The problems didn&#8217;t change. The cost of getting them wrong did.</p><div><hr></div><h2>This Is Not Theoretical</h2><p>Before going further, here is why this pattern shows up consistently across tools and research.</p><p>Cursor ships a 500 line file limit recommendation specifically because large files degrade agent retrieval quality. &#185; LLM research consistently documents accuracy loss on information buried in long contexts, what researchers call the lost in the middle problem. &#178; And in January 2026 Cursor shipped dynamic context discovery, moving away from static context loading toward pulling only what the agent needs on demand. Their A/B tests showed a 46.9% token reduction just from tighter context loading. &#179;</p><p>Three independent signals pointing at the same thing. Retrievability dominates cost, speed, and correctness.</p><p>They are building tooling to compensate for bad codebases. Low Retrieval Debt makes that compensation unnecessary. The teams that win won&#8217;t have the best agent prompts. They will have codebases that are cheap to understand, cheap to modify, and hard to misunderstand.</p><div><hr></div><h2>Naming Is Now Architecture</h2><p>Agents don&#8217;t remember your codebase. They find it through semantic search. Your repository is indexed as vector embeddings and the agent retrieves what looks relevant to the query.</p><p>Poor naming isn&#8217;t a style issue. It is a retrieval failure.</p><pre><code><code># Agent searching "discount logic" will miss this
def compute_final_value(u, amt, fl=False):
    if u.tier == 2:
        amt = amt * 0.9

# Agent finds this immediately
def apply_user_discount(user, order_amount: float, is_flash_sale: bool = False) -&gt; float:
    premium_discount = 0.10
</code></code></pre><p>Same logic. One surfaces. One doesn&#8217;t. The agent that misses the first version doesn&#8217;t raise a hand. It reimplements somewhere else and moves on confidently.</p><p>A function with single responsibility averages 20 to 50 lines. A god class doing six things averages 400 or more. An agent loading the god class to change one behavior loads 8 to 20 times more tokens than necessary. That is not a style problem. That is an infrastructure cost.</p><p>Naming conventions are no longer bikeshedding. They are part of your agent infrastructure.</p><div><hr></div><h2>Retrieval Debt: The Metric That Matters</h2><blockquote><p><em><strong>Retrieval Debt is how much context an agent must load to safely understand, change, and verify a single unit of behavior. Lower is better. Always.</strong></em></p></blockquote><p>This applies to your static codebase, core domain logic, data models, API contracts. Ephemeral generated code and <em>throwaway scripts are a different conversation</em>. But the foundation your agents build everything else on top of will always need these principles, and in an agentic world it needs them more rigorously than ever.</p><p>Discount logic scattered across three services means three retrievals, three formula structures, three edits, and a silent inconsistency the agent believes it already fixed. The same logic centralized means one retrieval, one edit, one test.</p><pre><code><code># High Retrieval Debt
# cart_service.py
if user.is_premium:
    total *= 0.9

# order_service.py
if user.is_premium:
    price = price * 0.9

# invoice_service.py
discount = 0.1 if user.is_premium else 0
final = amount - (amount * discount)

# Low Retrieval Debt
# pricing/discounts.py
PREMIUM_DISCOUNT = 0.10

def apply_user_discount(user, amount: float) -&gt; float:
    if user.is_premium:
        return amount * (1 - PREMIUM_DISCOUNT)
    return amount
</code></code></pre><p>A human missing one location creates a bug. An agent missing one location creates a silent production incident it is confident never happened.</p><div><hr></div><h2>What This Means for Your Team</h2><p>Agents have no domain understanding, no memory of past tradeoffs, no intuition about why your system looks the way it does. Their guess is often structurally plausible and contextually wrong.</p><p>Senior engineers become more valuable, not less. Their role shifts from writing code to shaping the context agents operate in, boundaries, names, abstractions, architectural intent. They nudge agents toward the right design by making the problem clear enough that the agent cannot go too far wrong.</p><p>For product and engineering leaders who don&#8217;t live in the code: ask your team one question. How many files does an agent need to read to safely change this feature? If they don&#8217;t know, or if the answer is more than three, you have a Retrieval Debt conversation worth having before your next planning cycle.</p><p>If your best engineers are shepherding agents through a messy codebase instead of making architectural calls, your structure is the bottleneck. That is Retrieval Debt showing up as a people cost.</p><div><hr></div><h2>How to Reduce Retrieval Debt This Week</h2><p><strong>The 2-3 file rule.</strong> If a safe change requires more than 2-3 files, you have a problem worth fixing now.</p><p><strong>The single retrieval test.</strong> Could an agent find the right place with one semantic search? If not, your naming or boundaries are wrong.</p><p><strong>The edit surface check.</strong> Count how many places change for one business rule update. More than two is Retrieval Debt.</p><div><hr></div><h2>The Bottom Line</h2><p>Your codebase is no longer just a communication medium between engineers. It is a knowledge base your agents query under cost and accuracy constraints, thousands of times a day.</p><p>Agent debt is the new technical debt. Retrieval Debt is how you measure it.</p><p>Start with your most changed modules. Count the retrievals needed to make a safe change. Drive that number down.</p><p>Most teams are accumulating this without noticing. The ones who design against it now will compound quietly while everyone else wonders why their agent productivity hit a ceiling.</p><div><hr></div><p><em>&#185; Cursor, Working with Context, docs.cursor.com/en/guides/working-with-context</em> <em>&#178; Lost in the Middle, Stanford NLP Research, 2023</em> <em>&#179; Cursor, Dynamic Context Discovery, January 2026. cursor.com/blog/dynamic-context-discovery</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://sohit.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://sohit.substack.com/subscribe?"><span>Subscribe now</span></a></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://sohit.substack.com/p/retrieval-debt-the-technical-debt?utm_source=substack&utm_medium=email&utm_content=share&action=share&quot;,&quot;text&quot;:&quot;Share&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://sohit.substack.com/p/retrieval-debt-the-technical-debt?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://sohit.substack.com/?utm_source=substack&amp;utm_medium=email&amp;utm_content=share&amp;action=share&quot;,&quot;text&quot;:&quot;Share sohit&#8217;s Newsletter&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://sohit.substack.com/?utm_source=substack&amp;utm_medium=email&amp;utm_content=share&amp;action=share"><span>Share sohit&#8217;s Newsletter</span></a></p><div class="directMessage button" data-attrs="{&quot;userId&quot;:14193308,&quot;userName&quot;:&quot;sohit kumar&quot;,&quot;canDm&quot;:null,&quot;dmUpgradeOptions&quot;:null,&quot;isEditorNode&quot;:true}" data-component-name="DirectMessageToDOM"></div><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://sohit.substack.com/p/retrieval-debt-the-technical-debt/comments&quot;,&quot;text&quot;:&quot;Leave a comment&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://sohit.substack.com/p/retrieval-debt-the-technical-debt/comments"><span>Leave a comment</span></a></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://sohit.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading sohit&#8217;s Newsletter! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p></p>]]></content:encoded></item><item><title><![CDATA[Building AI Agents? The Hard Part Isn’t the Agent]]></title><description><![CDATA[Why 95% of enterprise AI pilots fail - and what the successful ones do differently.]]></description><link>https://sohit.substack.com/p/building-ai-agents-the-hard-part</link><guid isPermaLink="false">https://sohit.substack.com/p/building-ai-agents-the-hard-part</guid><dc:creator><![CDATA[sohit kumar]]></dc:creator><pubDate>Sat, 31 Jan 2026 12:57:27 GMT</pubDate><content:encoded><![CDATA[<p>MIT research found that 95% of enterprise AI pilots fail to deliver measurable returns.</p><p>Not because the technology doesn&#8217;t work. Not because the models aren&#8217;t capable.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://sohit.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading sohit&#8217;s Newsletter! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>MIT calls it a &#8220;learning gap&#8221; - organizations don&#8217;t know how to integrate AI into real workflows.</p><p>From what I&#8217;ve seen, the gap is architectural. Teams build agents when they should be building systems.</p><div><hr></div><p>I work with teams building agentic platforms.</p><p>The first enterprise customer conversation is usually humbling.</p><p>They don&#8217;t ask about your model. They don&#8217;t ask about your prompts or your reasoning capabilities.</p><p>They ask:</p><blockquote><p><em>&#8220;What happens when the agent is wrong? How does it recover?&#8221;</em></p><p><em>&#8220;How will I know if something breaks at 2 AM?&#8221;</em></p><p><em>&#8220;What happens if a workflow fails halfway through?&#8221;</em></p><p><em>&#8220;When do humans get involved? How do you learn from that?&#8221;</em></p><p><em>&#8220;How do I audit what the agent did and why? Can one customer&#8217;s data touch another&#8217;s?&#8221;</em></p><p><em>&#8220;Where does inference happen? Does data stay in our region?&#8221;</em></p></blockquote><p>Most teams have good answers to maybe three of these.</p><p>That gap is where projects stall. Or die.</p><div><hr></div><p><strong>An agentic system is not an LLM with tools.</strong></p><p><strong>It is a production system where probabilistic reasoning is wrapped by deterministic execution, visibility, and control.</strong></p><div class="pullquote"><p><strong>The agent gets all the attention. But the system around it is what actually ships.</strong></p></div><h2>Reliability beats intelligence</h2><p>The most successful deployments aren&#8217;t the ones with the cleverest agents. They&#8217;re the ones that work consistently.</p><p>An agent that gives you an 8/10 answer every time is more valuable than one that gives you 10/10 half the time and fails unpredictably the other half. Enterprise workflows don&#8217;t tolerate variance. A finance team running month-end close doesn&#8217;t want &#8220;usually works.&#8221; They want &#8220;always works, and when it doesn&#8217;t, we know immediately.&#8221;</p><p>The optimization target that matters is not &#8220;how good is the output&#8221; but &#8220;how predictable is the outcome.&#8221;</p><p>Evals aren&#8217;t optional for agentic systems. They&#8217;re foundational.</p><p>In traditional software, you write tests once and they pass or fail deterministically. Agentic systems don&#8217;t work that way. The same input can produce different outputs. Model updates change behavior silently. Prompts that worked last month drift without warning.</p><p>Run evals continuously in production, not just during development. Catch drift before users do.</p><p>And when you have multiple agents working together, evals become even more critical. Each agent might perform fine in isolation. But chain them together and failures compound. Agent A&#8217;s slightly off output becomes Agent B&#8217;s confidently wrong input. Without evals at every handoff, you&#8217;re debugging in the dark.</p><p>The teams that treat evals as infrastructure - not an afterthought - are the ones shipping reliably.</p><h2>Observability is the moat</h2><p>If you can&#8217;t see what your agent is doing in production, you can&#8217;t improve it. You&#8217;re guessing. You&#8217;re relying on user complaints to surface issues. By the time you hear about a problem, it&#8217;s been happening for weeks.</p><p>Tools like Langfuse and Arize give you this visibility. Inputs, outputs, latency, token usage, outcomes, all traceable end to end.</p><p>Most teams can&#8217;t answer basic questions about their production agents. What&#8217;s your p95 latency? What percentage of requests need retry? Which tool calls fail most often?</p><p>Observability isn&#8217;t a feature you add later. It&#8217;s infrastructure that determines how fast you can iterate. Teams with better visibility ship improvements faster. That compounds.</p><h2>Orchestration is the unsexy superpower</h2><p>Your agent&#8217;s reasoning can be probabilistic. Your execution layer cannot.</p><p>When an agent decides to call an API, update a record, or send a message, that action needs to happen reliably. If it fails, it needs to retry. If it retries, it can&#8217;t duplicate side effects. If the workflow crashes mid-way, it needs to resume from where it left off, not start over.</p><p>Tools like Temporal and Restate give you durable execution, automatic retries, state persistence, and exactly-once semantics.</p><p>Simple try-catch logic works for demos. It falls apart in production with multi-step workflows, external dependencies, and edge cases you didn&#8217;t anticipate.</p><p>Orchestration is what turns an agent into a system.</p><p>An agent without durable orchestration is a demo, not a system.</p><h2>HITL is your learning loop</h2><p>The common assumption is that HITL is a transitional state. You start with humans in the loop, then gradually remove them as the agent gets better. Full autonomy is the goal.</p><p>That&#8217;s not what I see working.</p><p>The goal isn&#8217;t fewer humans. The goal is faster correct outcomes. Sometimes that means more autonomy. Sometimes it means a human reviewing something for 10 seconds before the agent proceeds.</p><p>But here&#8217;s what most teams miss: HITL isn&#8217;t just about catching errors. It&#8217;s your learning loop.</p><p>Every human correction is training data. Every escalation shows where your agent is weak. Every approval pattern tells you where you can safely increase autonomy.</p><p>The teams that treat HITL as a feedback system improve faster than everyone else. They&#8217;re not trying to remove humans from the loop. They&#8217;re using humans to make the system smarter.</p><p>Design for this from day one. Capture why humans intervene, not just that they did. Track which corrections repeat. Feed that back into your evals, your prompts, your guardrails.</p><p>The system should get smarter because humans are in the loop, not despite it.</p><h2>Security &amp; Governance is architecture</h2><p>Enterprise customers ask about security on day one. The temptation is to add it later. That&#8217;s a mistake.</p><p>Prompt injection defense. Tenant isolation. RBAC not just for users, but for agents acting on behalf of users. Audit trails for every autonomous action. Data classification that handles derived data, not just raw inputs.</p><p>You can&#8217;t retrofit this cleanly. Security boundaries are system-level concerns. Design them in from the start and they&#8217;re natural. Add them later and they&#8217;re a patchwork.</p><p>And before you even get to the technical conversation, there&#8217;s the compliance gate. SOC 2, ISO 27001, and depending on the industry, HIPAA or PCI-DSS. For agentic systems, this is harder than traditional software - you&#8217;re not just auditing what humans did, you&#8217;re auditing what agents decided to do autonomously. If you don&#8217;t have a clear answer for how you&#8217;ll pass an audit, enterprise deals stall before they start.</p><p>Every security question is really an architecture question. &#8220;How do you prevent X&#8221; is really &#8220;how is your system designed so that X can&#8217;t happen.&#8221;</p><h2>Data locality kills deals</h2><p>This one catches teams off guard. You build the system, it works, you&#8217;re ready to close a deal. Then the customer asks &#8220;where does inference happen?&#8221; and the project stalls.</p><p>Data residency and model residency are different problems. You might store customer data in the right region, but if inference happens via an external API that crosses geographic boundaries, you still have a compliance issue.</p><p>Infrastructure-as-code for multi-region deployment. Your entire stack should be deployable to any supported region with configuration changes, not re-architecture.</p><p>Some customers need BYOC for compliance or control. It adds complexity for everyone. But for customers with strict requirements, it&#8217;s the only path forward.</p><p>Compliance and data locality aren&#8217;t features you add at the end. They&#8217;re constraints that shape your architecture from the start.</p><h2>The shift</h2><p>95% of AI pilots fail not because the technology doesn&#8217;t work. They fail because teams build agents when they should be building systems.</p><p>The agent is a component. The system includes orchestration, observability, human escalation, security, reliability, and everything that makes it work in the real world.</p><p>Stop thinking &#8220;I&#8217;m building an agent.&#8221; Start thinking &#8220;I&#8217;m building a system that includes an agent.&#8221;</p><p>The agent demos. The system ships.</p><div><hr></div><p>I advise teams building agentic systems for enterprise. If you&#8217;re navigating this, let&#8217;s talk.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://sohit.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://sohit.substack.com/subscribe?"><span>Subscribe now</span></a></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://sohit.substack.com/?utm_source=substack&amp;utm_medium=email&amp;utm_content=share&amp;action=share&quot;,&quot;text&quot;:&quot;Share sohit&#8217;s Newsletter&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://sohit.substack.com/?utm_source=substack&amp;utm_medium=email&amp;utm_content=share&amp;action=share"><span>Share sohit&#8217;s Newsletter</span></a></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://sohit.substack.com/p/building-ai-agents-the-hard-part?utm_source=substack&utm_medium=email&utm_content=share&action=share&quot;,&quot;text&quot;:&quot;Share&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://sohit.substack.com/p/building-ai-agents-the-hard-part?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://sohit.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading sohit&#8217;s Newsletter! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://sohit.substack.com/p/building-ai-agents-the-hard-part/comments&quot;,&quot;text&quot;:&quot;Leave a comment&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://sohit.substack.com/p/building-ai-agents-the-hard-part/comments"><span>Leave a comment</span></a></p><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://sohit.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading sohit&#8217;s Newsletter! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Tech]]></title><description><![CDATA[Welcome to sohit&#8217;s Newsletter by me, sohit kumar.]]></description><link>https://sohit.substack.com/p/coming-soon</link><guid isPermaLink="false">https://sohit.substack.com/p/coming-soon</guid><dc:creator><![CDATA[sohit kumar]]></dc:creator><pubDate>Fri, 08 Jan 2021 15:15:19 GMT</pubDate><content:encoded><![CDATA[<p>Welcome to sohit&#8217;s Newsletter by me, sohit kumar. building tech platforms. https://t.co/oyf9UWt2kI https://x.com/ksohit</p><p>Sign up now so you don&#8217;t miss the first issue.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://sohit.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://sohit.substack.com/subscribe?"><span>Subscribe now</span></a></p><p>In the meantime, <a href="https://sohit.substack.com/p/coming-soon?utm_source=substack&utm_medium=email&utm_content=share&action=share">tell your friends</a>!</p>]]></content:encoded></item></channel></rss>