<?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[Decoding AI Magazine]]></title><description><![CDATA[Join for content on designing, building, and shipping AI software. Learn AI engineering, end-to-end, from idea to production. Every Tuesday.]]></description><link>https://www.decodingai.com</link><image><url>https://substackcdn.com/image/fetch/$s_!k2ig!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F00bc74e0-3601-49ce-8ab9-4c7b499ce597_1280x1280.png</url><title>Decoding AI Magazine</title><link>https://www.decodingai.com</link></image><generator>Substack</generator><lastBuildDate>Tue, 24 Nov 2026 02:11:30 GMT</lastBuildDate><atom:link href="https://www.decodingai.com/feed" rel="self" type="application/rss+xml"/><copyright><![CDATA[Paul-Emil Iusztin]]></copyright><language><![CDATA[en]]></language><webMaster><![CDATA[decodingai@substack.com]]></webMaster><itunes:owner><itunes:email><![CDATA[decodingai@substack.com]]></itunes:email><itunes:name><![CDATA[Paul Iusztin]]></itunes:name></itunes:owner><itunes:author><![CDATA[Paul Iusztin]]></itunes:author><googleplay:owner><![CDATA[decodingai@substack.com]]></googleplay:owner><googleplay:email><![CDATA[decodingai@substack.com]]></googleplay:email><googleplay:author><![CDATA[Paul Iusztin]]></googleplay:author><itunes:block><![CDATA[Yes]]></itunes:block><item><title><![CDATA[Ship Agent Changes Safely in 5 Steps]]></title><description><![CDATA[Label your traces and replay every failure.]]></description><link>https://www.decodingai.com/p/ship-agent-changes-safely</link><guid isPermaLink="false">https://www.decodingai.com/p/ship-agent-changes-safely</guid><dc:creator><![CDATA[Paul Iusztin]]></dc:creator><pubDate>Thu, 19 Nov 2026 12:02:46 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/83c91fda-f557-4406-ad07-8144c7aacb67_1376x768.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>You change a prompt on a branch... no errors, no complaints. Did you just break something that worked yesterday? The scariest AI failures are the silent ones.</p><p>Without a way to know, you get afraid to change your prompts because the chance of breaking what worked without noticing is too high.</p><p>The fix: build evals from your own failures.&nbsp;<em>This roadmap shows you how to do it.</em></p><div><hr></div><h2>1. <a href="https://www.decodingai.com/p/build-an-ai-evals-dataset-with-error-analysis">No Evals Dataset? Here&#8217;s How to Build One from Scratch</a></h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!_A5d!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e9a5f98-b289-4295-9168-a2fbbe80a84e_1201x1090.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!_A5d!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e9a5f98-b289-4295-9168-a2fbbe80a84e_1201x1090.png 424w, https://substackcdn.com/image/fetch/$s_!_A5d!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e9a5f98-b289-4295-9168-a2fbbe80a84e_1201x1090.png 848w, https://substackcdn.com/image/fetch/$s_!_A5d!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e9a5f98-b289-4295-9168-a2fbbe80a84e_1201x1090.png 1272w, https://substackcdn.com/image/fetch/$s_!_A5d!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e9a5f98-b289-4295-9168-a2fbbe80a84e_1201x1090.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!_A5d!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e9a5f98-b289-4295-9168-a2fbbe80a84e_1201x1090.png" width="1201" height="1090" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9e9a5f98-b289-4295-9168-a2fbbe80a84e_1201x1090.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1090,&quot;width&quot;:1201,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;The four-quadrant matrix that ranks failure clusters by frequency and severity.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="The four-quadrant matrix that ranks failure clusters by frequency and severity." title="The four-quadrant matrix that ranks failure clusters by frequency and severity." srcset="https://substackcdn.com/image/fetch/$s_!_A5d!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e9a5f98-b289-4295-9168-a2fbbe80a84e_1201x1090.png 424w, https://substackcdn.com/image/fetch/$s_!_A5d!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e9a5f98-b289-4295-9168-a2fbbe80a84e_1201x1090.png 848w, https://substackcdn.com/image/fetch/$s_!_A5d!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e9a5f98-b289-4295-9168-a2fbbe80a84e_1201x1090.png 1272w, https://substackcdn.com/image/fetch/$s_!_A5d!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e9a5f98-b289-4295-9168-a2fbbe80a84e_1201x1090.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Rank every failure cluster by frequency and severity.</em></figcaption></figure></div><p>Most teams write elaborate eval criteria before looking at their data. Pull 20-50 real traces instead, and have one domain expert mark each <em>Pass</em> or <em>Fail</em> with a short critique of the first thing that went wrong. Then cluster the failures and rank them by frequency and severity. Your dataset is the secret weapon, not your system prompt.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://www.decodingai.com/p/build-an-ai-evals-dataset-with-error-analysis&quot;,&quot;text&quot;:&quot;Read the article&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://www.decodingai.com/p/build-an-ai-evals-dataset-with-error-analysis"><span>Read the article</span></a></p>
      <p>
          <a href="https://www.decodingai.com/p/ship-agent-changes-safely">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[Build Durable, Secure Long-Running Agents]]></title><description><![CDATA[From crashes, throwaway code and surprise bills to a $74.63 run you are proud of]]></description><link>https://www.decodingai.com/p/build-durable-secure-long-running-agents</link><guid isPermaLink="false">https://www.decodingai.com/p/build-durable-secure-long-running-agents</guid><dc:creator><![CDATA[Paul Iusztin]]></dc:creator><pubDate>Tue, 17 Nov 2026 07:02:53 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!0FNk!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb5d235f5-7e88-4c60-9445-a808f3c3c25a_1376x768.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_!0FNk!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb5d235f5-7e88-4c60-9445-a808f3c3c25a_1376x768.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!0FNk!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb5d235f5-7e88-4c60-9445-a808f3c3c25a_1376x768.png 424w, https://substackcdn.com/image/fetch/$s_!0FNk!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb5d235f5-7e88-4c60-9445-a808f3c3c25a_1376x768.png 848w, https://substackcdn.com/image/fetch/$s_!0FNk!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb5d235f5-7e88-4c60-9445-a808f3c3c25a_1376x768.png 1272w, https://substackcdn.com/image/fetch/$s_!0FNk!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb5d235f5-7e88-4c60-9445-a808f3c3c25a_1376x768.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!0FNk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb5d235f5-7e88-4c60-9445-a808f3c3c25a_1376x768.png" width="1376" height="768" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b5d235f5-7e88-4c60-9445-a808f3c3c25a_1376x768.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:768,&quot;width&quot;:1376,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;One lantern out, the climb still lit: a failure should cost one round, never the night.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="One lantern out, the climb still lit: a failure should cost one round, never the night." title="One lantern out, the climb still lit: a failure should cost one round, never the night." srcset="https://substackcdn.com/image/fetch/$s_!0FNk!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb5d235f5-7e88-4c60-9445-a808f3c3c25a_1376x768.png 424w, https://substackcdn.com/image/fetch/$s_!0FNk!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb5d235f5-7e88-4c60-9445-a808f3c3c25a_1376x768.png 848w, https://substackcdn.com/image/fetch/$s_!0FNk!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb5d235f5-7e88-4c60-9445-a808f3c3c25a_1376x768.png 1272w, https://substackcdn.com/image/fetch/$s_!0FNk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb5d235f5-7e88-4c60-9445-a808f3c3c25a_1376x768.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>What would it take to trust an AI agent to work on your code overnight? Without burning through LLM API credits to reach its goal no matter what, exposing your credentials to the AI overlords, or losing hours of progress when something crashes at 5 AM.</p><p>Long-running agents that implement huge chunks of work while you do something else are the future. You have to be delusional not to accept that.</p><p>That&#8217;s why in the past month, I asked exactly these questions on LinkedIn and X, and about 100 engineers answered. All of them felt this pain and asked me to propose a way to set a spend cap the agent can&#8217;t override, credentials it can never read, and a crash that costs one round, not the entire run.</p><blockquote><p>I created a prototype that touches all these problems while building <a href="https://github.com/decodingai-magazine/codeclimb">CodeClimb</a>, an overnight eval-driven code search inspired by Andrej Karpathy&#8217;s autoresearch.</p></blockquote><p>In my first CodeClimb vanilla form, I topped up OpenRouter with $10, not knowing what a run costs. After 6 rounds, it burned through all my credits, and the run died mid-turn, losing all my work. Sounds familiar? These are the pain points I want to solve by designing durable, secure, long-running agents! Using CodeClimb as an example.</p><p>Image 1 shows CodeClimb&#8217;s loop at the highest level: the coding agent writes the solution as an experiment, then we evaluate it on the dev split and repeat until done. Ultimately, we compute the metrics on the test split to see if it overfits. Bringing a data science mindset to coding agents.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!OtD0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca4e5d29-5a10-45df-81bb-c65dbda2ad78_1200x626.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!OtD0!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca4e5d29-5a10-45df-81bb-c65dbda2ad78_1200x626.png 424w, https://substackcdn.com/image/fetch/$s_!OtD0!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca4e5d29-5a10-45df-81bb-c65dbda2ad78_1200x626.png 848w, https://substackcdn.com/image/fetch/$s_!OtD0!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca4e5d29-5a10-45df-81bb-c65dbda2ad78_1200x626.png 1272w, https://substackcdn.com/image/fetch/$s_!OtD0!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca4e5d29-5a10-45df-81bb-c65dbda2ad78_1200x626.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!OtD0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca4e5d29-5a10-45df-81bb-c65dbda2ad78_1200x626.png" width="1200" height="626" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ca4e5d29-5a10-45df-81bb-c65dbda2ad78_1200x626.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:626,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;CodeClimb architecture&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="CodeClimb architecture" title="CodeClimb architecture" srcset="https://substackcdn.com/image/fetch/$s_!OtD0!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca4e5d29-5a10-45df-81bb-c65dbda2ad78_1200x626.png 424w, https://substackcdn.com/image/fetch/$s_!OtD0!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca4e5d29-5a10-45df-81bb-c65dbda2ad78_1200x626.png 848w, https://substackcdn.com/image/fetch/$s_!OtD0!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca4e5d29-5a10-45df-81bb-c65dbda2ad78_1200x626.png 1272w, https://substackcdn.com/image/fetch/$s_!OtD0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca4e5d29-5a10-45df-81bb-c65dbda2ad78_1200x626.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Image 1: CodeClimb at the highest level. The loop experiments and scores on dev until a stop condition fires, then scores the final code once on test.</em></figcaption></figure></div><p>In this article, we will touch on each pain point progressively:</p><ul><li><p>A clear way to <em>quantify the quality of generated code</em> during long-running jobs, so you can tell in time whether the code is good or should be thrown away.</p></li><li><p><em>Guardrails</em> in code to stop relying on the agent to decide when to stop due to cost or quality caps.</p></li><li><p>Pipe everything through a <em>proxy</em> to avoid dumping the credentials into the sandbox and trusting the agent will behave.</p></li><li><p>Using a <em>durability engine</em> (our choice is <a href="https://inngest.link/dai-nl">Inngest</a>) to retry failed steps or replay stopped or crashed runs.</p></li><li><p>Add a <em>human-in-the-loop</em> channel to pause if the night runs out of credits, or if we want to inject some human wisdom.</p></li></ul><p>And finally, deploy everything to the cloud, because why not!</p><p>Now, let&#8217;s start by understanding what the vanilla CodeClimb workflow does, its problems, and then make it durable and secure.</p><h2>The bare-bones CodeClimb loop</h2><p>In late 2026, the biggest issue with building reliable software with coding agents is verifying their output in terms of both clean code and performance.</p><p>Let&#8217;s be honest: when you see a PR with 23,546 lines of code changes from your coding agent, you are not going to review that. In that case, how can you make sure that the output is correct?</p><p>At Decoding AI, we are focused on building AI software, which means we are interested in using coding agents to implement other agents, RAG algorithms and fine-tuning pipelines. The beautiful part about AI software is that it&#8217;s measurable. You can encode the quality of your RAG algorithm solely by looking at the retrieval and generation scores such as F1 and mean reciprocal rank (MRR) metrics.</p><p>With <a href="https://github.com/decodingai-magazine/codeclimb/tree/main">CodeClimb</a>, we want to double down on that. We implemented an eval-driven code search workflow where the coding agent is guided purely by a spec, plus a dataset and a set of metrics specialized for your problem. Instead of relying on unit or integration tests, which are not that great when written by the coding agent, we rely on a data-driven loop to extract signal on what to improve.</p><p>For this article, we used CodeClimb to implement a GraphRAG algorithm from scratch. GraphRAG extracts the entities and relationships from your documents into a knowledge graph (shown in Image 2), merges the duplicate entities found across documents, then retrieves over that graph to answer questions. We considered GraphRAG a cool example, as it&#8217;s hard to make it work on your exact data models (your ontology). It needs a ton of tweaking. Plus, you can extract a ton of signals at multiple points in your pipeline: your node and entity extractor, duplicate-node merging and retrieval quality. We left generation out of the equation for this exercise. If you&#8217;re new to GraphRAG, I explain <a href="https://www.decodingai.com/p/agentic-graphrag">how agentic GraphRAG works</a> in a separate article.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!M-bm!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6174c53f-72c9-48a0-9828-4d5d1b89bbcf_2450x1814.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!M-bm!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6174c53f-72c9-48a0-9828-4d5d1b89bbcf_2450x1814.png 424w, https://substackcdn.com/image/fetch/$s_!M-bm!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6174c53f-72c9-48a0-9828-4d5d1b89bbcf_2450x1814.png 848w, https://substackcdn.com/image/fetch/$s_!M-bm!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6174c53f-72c9-48a0-9828-4d5d1b89bbcf_2450x1814.png 1272w, https://substackcdn.com/image/fetch/$s_!M-bm!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6174c53f-72c9-48a0-9828-4d5d1b89bbcf_2450x1814.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!M-bm!,w_2400,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6174c53f-72c9-48a0-9828-4d5d1b89bbcf_2450x1814.png" width="1200" height="888.4615384615385" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6174c53f-72c9-48a0-9828-4d5d1b89bbcf_2450x1814.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:&quot;large&quot;,&quot;height&quot;:1078,&quot;width&quot;:1456,&quot;resizeWidth&quot;:1200,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-large" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!M-bm!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6174c53f-72c9-48a0-9828-4d5d1b89bbcf_2450x1814.png 424w, https://substackcdn.com/image/fetch/$s_!M-bm!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6174c53f-72c9-48a0-9828-4d5d1b89bbcf_2450x1814.png 848w, https://substackcdn.com/image/fetch/$s_!M-bm!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6174c53f-72c9-48a0-9828-4d5d1b89bbcf_2450x1814.png 1272w, https://substackcdn.com/image/fetch/$s_!M-bm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6174c53f-72c9-48a0-9828-4d5d1b89bbcf_2450x1814.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Image 2: The knowledge graph extracted on the test split.</em></figcaption></figure></div><p>The first (and hardest) step is to build the GraphRAG dataset that will drive the whole CodeClimb coding process. We took 22 Decoding AI articles (because it&#8217;s easy for me to debug as the domain expert) and split them into 6 train, 8 dev and 8 test. We used a combination of Opus 5.5, Fable 5.1 and human reviews to extract the knowledge graph based on our ontology: people, organizations, tools, methods, systems and models. As for the metrics, we used F1 on extracted entities and relationships, recall on how well mentions of the same entity across documents merge into one node, and recall and MRR on retrieval.</p><p>You don&#8217;t need to understand GraphRAG for the rest to make sense. You need to understand that the coding agent uses the dataset and metrics as signals while coding, and that they let us quantify code quality without looking at the code. It&#8217;s just a set of clear numbers that tell you if the code is working or not. It&#8217;s similar to training a model, but here the model is our code.</p><p>Image 3 zooms into each piece of the bare-bones loop and what data it is allowed to see.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!zfSD!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb3c01fcc-6e89-4ee8-a7aa-92ba0027db3a_1200x768.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!zfSD!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb3c01fcc-6e89-4ee8-a7aa-92ba0027db3a_1200x768.png 424w, https://substackcdn.com/image/fetch/$s_!zfSD!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb3c01fcc-6e89-4ee8-a7aa-92ba0027db3a_1200x768.png 848w, https://substackcdn.com/image/fetch/$s_!zfSD!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb3c01fcc-6e89-4ee8-a7aa-92ba0027db3a_1200x768.png 1272w, https://substackcdn.com/image/fetch/$s_!zfSD!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb3c01fcc-6e89-4ee8-a7aa-92ba0027db3a_1200x768.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!zfSD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb3c01fcc-6e89-4ee8-a7aa-92ba0027db3a_1200x768.png" width="1200" height="768" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b3c01fcc-6e89-4ee8-a7aa-92ba0027db3a_1200x768.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:768,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;The bare-bones CodeClimb system: a Pi agent over a Docker sandbox for the experiment, the dev evaluation and the test evaluation&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="The bare-bones CodeClimb system: a Pi agent over a Docker sandbox for the experiment, the dev evaluation and the test evaluation" title="The bare-bones CodeClimb system: a Pi agent over a Docker sandbox for the experiment, the dev evaluation and the test evaluation" srcset="https://substackcdn.com/image/fetch/$s_!zfSD!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb3c01fcc-6e89-4ee8-a7aa-92ba0027db3a_1200x768.png 424w, https://substackcdn.com/image/fetch/$s_!zfSD!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb3c01fcc-6e89-4ee8-a7aa-92ba0027db3a_1200x768.png 848w, https://substackcdn.com/image/fetch/$s_!zfSD!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb3c01fcc-6e89-4ee8-a7aa-92ba0027db3a_1200x768.png 1272w, https://substackcdn.com/image/fetch/$s_!zfSD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb3c01fcc-6e89-4ee8-a7aa-92ba0027db3a_1200x768.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Image 3: The bare-bones system. The coder never sees the dev or test splits, and every round&#8217;s hypothesis and review go to the history.</em></figcaption></figure></div><p>Here is <strong>how CodeClimb works</strong>. The workflow is split into:</p><ol><li><p><strong>The experiment</strong>, where we use a Pi coding agent to write the code within a Docker sandbox. It gets as input the GraphRAG spec, the train split, which it can use as few-shot examples to verify its work, plus the history from previous experiments.</p></li><li><p><strong>The evaluator</strong> takes the code from the experiment and computes the metrics on the dev split. On top of that, we use another Pi coding agent, running in a completely different Docker sandbox, which, based on the code and the metric results, writes a review that guides future iterations.</p></li><li><p>The experimentation and evaluation steps are <strong>orchestrated by TypeScript code</strong>. After each evaluation, it combines all the dev metrics into one weighted score, where each metric counts only up to its threshold, such as 0.8 on the extraction F1 score. An experiment is kept only if this score beats the best checkpoint by more than the evaluation&#8217;s noise, which we measure by scoring the kept code a second time without changing it. Otherwise, the next round reverts to the best checkpoint. Either way, the experiment&#8217;s assumption and the reviewer&#8217;s results go into a decision history, kept for the dropped experiments too, so the coding agent knows what works and what doesn&#8217;t, and doesn&#8217;t repeat itself. The loop goes on until every threshold is met or a stop condition fires.</p></li><li><p>After the loop finishes, we <strong>compute the metrics once on the test split</strong>. If the dev scores are much higher than the test ones, the code overfits.</p></li><li><p>We report all the results to a Next.js <strong>dashboard</strong> where we can monitor, stop or resume a night run.</p></li></ol><p>The numbers this loop produces are only reliable because we completely decoupled the coding from evaluation. You could have passed this dataset directly to Claude Code via vanilla prompting or skills, but agents are well known for cheating. Nothing would have stopped the coding agent from looking into the dev or test split results.</p><p>That&#8217;s why the coder never grades itself. The coding and evaluation steps are isolated in different Docker sandboxes. The Pi coding agent never sees dev or test data, or their gold answers. The only bridge is the reviewer&#8217;s feedback.</p><p>On top of the per-night decision history, we also track learnings between nights, distilling each night&#8217;s decision log into a 200-line Markdown file that aggregates them. Thus, even if we start a night from scratch, it can tap into the wisdom of its predecessors.</p><p>Every night is also reproducible by construction. The night&#8217;s configuration lives in a YAML config file, so the models, the reviewer model and the dataset split are always known. The dataset isn&#8217;t huge, so it&#8217;s committed to git along with the evaluators and the Markdown file that aggregates the decision-log memory between night runs. What we cannot control is the stochasticity of the coding agent, but at least we know all the inputs and metadata parameters.</p><p>Here is the GraphRAG night run config file:</p><pre><code><code>scenario: scenarios/graphrag
sandbox: docker
max_rounds: 26
plateau_rounds: 9
deadline: 24h
timeouts:
  experiment_min: 30
  eval_min: 10
model: anthropic/claude-opus-5-5
coder_thinking: medium  # off | minimal | low | medium | high
reviewer_model: anthropic/claude-opus-5-5
reviewer_thinking: high
allowed_models:
  - openrouter/deepseek/deepseek-v4.1-flash
  - openrouter/typesafe/jev-1.14
  - openrouter/qwen/qwen3-embedding-4b
  - openrouter/qwen/qwen3-reranker-8b
primary_metric: extraction.mentions.f1
thresholds:
  extraction.mentions.f1: 0.8
  extraction.relations.undirected.f1: 0.6
  graph.b_cubed.recall: 0.98
  retrieval.by_kind.single_hop.metrics.edge_recall_at_k.mean: 0.95
  retrieval.by_kind.single_hop.metrics.answer_mrr.mean: 0.9
budget_usd:
  experiment: 2.5
  night: 120
results_path: graphrag/results.jsonl
</code></code></pre><p>Image 4 shows the node extraction F1 of our winning night. CodeClimb did not get stuck in the first rounds and kept climbing. For F1, one is the best and zero is the worst.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!5Hiv!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff05ece8a-4157-462a-accb-46ffac4dee73_1990x1328.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!5Hiv!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff05ece8a-4157-462a-accb-46ffac4dee73_1990x1328.png 424w, https://substackcdn.com/image/fetch/$s_!5Hiv!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff05ece8a-4157-462a-accb-46ffac4dee73_1990x1328.png 848w, https://substackcdn.com/image/fetch/$s_!5Hiv!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff05ece8a-4157-462a-accb-46ffac4dee73_1990x1328.png 1272w, https://substackcdn.com/image/fetch/$s_!5Hiv!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff05ece8a-4157-462a-accb-46ffac4dee73_1990x1328.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!5Hiv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff05ece8a-4157-462a-accb-46ffac4dee73_1990x1328.png" width="728" height="486" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f05ece8a-4157-462a-accb-46ffac4dee73_1990x1328.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:&quot;normal&quot;,&quot;height&quot;:972,&quot;width&quot;:1456,&quot;resizeWidth&quot;:728,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:&quot;center&quot;,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!5Hiv!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff05ece8a-4157-462a-accb-46ffac4dee73_1990x1328.png 424w, https://substackcdn.com/image/fetch/$s_!5Hiv!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff05ece8a-4157-462a-accb-46ffac4dee73_1990x1328.png 848w, https://substackcdn.com/image/fetch/$s_!5Hiv!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff05ece8a-4157-462a-accb-46ffac4dee73_1990x1328.png 1272w, https://substackcdn.com/image/fetch/$s_!5Hiv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff05ece8a-4157-462a-accb-46ffac4dee73_1990x1328.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Image 4: Node extraction F1 climbed to 0.764 on dev, below the 0.8 threshold. Some reverted rounds score higher because the weighted score over all metrics is still lower.</em></figcaption></figure></div><p>The infrastructure supports letting the agent run for more iterations, which would let it explore more branches and potentially find a better solution that hits our expected threshold. But this night ended on its 26-round cap, and we ran out of credits.</p><p>Image 5 shows the same climb for edge extraction, the harder problem:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!68zF!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47fc62ae-fcef-4298-a4db-caf6ccbb81c3_1998x1344.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!68zF!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47fc62ae-fcef-4298-a4db-caf6ccbb81c3_1998x1344.png 424w, https://substackcdn.com/image/fetch/$s_!68zF!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47fc62ae-fcef-4298-a4db-caf6ccbb81c3_1998x1344.png 848w, https://substackcdn.com/image/fetch/$s_!68zF!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47fc62ae-fcef-4298-a4db-caf6ccbb81c3_1998x1344.png 1272w, https://substackcdn.com/image/fetch/$s_!68zF!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47fc62ae-fcef-4298-a4db-caf6ccbb81c3_1998x1344.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!68zF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47fc62ae-fcef-4298-a4db-caf6ccbb81c3_1998x1344.png" width="728" height="489.5" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/47fc62ae-fcef-4298-a4db-caf6ccbb81c3_1998x1344.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:&quot;normal&quot;,&quot;height&quot;:979,&quot;width&quot;:1456,&quot;resizeWidth&quot;:728,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:&quot;center&quot;,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!68zF!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47fc62ae-fcef-4298-a4db-caf6ccbb81c3_1998x1344.png 424w, https://substackcdn.com/image/fetch/$s_!68zF!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47fc62ae-fcef-4298-a4db-caf6ccbb81c3_1998x1344.png 848w, https://substackcdn.com/image/fetch/$s_!68zF!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47fc62ae-fcef-4298-a4db-caf6ccbb81c3_1998x1344.png 1272w, https://substackcdn.com/image/fetch/$s_!68zF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47fc62ae-fcef-4298-a4db-caf6ccbb81c3_1998x1344.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Image 5: Edge extraction F1 reached 0.455 on dev but only 0.368 on test, so relationships generalize worst.</em></figcaption></figure></div><p>The graph merge recall (0.994), retrieval recall (0.909) and MRR (0.922) metrics all scored over 0.9 on the test split, where 1 is maximum for all metrics.</p><p>For our tests, we powered Pi with our GitHub Copilot subscription (we have Pro for free as an open-source contributor), plus Anthropic models via their API key, as using the subscription is against their policy (we have the Ultra plan, which provides $200 in API credits). The GraphRAG program itself calls 4 cheap models via OpenRouter, listed in the config above.</p><p>Across our experiments, we consumed $168 in Anthropic credits, $44 in OpenRouter credits and ~$7 of our GitHub Copilot subscription credits. Almost all of the winning night&#8217;s cost went to Opus 5.5 on medium effort ($71.13), and only about $3.50 went to the OpenRouter models. Image 6 shows its dashboard summary.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!c5IU!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a9ae401-ecf4-4bd1-95dd-330e1ff580b1_3240x1006.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!c5IU!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a9ae401-ecf4-4bd1-95dd-330e1ff580b1_3240x1006.png 424w, https://substackcdn.com/image/fetch/$s_!c5IU!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a9ae401-ecf4-4bd1-95dd-330e1ff580b1_3240x1006.png 848w, https://substackcdn.com/image/fetch/$s_!c5IU!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a9ae401-ecf4-4bd1-95dd-330e1ff580b1_3240x1006.png 1272w, https://substackcdn.com/image/fetch/$s_!c5IU!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a9ae401-ecf4-4bd1-95dd-330e1ff580b1_3240x1006.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!c5IU!,w_2400,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a9ae401-ecf4-4bd1-95dd-330e1ff580b1_3240x1006.png" width="1200" height="372.5274725274725" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5a9ae401-ecf4-4bd1-95dd-330e1ff580b1_3240x1006.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:&quot;large&quot;,&quot;height&quot;:452,&quot;width&quot;:1456,&quot;resizeWidth&quot;:1200,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-large" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!c5IU!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a9ae401-ecf4-4bd1-95dd-330e1ff580b1_3240x1006.png 424w, https://substackcdn.com/image/fetch/$s_!c5IU!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a9ae401-ecf4-4bd1-95dd-330e1ff580b1_3240x1006.png 848w, https://substackcdn.com/image/fetch/$s_!c5IU!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a9ae401-ecf4-4bd1-95dd-330e1ff580b1_3240x1006.png 1272w, https://substackcdn.com/image/fetch/$s_!c5IU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a9ae401-ecf4-4bd1-95dd-330e1ff580b1_3240x1006.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Image 6: The winning night: 26 rounds, 11.8 hours, $74.63. With checkpoints, a crash costs at most one $2.87 round, never all 26.</em></figcaption></figure></div><p>To double-check the metrics, we also render a graph visualization highlighting the extractions that matched the gold dataset, wrong node types, the extractions predicted but not in gold and the missed ones. Image 7 shows it on the dev split. Looking at the data, some predictions flagged as not in gold are valid (e.g., &#8220;unified memory&#8221; as a system), so the gold dataset needs another pass. In other words: <em><strong>&#8220;Look at your data!&#8221;</strong></em></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!C6l2!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14654857-a1d2-47df-8116-8485753b05fe_2052x1368.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!C6l2!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14654857-a1d2-47df-8116-8485753b05fe_2052x1368.png 424w, https://substackcdn.com/image/fetch/$s_!C6l2!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14654857-a1d2-47df-8116-8485753b05fe_2052x1368.png 848w, https://substackcdn.com/image/fetch/$s_!C6l2!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14654857-a1d2-47df-8116-8485753b05fe_2052x1368.png 1272w, https://substackcdn.com/image/fetch/$s_!C6l2!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14654857-a1d2-47df-8116-8485753b05fe_2052x1368.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!C6l2!,w_2400,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14654857-a1d2-47df-8116-8485753b05fe_2052x1368.png" width="1200" height="800.2747252747253" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/14654857-a1d2-47df-8116-8485753b05fe_2052x1368.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:&quot;large&quot;,&quot;height&quot;:971,&quot;width&quot;:1456,&quot;resizeWidth&quot;:1200,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-large" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!C6l2!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14654857-a1d2-47df-8116-8485753b05fe_2052x1368.png 424w, https://substackcdn.com/image/fetch/$s_!C6l2!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14654857-a1d2-47df-8116-8485753b05fe_2052x1368.png 848w, https://substackcdn.com/image/fetch/$s_!C6l2!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14654857-a1d2-47df-8116-8485753b05fe_2052x1368.png 1272w, https://substackcdn.com/image/fetch/$s_!C6l2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14654857-a1d2-47df-8116-8485753b05fe_2052x1368.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Image 7: The dev split graph against gold. Missed entities (72) outnumber extra ones (52), so the extractor loses more on recall than on precision.</em></figcaption></figure></div><blockquote><p>If you want to learn more about how to design an ontology for your graph, I cover it in <a href="https://www.decodingai.com/p/ship-a-knowledge-graph-ontology-in-5-minutes">shipping a knowledge graph ontology in 5 minutes</a>.</p></blockquote><p>Now that we know what CodeClimb does, let&#8217;s circle back to what we came for: durable and secure long-running agents!</p><h2>Guardrails the agent can&#8217;t override</h2><p>After posting about CodeClimb on my socials, I was hit by this recurring idea: <em>&#8220;I want the spend limit enforced outside the agent, not just included in its instructions.&#8221;</em></p><p>Relying on the agent to decide whether to stop or continue means relying on the non-determinism inside the agent to follow its own guardrails: the thresholds, the number of rounds, the plateau, the costs.</p><p>So we moved all the guardrails within a TypeScript orchestrator, as shown in Image 8. A programmatic layer sits between the sandboxes and checks state between rounds with plain if-else statements. It ends a night on 5 conditions: metric thresholds reached (is the F1 score bigger than 0.8?), the iteration cap (26 rounds), the deadline (24h), the night budget ($120), or a plateau (9 rounds in a row with 0 improvements). For guardrails, deterministic code wins all the time.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!TGWm!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fedfc9ca1-5d6e-48ce-9eb4-68725a1ccd87_1200x821.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!TGWm!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fedfc9ca1-5d6e-48ce-9eb4-68725a1ccd87_1200x821.png 424w, https://substackcdn.com/image/fetch/$s_!TGWm!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fedfc9ca1-5d6e-48ce-9eb4-68725a1ccd87_1200x821.png 848w, https://substackcdn.com/image/fetch/$s_!TGWm!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fedfc9ca1-5d6e-48ce-9eb4-68725a1ccd87_1200x821.png 1272w, https://substackcdn.com/image/fetch/$s_!TGWm!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fedfc9ca1-5d6e-48ce-9eb4-68725a1ccd87_1200x821.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!TGWm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fedfc9ca1-5d6e-48ce-9eb4-68725a1ccd87_1200x821.png" width="1200" height="821" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/edfc9ca1-5d6e-48ce-9eb4-68725a1ccd87_1200x821.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:821,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;The CodeClimb system with guardrails: an orchestration layer that checks costs and every stop condition&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="The CodeClimb system with guardrails: an orchestration layer that checks costs and every stop condition" title="The CodeClimb system with guardrails: an orchestration layer that checks costs and every stop condition" srcset="https://substackcdn.com/image/fetch/$s_!TGWm!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fedfc9ca1-5d6e-48ce-9eb4-68725a1ccd87_1200x821.png 424w, https://substackcdn.com/image/fetch/$s_!TGWm!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fedfc9ca1-5d6e-48ce-9eb4-68725a1ccd87_1200x821.png 848w, https://substackcdn.com/image/fetch/$s_!TGWm!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fedfc9ca1-5d6e-48ce-9eb4-68725a1ccd87_1200x821.png 1272w, https://substackcdn.com/image/fetch/$s_!TGWm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fedfc9ca1-5d6e-48ce-9eb4-68725a1ccd87_1200x821.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Image 8: The system with guardrails. Every stop rule lives in the orchestrator, so the agent can&#8217;t talk itself past them.</em></figcaption></figure></div><p>As the node and relationship F1 scores never hit the thresholds, the iteration cap, cost cap and plateau are what stopped the night runs in practice.</p><p><strong>How did we track costs?</strong> The Pi coding agent reports the cost of every message it sends, so we sum it as it goes. The trickier part was the code the agent writes, which calls models on OpenRouter whenever it runs. For that, we route every one of its calls through a metering proxy that keeps track of the cost per experiment and per run.</p><p>Spend and time can&#8217;t wait for the round to end, so a monitor runs alongside the experiment and checks both. In the GraphRAG config, an experiment is capped at $2.50 and 30 minutes, and the night at $120. The cap is checked before every model call, so the call that crosses it still runs, and then the coding agent loop is aborted.</p><p>For cost alone, we could have used the OpenRouter API or an observability tool like Opik or LangSmith, but the proxy comes with other goodies. Let&#8217;s see what these are.</p><h2>A proxy for credentials and allowed models</h2><p>Without a proxy, you face 2 problems. First, dumping credentials into the sandbox lets the model use them as is. They&#8217;re easy to load into memory and then into the chat, which exposes them all. This can work if you keep rotating them, which I personally don&#8217;t like doing as a one-person engineering team.</p><p>Second, a GraphRAG program needs several models (extraction, merging, embedding, reranking). Remember that agents are goal-achieving machines. So the moment they hit a bump with the models listed in the config, they can always decide to use more powerful (and costly!) ones just for <em>&#8220;the greater good of achieving their goal&#8221;</em>.</p><p>Both problems are fixed by the same metering proxy that already tracks cost: it holds the real credentials, and it acts as a firewall that decides which models a request may reach. As illustrated in Image 9, the program sends its requests to the proxy, which implements the OpenAI protocol and routes them to OpenRouter. From inside the sandbox, it looks like an OpenAI endpoint with provided credentials.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!D7e0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b004647-0961-45d2-8328-224b853075e7_1200x956.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!D7e0!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b004647-0961-45d2-8328-224b853075e7_1200x956.png 424w, https://substackcdn.com/image/fetch/$s_!D7e0!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b004647-0961-45d2-8328-224b853075e7_1200x956.png 848w, https://substackcdn.com/image/fetch/$s_!D7e0!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b004647-0961-45d2-8328-224b853075e7_1200x956.png 1272w, https://substackcdn.com/image/fetch/$s_!D7e0!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b004647-0961-45d2-8328-224b853075e7_1200x956.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!D7e0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b004647-0961-45d2-8328-224b853075e7_1200x956.png" width="1200" height="956" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1b004647-0961-45d2-8328-224b853075e7_1200x956.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:956,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;The CodeClimb system with a proxy between the program and the model providers&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="The CodeClimb system with a proxy between the program and the model providers" title="The CodeClimb system with a proxy between the program and the model providers" srcset="https://substackcdn.com/image/fetch/$s_!D7e0!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b004647-0961-45d2-8328-224b853075e7_1200x956.png 424w, https://substackcdn.com/image/fetch/$s_!D7e0!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b004647-0961-45d2-8328-224b853075e7_1200x956.png 848w, https://substackcdn.com/image/fetch/$s_!D7e0!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b004647-0961-45d2-8328-224b853075e7_1200x956.png 1272w, https://substackcdn.com/image/fetch/$s_!D7e0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b004647-0961-45d2-8328-224b853075e7_1200x956.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Image 9: The system with a metering proxy. Credentials, the model allow list and the cost meter live where the agent can&#8217;t touch them.</em></figcaption></figure></div><p>On the sandbox side, the OpenAI proxy endpoint is reached with a one-off token, which is extremely easy to rotate because CodeClimb manages it. The token is accepted only by the proxy. It&#8217;s valid for 1 coding session or 1 evaluation, carries a dollar cap and is revoked when the run ends. The real credentials are added inside the proxy and accessed only programmatically.</p><p>The proxy accepts 4 models: DeepSeek v4.1 Flash for extraction, Typesafe Jev 1.14 as the decision model, Qwen3 Embedding 4B and Qwen3 Reranker 8B. A request for any other model is refused.</p><p>The Anthropic key gets the same protection a different way: Pi runs on the host, so its credentials never enter the sandbox. Only its shell and file tools do. We covered how coding agents use sandboxes in depth <a href="https://www.decodingai.com/p/run-coding-agents-safely">in this article</a>.</p><p>The cons are that you need to implement an interface for every service you want to use (which isn&#8217;t that hard to do with coding agents) and every call has an extra network hop. If you sidecar the proxy near your sandbox, the extra hop is easy to manage.</p><p>This is how we made CodeClimb secure. Now let&#8217;s move on to my favorite part and see how we made it durable.</p><h2>Checkpoints that survive a crash</h2><p>Three types of events can interrupt a night run. First, infrastructure fails, such as a dropped internet connection. Second, another service fails, such as a model provider going down or running out of credits. Third, a human stops the run, looks at the results and wants to continue from there.</p><p>All three are fixed by a durability tool, such as <a href="https://inngest.link/dai-nl">Inngest</a>, as shown in Image 10. The night run becomes an Inngest function that invokes 1 child function per experiment and per evaluation. Each piece of work (coding, evaluation, review) is a saved step.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!vbgh!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcea7c85e-9e73-4051-8cb5-fbb23b06e0e3_1200x989.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!vbgh!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcea7c85e-9e73-4051-8cb5-fbb23b06e0e3_1200x989.png 424w, https://substackcdn.com/image/fetch/$s_!vbgh!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcea7c85e-9e73-4051-8cb5-fbb23b06e0e3_1200x989.png 848w, https://substackcdn.com/image/fetch/$s_!vbgh!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcea7c85e-9e73-4051-8cb5-fbb23b06e0e3_1200x989.png 1272w, https://substackcdn.com/image/fetch/$s_!vbgh!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcea7c85e-9e73-4051-8cb5-fbb23b06e0e3_1200x989.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!vbgh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcea7c85e-9e73-4051-8cb5-fbb23b06e0e3_1200x989.png" width="1200" height="989" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/cea7c85e-9e73-4051-8cb5-fbb23b06e0e3_1200x989.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:989,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;The CodeClimb system made durable: Inngest checkpoints the loop and triggers its functions&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="The CodeClimb system made durable: Inngest checkpoints the loop and triggers its functions" title="The CodeClimb system made durable: Inngest checkpoints the loop and triggers its functions" srcset="https://substackcdn.com/image/fetch/$s_!vbgh!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcea7c85e-9e73-4051-8cb5-fbb23b06e0e3_1200x989.png 424w, https://substackcdn.com/image/fetch/$s_!vbgh!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcea7c85e-9e73-4051-8cb5-fbb23b06e0e3_1200x989.png 848w, https://substackcdn.com/image/fetch/$s_!vbgh!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcea7c85e-9e73-4051-8cb5-fbb23b06e0e3_1200x989.png 1272w, https://substackcdn.com/image/fetch/$s_!vbgh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcea7c85e-9e73-4051-8cb5-fbb23b06e0e3_1200x989.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Image 10: The system made durable. Inngest holds the run, so a dead worker loses only the running step that hasn&#8217;t finished.</em></figcaption></figure></div><p>Once a step finishes, Inngest saves its result. After a crash, the function replays, skips what is already done and continues where it left off.</p><p>In Image 11, <code>run-night</code> is the parent. <code>run-experiment</code> and <code>run-evaluator</code> have no trigger because <code>run-night</code> invokes them, and the other 4 react to lifecycle events such as <code>night.start</code> or <code>night.finished</code>. Each step is a non-deterministic or state-changing step from your program. You need to design them this way because, on replay, you want to ensure that a non-deterministic experiment or evaluation step always outputs the same values, while a ste</p><p>p that records your history log doesn&#8217;t repeat the same message.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!jGG-!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb70fbb8-bb25-4ae4-912f-038899535e96_1592x1066.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!jGG-!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb70fbb8-bb25-4ae4-912f-038899535e96_1592x1066.png 424w, https://substackcdn.com/image/fetch/$s_!jGG-!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb70fbb8-bb25-4ae4-912f-038899535e96_1592x1066.png 848w, https://substackcdn.com/image/fetch/$s_!jGG-!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb70fbb8-bb25-4ae4-912f-038899535e96_1592x1066.png 1272w, https://substackcdn.com/image/fetch/$s_!jGG-!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb70fbb8-bb25-4ae4-912f-038899535e96_1592x1066.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!jGG-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb70fbb8-bb25-4ae4-912f-038899535e96_1592x1066.png" width="728" height="487.5" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/eb70fbb8-bb25-4ae4-912f-038899535e96_1592x1066.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:&quot;normal&quot;,&quot;height&quot;:975,&quot;width&quot;:1456,&quot;resizeWidth&quot;:728,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:&quot;center&quot;,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!jGG-!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb70fbb8-bb25-4ae4-912f-038899535e96_1592x1066.png 424w, https://substackcdn.com/image/fetch/$s_!jGG-!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb70fbb8-bb25-4ae4-912f-038899535e96_1592x1066.png 848w, https://substackcdn.com/image/fetch/$s_!jGG-!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb70fbb8-bb25-4ae4-912f-038899535e96_1592x1066.png 1272w, https://substackcdn.com/image/fetch/$s_!jGG-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb70fbb8-bb25-4ae4-912f-038899535e96_1592x1066.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Image 11: The 7 Inngest functions behind one night.</em></figcaption></figure></div><p>As shown in Image 12, under the hood, the Inngest server queues steps and stores each step&#8217;s output by its ID. The functions are triggered on our worker based on the event type via a WebSocket.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!hwCT!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbd9d55b-cc70-4c29-8f16-f57fd7dc6bb5_1200x726.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!hwCT!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbd9d55b-cc70-4c29-8f16-f57fd7dc6bb5_1200x726.png 424w, https://substackcdn.com/image/fetch/$s_!hwCT!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbd9d55b-cc70-4c29-8f16-f57fd7dc6bb5_1200x726.png 848w, https://substackcdn.com/image/fetch/$s_!hwCT!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbd9d55b-cc70-4c29-8f16-f57fd7dc6bb5_1200x726.png 1272w, https://substackcdn.com/image/fetch/$s_!hwCT!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbd9d55b-cc70-4c29-8f16-f57fd7dc6bb5_1200x726.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!hwCT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbd9d55b-cc70-4c29-8f16-f57fd7dc6bb5_1200x726.png" width="1200" height="726" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/bbd9d55b-cc70-4c29-8f16-f57fd7dc6bb5_1200x726.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:726,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;How CodeClimb runs on Inngest: events in, a queue and a state store on the server, and a worker that dials out&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="How CodeClimb runs on Inngest: events in, a queue and a state store on the server, and a worker that dials out" title="How CodeClimb runs on Inngest: events in, a queue and a state store on the server, and a worker that dials out" srcset="https://substackcdn.com/image/fetch/$s_!hwCT!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbd9d55b-cc70-4c29-8f16-f57fd7dc6bb5_1200x726.png 424w, https://substackcdn.com/image/fetch/$s_!hwCT!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbd9d55b-cc70-4c29-8f16-f57fd7dc6bb5_1200x726.png 848w, https://substackcdn.com/image/fetch/$s_!hwCT!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbd9d55b-cc70-4c29-8f16-f57fd7dc6bb5_1200x726.png 1272w, https://substackcdn.com/image/fetch/$s_!hwCT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbd9d55b-cc70-4c29-8f16-f57fd7dc6bb5_1200x726.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Image 12: How CodeClimb runs on Inngest.</em></figcaption></figure></div><p>In Image 13, you can see a ~9 min test run of our coding night pipeline (on our plan, Inngest stores data for only 7 days, so we lost our main runs), including how long each step takes and its inputs and outputs.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!0PmR!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f53d903-6907-4390-a2aa-55ba1dee9456_2762x1612.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!0PmR!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f53d903-6907-4390-a2aa-55ba1dee9456_2762x1612.png 424w, https://substackcdn.com/image/fetch/$s_!0PmR!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f53d903-6907-4390-a2aa-55ba1dee9456_2762x1612.png 848w, https://substackcdn.com/image/fetch/$s_!0PmR!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f53d903-6907-4390-a2aa-55ba1dee9456_2762x1612.png 1272w, https://substackcdn.com/image/fetch/$s_!0PmR!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f53d903-6907-4390-a2aa-55ba1dee9456_2762x1612.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!0PmR!,w_2400,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f53d903-6907-4390-a2aa-55ba1dee9456_2762x1612.png" width="1200" height="700.5494505494505" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7f53d903-6907-4390-a2aa-55ba1dee9456_2762x1612.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:&quot;large&quot;,&quot;height&quot;:850,&quot;width&quot;:1456,&quot;resizeWidth&quot;:1200,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-large" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!0PmR!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f53d903-6907-4390-a2aa-55ba1dee9456_2762x1612.png 424w, https://substackcdn.com/image/fetch/$s_!0PmR!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f53d903-6907-4390-a2aa-55ba1dee9456_2762x1612.png 848w, https://substackcdn.com/image/fetch/$s_!0PmR!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f53d903-6907-4390-a2aa-55ba1dee9456_2762x1612.png 1272w, https://substackcdn.com/image/fetch/$s_!0PmR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f53d903-6907-4390-a2aa-55ba1dee9456_2762x1612.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Image 13: A short test night in the Inngest dashboard. Coding (2m 35s) and review (1m 55s) dominate, so they are the steps worth checkpointing.</em></figcaption></figure></div><p>During a GraphRAG night run, I killed the worker in the middle of round 2. About 2 minutes later, the step was retried, the coding agent reopened its session, and the night finished. In another test, I cut my internet for ~30 seconds, long enough for the run to crash. As shown in Image 14, after the internet reconnected, Inngest retried the step, and everything continued.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!NxB2!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F465ee053-2ac2-4c8a-abbc-0324a842358f_1200x767.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!NxB2!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F465ee053-2ac2-4c8a-abbc-0324a842358f_1200x767.png 424w, https://substackcdn.com/image/fetch/$s_!NxB2!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F465ee053-2ac2-4c8a-abbc-0324a842358f_1200x767.png 848w, https://substackcdn.com/image/fetch/$s_!NxB2!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F465ee053-2ac2-4c8a-abbc-0324a842358f_1200x767.png 1272w, https://substackcdn.com/image/fetch/$s_!NxB2!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F465ee053-2ac2-4c8a-abbc-0324a842358f_1200x767.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!NxB2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F465ee053-2ac2-4c8a-abbc-0324a842358f_1200x767.png" width="1200" height="767" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/465ee053-2ac2-4c8a-abbc-0324a842358f_1200x767.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:767,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;How a crashed step is retried: finished steps stay memoized, the failed one retries up to three times&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="How a crashed step is retried: finished steps stay memoized, the failed one retries up to three times" title="How a crashed step is retried: finished steps stay memoized, the failed one retries up to three times" srcset="https://substackcdn.com/image/fetch/$s_!NxB2!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F465ee053-2ac2-4c8a-abbc-0324a842358f_1200x767.png 424w, https://substackcdn.com/image/fetch/$s_!NxB2!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F465ee053-2ac2-4c8a-abbc-0324a842358f_1200x767.png 848w, https://substackcdn.com/image/fetch/$s_!NxB2!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F465ee053-2ac2-4c8a-abbc-0324a842358f_1200x767.png 1272w, https://substackcdn.com/image/fetch/$s_!NxB2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F465ee053-2ac2-4c8a-abbc-0324a842358f_1200x767.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Image 14: How Inngest retries a crashed step. Finished rounds stay memoized, and after 3 failed attempts, the night stops and cleans up.</em></figcaption></figure></div><p>The biggest failure point is our dependency on external LLM providers for our coding agent (GitHub Copilot or Anthropic). If we retry more than 3 times, the run is flagged as failed and can be replayed later. To smooth this out, we run a quick smoke test before each round to test the connection with our providers.</p><p>On the other hand, we have the scenario where we stop on purpose and have to safely cancel all resources, such as running sandboxes, to ensure we have zero zombie coding agents still consuming tokens or compute (which gets worse when we pay for remote sandboxes).</p><p>Canceling an Inngest run doesn&#8217;t interrupt a step that&#8217;s already running, so we had to handle in our code aborting the Pi coding agent loop and destroying the live sandboxes.</p><p>On top of checkpointing a night&#8217;s running state, we version the code. Every experiment is one commit in a local bare git repo. A better experiment becomes the new kept commit, and the next round builds on it. For failed experiments, we just skip the commits, which means that the next round starts again from the commit of the best experiment.</p><p>With this strategy, we can also compute diffs between the best solution and the failed ones as additional feedback to pass between iterations in the decision history.</p><p>With 1 commit per experiment, I can check out any of them to see what happened, export the best one, or start a new night using the commit as a seed instead of starting from scratch. This is extremely useful if we hit a max rounds cap or a plateau and we decide we want to continue.</p><p>The repository is purely local, but we can easily hook it up to a remote origin on GitHub or GitLab. Or take it even further and start each night run from an existing repository where the outcome becomes a PR with a metrics report, instead of a 10,000-line PR to review.</p><div class="callout-block" data-callout="true"><p>&#128187; To <em>test <a href="https://github.com/decodingai-magazine/codeclimb/tree/main">CodeClimb</a> on Inngest Cloud for free</em>, use <a href="http://inngest.link/dai">this link</a> for a 3-month free trial (available until Nov 2027) of their Pro subscription, which includes 1M executions, 5M events, 20 workers, 100 remote sandboxes, and more.</p></div><p>The last piece is a human in the loop to recover or steer the run.</p><h2>A human in the loop</h2><p>Remember the run that died mid-turn? At first, because I had trust issues with the Pi coding agent, I kept topping up OpenRouter in $10 batches, and the night runs kept running out of credits mid-turn.</p><p>The solution was to catch custom errors, such as <code>OutofBudget</code>, and leverage Inngest&#8217;s <code>step.waitForEvent()</code> to pause the night for up to 3 days until a <code>night.resume</code> event arrives. As illustrated in Image 15, the pause fires wherever the credits run out: in an experiment, an evaluation or a review. In our use case, the event is sent after adding credits to OpenRouter or Anthropic, and the night continues from the step that paused.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!O2pB!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c36b0f2-3a50-4576-a28b-ab7acc8994d2_1200x986.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!O2pB!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c36b0f2-3a50-4576-a28b-ab7acc8994d2_1200x986.png 424w, https://substackcdn.com/image/fetch/$s_!O2pB!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c36b0f2-3a50-4576-a28b-ab7acc8994d2_1200x986.png 848w, https://substackcdn.com/image/fetch/$s_!O2pB!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c36b0f2-3a50-4576-a28b-ab7acc8994d2_1200x986.png 1272w, https://substackcdn.com/image/fetch/$s_!O2pB!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c36b0f2-3a50-4576-a28b-ab7acc8994d2_1200x986.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!O2pB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c36b0f2-3a50-4576-a28b-ab7acc8994d2_1200x986.png" width="1200" height="986" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8c36b0f2-3a50-4576-a28b-ab7acc8994d2_1200x986.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:986,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;How to design coding long-running agents you can trust&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="How to design coding long-running agents you can trust" title="How to design coding long-running agents you can trust" srcset="https://substackcdn.com/image/fetch/$s_!O2pB!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c36b0f2-3a50-4576-a28b-ab7acc8994d2_1200x986.png 424w, https://substackcdn.com/image/fetch/$s_!O2pB!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c36b0f2-3a50-4576-a28b-ab7acc8994d2_1200x986.png 848w, https://substackcdn.com/image/fetch/$s_!O2pB!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c36b0f2-3a50-4576-a28b-ab7acc8994d2_1200x986.png 1272w, https://substackcdn.com/image/fetch/$s_!O2pB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c36b0f2-3a50-4576-a28b-ab7acc8994d2_1200x986.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Image 15: The system with a human in the loop. When credits run out, the night pauses instead of failing, and feedback steers the next experiment.</em></figcaption></figure></div><p>It&#8217;s incredibly important to understand that while it waits, the run costs nothing. <a href="https://inngest.link/dai-nl">Inngest</a> suspends the run, so it doesn&#8217;t block any worker or sandbox. Any step can wait for a human this way. Otherwise, a standard input command would hold resources that other workflows actually need.</p><p>The second human-in-the-loop decision is steering. After a night ends, I analyze it with Opus or Fable, looking at all the logs generated by Pi and the decision history. If I see more potential in the night run, I either continue it for more rounds with a written direction, or start a new night from the best kept commit plus my input. This strategy can be extended further with a steering queue that adds feedback in real time by sending events with Inngest via <code>step.sendEvent("feedback")</code>.</p><h2>From my machine to the cloud</h2><p>So far, everything runs on my machine, using Inngest&#8217;s local dev server and Docker for the sandboxes. This limits the night run to one user, one night run at a time, stuck on my machine. The beauty of this setup is that it can run remotely at scale.</p><p>First, as shown in Image 16, we have to deploy the Inngest dev server to their Inngest Cloud managed service. To do so, you only need to <a href="https://inngest.link/dai-nl">subscribe to Inngest</a> (they have a generous freemium plan). Or, as Inngest is open-source, you can host it yourself as well.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!CUob!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5470aea-9ade-43c6-9dce-1dfb0384b0a1_1200x667.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!CUob!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5470aea-9ade-43c6-9dce-1dfb0384b0a1_1200x667.png 424w, https://substackcdn.com/image/fetch/$s_!CUob!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5470aea-9ade-43c6-9dce-1dfb0384b0a1_1200x667.png 848w, https://substackcdn.com/image/fetch/$s_!CUob!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5470aea-9ade-43c6-9dce-1dfb0384b0a1_1200x667.png 1272w, https://substackcdn.com/image/fetch/$s_!CUob!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5470aea-9ade-43c6-9dce-1dfb0384b0a1_1200x667.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!CUob!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5470aea-9ade-43c6-9dce-1dfb0384b0a1_1200x667.png" width="1200" height="667" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e5470aea-9ade-43c6-9dce-1dfb0384b0a1_1200x667.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:667,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;How CodeClimb runs fully hosted: an Inngest worker and the dashboard on Vercel, with Inngest Cloud and the LLM providers beside them&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="How CodeClimb runs fully hosted: an Inngest worker and the dashboard on Vercel, with Inngest Cloud and the LLM providers beside them" title="How CodeClimb runs fully hosted: an Inngest worker and the dashboard on Vercel, with Inngest Cloud and the LLM providers beside them" srcset="https://substackcdn.com/image/fetch/$s_!CUob!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5470aea-9ade-43c6-9dce-1dfb0384b0a1_1200x667.png 424w, https://substackcdn.com/image/fetch/$s_!CUob!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5470aea-9ade-43c6-9dce-1dfb0384b0a1_1200x667.png 848w, https://substackcdn.com/image/fetch/$s_!CUob!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5470aea-9ade-43c6-9dce-1dfb0384b0a1_1200x667.png 1272w, https://substackcdn.com/image/fetch/$s_!CUob!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5470aea-9ade-43c6-9dce-1dfb0384b0a1_1200x667.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Image 16: How I would host CodeClimb. The tools run in Inngest Sandboxes, so the Vercel worker only orchestrates and stays light.</em></figcaption></figure></div><p>Next, we swap our Docker Sandboxes with Inngest Sandboxes. To do so, we just switch the backend that executes the tools from Docker to Inngest. Each Pi coding and evaluation session gets its own microVM. A sandbox is limited to 1 hour of active runtime, so timeouts would be capped at 50 minutes.</p><p>Ultimately, the worker, the metering proxy and the Next.js dashboard are deployed on Vercel, which integrates with Inngest in a few clicks.</p><h2>Honest thoughts</h2><p>The durable, secure, long-running agent part works really well. The night run is resilient: it bounces back from every stop and crash scenario I tested. On top of that, I had zero issues with the coding agent going rogue and starting to use models from OpenRouter that I didn&#8217;t want it to use. Even though <a href="https://inngest.link/dai-nl">Inngest</a> is the sponsor of this article, our honest verdict is that it made it super easy to make the code durable.</p><p>Now what about the idea behind CodeClimb? The idea worked decently well. The coding agent made a lot of progress with almost 0 human intervention, as the loop is 100% encoded into our workflow. It got close to the node extraction threshold, while edge extraction stayed far off.</p><p>We modeled the problem around some internal tools that we need at Decoding AI. Most likely we won&#8217;t use the code as is, because from a scaling point of view, it isn&#8217;t that great (e.g., the ingestion and retrieval code isn&#8217;t modeled as pipelines). But we&#8217;ll take the algorithm and parameters it found to work well on our dataset and port them into our infrastructure. Similar to the dynamics between research and production.</p><p>Without CodeClimb, manually controlling this experimentation and evaluation loop with a coding agent can be super time-consuming and boring. Plus, it&#8217;s easy to leak data. Also, in terms of costs, spending ~$75 per night is a decent amount, especially if you leverage the credits from your Anthropic subscription or power Pi with other compatible subscriptions such as OpenCode Go, Grok or OpenAI.</p><p>The biggest bottleneck we have is the quality of the dataset. Deciding what nodes and relationships to extract and which to drop needs more work. Once we crack that, it&#8217;s autopilot time.</p><blockquote><p>&#128187; You can <a href="https://github.com/decodingai-magazine/codeclimb/tree/main">try CodeClimb on our GitHub</a>. It&#8217;s 100% open-source. And don&#8217;t forget to <em>register for Inngest with <a href="http://inngest.link/dai">this link</a></em> for a 3-month Pro free trial (available until Nov 2027) so you can run CodeClimb for free in remote Inngest sandboxes. </p></blockquote><p>In the next article from the series, we will compare building CodeClimb in Inngest vs. the LangChain ecosystem. I won&#8217;t give more spoilers!</p><h2>Further reading</h2><ol><li><p><a href="https://github.com/karpathy/autoresearch">autoresearch</a></p></li><li><p><a href="https://www.anthropic.com/research/effective-harnesses-for-long-running-agents">Effective Harnesses for Long-Running Agents</a></p></li><li><p><a href="https://lilianweng.github.io/posts/2026-07-04-harness/">Harness Engineering for Self-Improvement</a></p></li></ol><div><hr></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.decodingai.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">Learn AI engineering end-to-end, from idea to production, from the author of the best-selling LLM Engineer&#8217;s Handbook.</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><div><hr></div><div class="callout-block" data-callout="true"><h4>Whenever you&#8217;re ready, here is how I can help you</h4><p><em>Go from agent user to agent builder.</em> Master the foundations of AI agents and turn fragile demo code into reliable, production-ready systems with my course, <strong><a href="https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering">Agent Engineering: Building Multi-Agent Systems</a></strong> (made with Towards AI).</p><p>35 lessons. Pure foundations from scratch. 4 mini-projects. 2 production systems. A certificate and direct access to me &amp; industry experts in our Discord.</p><p>Built for software and data professionals transitioning into AI engineering. <em>Rated 5/5 with 300+ students. The first 7 lessons are free:</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering&quot;,&quot;text&quot;:&quot;Start here&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering"><span>Start here</span></a></p><p><em>Not ready to commit?</em> Start with our <strong><a href="https://email-course.towardsai.net/?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering">free Agent AI Engineering Guide</a></strong>, a 6-day email course on the mistakes that silently break AI agents in production.</p></div><div><hr></div><p><em>Thanks again to <strong><a href="https://inngest.link/dai-nl">Inngest</a></strong> for sponsoring the series and keeping it free!</em></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!44TA!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F492d94e3-5efc-4925-aca7-68c80d329d3c_1200x400.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!44TA!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F492d94e3-5efc-4925-aca7-68c80d329d3c_1200x400.png 424w, https://substackcdn.com/image/fetch/$s_!44TA!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F492d94e3-5efc-4925-aca7-68c80d329d3c_1200x400.png 848w, https://substackcdn.com/image/fetch/$s_!44TA!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F492d94e3-5efc-4925-aca7-68c80d329d3c_1200x400.png 1272w, https://substackcdn.com/image/fetch/$s_!44TA!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F492d94e3-5efc-4925-aca7-68c80d329d3c_1200x400.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!44TA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F492d94e3-5efc-4925-aca7-68c80d329d3c_1200x400.png" width="1200" height="400" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/492d94e3-5efc-4925-aca7-68c80d329d3c_1200x400.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:400,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:121893,&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://www.decodingai.com/i/224907258?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F492d94e3-5efc-4925-aca7-68c80d329d3c_1200x400.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_!44TA!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F492d94e3-5efc-4925-aca7-68c80d329d3c_1200x400.png 424w, https://substackcdn.com/image/fetch/$s_!44TA!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F492d94e3-5efc-4925-aca7-68c80d329d3c_1200x400.png 848w, https://substackcdn.com/image/fetch/$s_!44TA!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F492d94e3-5efc-4925-aca7-68c80d329d3c_1200x400.png 1272w, https://substackcdn.com/image/fetch/$s_!44TA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F492d94e3-5efc-4925-aca7-68c80d329d3c_1200x400.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><a href="https://inngest.link/dai-nl">Try Inngest for free here</a> (free plan with 50k executions/month, or self-host it, since it&#8217;s open-source)</figcaption></figure></div><p><strong>Build AI agents and workflows that survive crashes, retries, and long waits:</strong></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://inngest.link/dai-nl&quot;,&quot;text&quot;:&quot;Start building for free&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://inngest.link/dai-nl"><span>Start building for free</span></a></p><div><hr></div><h2>Images &amp; videos</h2><p>If not otherwise stated, all images and videos are created by the author.</p>]]></content:encoded></item><item><title><![CDATA[Don't Let Claude Code Design Your LLM Judges]]></title><description><![CDATA[What 28,200 LLM judgments taught me about noise, rubrics, and human calibration]]></description><link>https://www.decodingai.com/p/write-your-own-llm-judges</link><guid isPermaLink="false">https://www.decodingai.com/p/write-your-own-llm-judges</guid><dc:creator><![CDATA[Louis-François Bouchard]]></dc:creator><pubDate>Tue, 10 Nov 2026 12:21:59 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!7DUm!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda7ff322-6550-46e9-b563-0c4647abb716_1376x768.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><strong>Paul:</strong> Today, the spotlight is on Louis-Fran&#231;ois Bouchard.</p><p>He&#8217;s the CTO and co-founder of Towards AI and co-author of <em>Building LLMs for Production</em>, with a second book on the way (more on that in an upcoming guest post). He builds AI systems, trains teams on AI adoption&nbsp;and shares practical engineering lessons with 70K+ subscribers on his <a href="https://www.youtube.com/@whatsai">YouTube channel</a>, newsletter and blog.</p><p>Enough chitchat. Let&#8217;s get into it &#128064; &#8595;</p><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_!7DUm!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda7ff322-6550-46e9-b563-0c4647abb716_1376x768.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!7DUm!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda7ff322-6550-46e9-b563-0c4647abb716_1376x768.png 424w, https://substackcdn.com/image/fetch/$s_!7DUm!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda7ff322-6550-46e9-b563-0c4647abb716_1376x768.png 848w, https://substackcdn.com/image/fetch/$s_!7DUm!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda7ff322-6550-46e9-b563-0c4647abb716_1376x768.png 1272w, https://substackcdn.com/image/fetch/$s_!7DUm!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda7ff322-6550-46e9-b563-0c4647abb716_1376x768.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!7DUm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda7ff322-6550-46e9-b563-0c4647abb716_1376x768.png" width="1376" height="768" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/da7ff322-6550-46e9-b563-0c4647abb716_1376x768.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:768,&quot;width&quot;:1376,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1377870,&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://www.decodingai.com/i/223628804?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda7ff322-6550-46e9-b563-0c4647abb716_1376x768.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_!7DUm!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda7ff322-6550-46e9-b563-0c4647abb716_1376x768.png 424w, https://substackcdn.com/image/fetch/$s_!7DUm!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda7ff322-6550-46e9-b563-0c4647abb716_1376x768.png 848w, https://substackcdn.com/image/fetch/$s_!7DUm!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda7ff322-6550-46e9-b563-0c4647abb716_1376x768.png 1272w, https://substackcdn.com/image/fetch/$s_!7DUm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda7ff322-6550-46e9-b563-0c4647abb716_1376x768.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>Can any model write like me? Like, actually write a script I could read out loud without cringing?</p><p>That&#8217;s what <a href="https://benchmark.towardsai.com/">ToneBench</a>, the writing benchmark I released at <a href="https://youtu.be/_dTF3NpPzGo">AI Engineer in New York on October 13</a>, measures. After vibe coding on this project for more than 5 months, spending thousands on API tokens, and making tons of mistakes along the way, I want to share some learnings so you can do better when you build your next evals.</p><p>Most scores on ToneBench come from LLM judges. Claude Code and Codex wrote the code. Everything. Whether the scores mean anything came down to a handful of decisions I made that Claude Code never suggested. The results would&#8217;ve been TERRIBLE and untrustworthy if I had fully trusted Claude to also work on the judges&#8217; prompts and criteria. So, let&#8217;s see what these decisions were and how you can use them yourself.</p><p>Quickly on ToneBench: I made it because at Towards AI we write for a living, and I was tired of guessing which model to use.</p><p>It&#8217;s simple. Every model gets the same 13-20,000-token prompt depending on the task. It has my voice guide, a storytelling guide, the hard rules like target length, and the brief and research for one of ten real scripts from my channel. No tools, no web search. It writes five drafts per script, and four judges plus a few code checks score each one on nine weighted metrics.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!OMGL!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd0a2476f-ab3f-4cc4-b25c-c5ef27de4f3e_2000x1047.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!OMGL!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd0a2476f-ab3f-4cc4-b25c-c5ef27de4f3e_2000x1047.png 424w, https://substackcdn.com/image/fetch/$s_!OMGL!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd0a2476f-ab3f-4cc4-b25c-c5ef27de4f3e_2000x1047.png 848w, https://substackcdn.com/image/fetch/$s_!OMGL!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd0a2476f-ab3f-4cc4-b25c-c5ef27de4f3e_2000x1047.png 1272w, https://substackcdn.com/image/fetch/$s_!OMGL!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd0a2476f-ab3f-4cc4-b25c-c5ef27de4f3e_2000x1047.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!OMGL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd0a2476f-ab3f-4cc4-b25c-c5ef27de4f3e_2000x1047.png" width="1456" height="762" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d0a2476f-ab3f-4cc4-b25c-c5ef27de4f3e_2000x1047.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:762,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;How ToneBench works&quot;,&quot;title&quot;:&quot;How ToneBench works&quot;,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="How ToneBench works" title="How ToneBench works" srcset="https://substackcdn.com/image/fetch/$s_!OMGL!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd0a2476f-ab3f-4cc4-b25c-c5ef27de4f3e_2000x1047.png 424w, https://substackcdn.com/image/fetch/$s_!OMGL!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd0a2476f-ab3f-4cc4-b25c-c5ef27de4f3e_2000x1047.png 848w, https://substackcdn.com/image/fetch/$s_!OMGL!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd0a2476f-ab3f-4cc4-b25c-c5ef27de4f3e_2000x1047.png 1272w, https://substackcdn.com/image/fetch/$s_!OMGL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd0a2476f-ab3f-4cc4-b25c-c5ef27de4f3e_2000x1047.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Figure 1. How ToneBench works. Each configuration (one model at one effort level) writes 50 drafts, which get 200 judgments.</em></figcaption></figure></div><p>With 141 model configurations we measured (many models + different thinking levels), that&#8217;s 7,050 drafts and 28,200 judgments. I can&#8217;t read them all, so apart from what code scores, every number on the board is the judges&#8217; opinion, so they need to be trustworthy and reliable.</p><p>Paul&#8217;s rule on this newsletter is to use an LLM judge &#8220;only for what code cannot score.&#8221; We do the same, but whether a script sounds like me is about as far from code as it gets. So here&#8217;s what I&#8217;d check before trusting an LLM judge on a subjective task like this.</p><h2>1. Read every prompt Claude Code writes for your judge</h2><p>I built ToneBench with Claude Code and Codex, on four 20x subscriptions running for five months, integrating most of the features on a fullvibe coding format and mostly focusing my time on the rubrics, metrics and calibration side of the benchmark; where I believe my &#8220;human time&#8221; was most worthwhile. Coding agents are fantastic at building what you decide and bad at deciding what to build, which means they can&#8217;t make a score trustworthy in this case.</p><p><strong>The rubric needs your hands.</strong> To be honest, some of what Claude Code drafted for the judges was super weird. Sometimes you don&#8217;t even understand what it&#8217;s saying, which is bad when that text turns your taste into a number that should mean something. And rules that read well, even ones taken from my own voice guide, can still measure the wrong thing. On our early-October baseline, 119 of 141 models scored above my own scripts on anti-slop, because the rubric punished habits I actually have, like reading an exact figure out loud and repeating it for emphasis. On substance, 102 generations beat me, because any fact outside the research packet counted as invented, even though it was true client insights. Your best outputs should sit at the top of your scale. If they don&#8217;t, read the rubric again, and spend time improving it. On October 7, after weeks of iterations on the rubric, I scrapped it all and rewrote most metric sections by hand.</p><p><strong>It never suggested the checks I trust most.</strong> In four months, Claude never proposed checking whether the same draft gets the same score twice, or comparing the judges with human ratings. I had to think of both and decide to implement both: what if the same draft doesn&#8217;t always lead to the same rating? I then, of course, used Claude to implement them and iterate on the &#8220;how&#8221;, but you, as the owner of the product, need to know the features you need.</p><p><strong>It over-invests where it doesn&#8217;t matter.</strong> I asked for a simple page where people compare two text snippets, and the agents proposed Tailscale, a new paid hosting plan and a security debate about pushing the snippets. At one point I typed &#8220;ffs these are just text snippets to compare in my own f***ing team, it&#8217;s fine to push it, go.&#8221; Then I lost three weeks on that page before realizing it couldn&#8217;t tell me what my judges got wrong. More on that later.</p><p>Let the agents write the code. Read every judge prompt and make every implementation and measurement decision yourself.</p><h2>2. Measure the noise before you rank anything</h2><p>Your typical eval has two sources of noise. The model you are testing, and the judge testing it. It&#8217;s easy to forget the second needs measurement too.</p><p>For the model, if you only do the task once, it may fool you. I had this intuition, so I regenerated the same task 10 times. From this, I saw wide variance in results across most models. The &#8220;worse&#8221; the model, the wider the variance in generation quality.</p><p>On our current board, we always generate 5 drafts for every single model config to ensure we measure that variance. For example, Grok 4.7 ranks 5th on its best drafts, 29th on average and 67th on its worst. Rating just one draft would mean it lands anywhere between fifth and 67th. But if you average the results across enough generations, you end up with a 29th ranking, which better represents the model&#8217;s average quality.</p><p>This variance also indicates the model&#8217;s quality. Opus 5.5 on xhigh, the best model of the benchmark right now, moves about &#177;0.9 points between drafts. It always lands first on any given generation, with very little variance.</p><p>So, currently, every model writes five drafts per script. This is enough to calculate the per-model variance on our end. But we started with fifty, looked at the spread, and then dropped until we had statistical evidence, and five was enough to see it at an API price we can afford. This is something you&#8217;ll need to confirm for your own eval set and tasks, but you need to account for it.</p><p>The same uncertainty and variance apply to your judges, since they are also non-deterministic.</p><p>I recently wanted to add Gemini as a fifth judge. But before doing so, I needed to know whether it would help. For this, I have a &#8220;calibration&#8221; set: human ratings my team and I made on how we&#8217;d rate generations. We use it to measure accordance, or &#8220;calibration,&#8221; with our LLM judges, and use it to measure the quality of the rubric we feed them.</p><p>So, every time I want to add a new judge or replace one, like Gemini 4, I&#8217;ll give it the same prompt as our current judges and measure its rating calibration against our set and against the other judges.</p><p>In this case, Gemini didn&#8217;t align with our calibration and was rating models almost randomly compared to our current 4 judges (GLM 5.3 Flash, GPT 6.1 Sol, Opus 5.5, Jev). If I had added Gemini, it would&#8217;ve shuffled the leaderboard every time we recomputed the scores, making the benchmark totally unreliable. Without the human-made calibration, I would&#8217;ve never known this and might&#8217;ve added it as a new judge, reducing the benchmark&#8217;s reliability.</p><p>Those are two examples of noise you need to account for, but there are way more case-specific ones for every single task and system in place. Every component that might add a decision layer, especially probabilistic ones, needs to be measured and compared before being changed.</p><h2>3. Pass/fail is simpler. If you need a scale, pay for it in examples</h2><p>Paul recommends pass/fail, because LLMs are bad at 1-to-5 scales. I agree, and it&#8217;s usually what we recommend to our clients, too. In June I even told someone on X that a single 1-5 from a judge &#8220;mostly measures the judge&#8217;s mood.&#8221; Well, guess what I ended up building.</p><p>Putting &#8220;does this sound like Louis?&#8221; into binary statements is really hard. Like, really, really hard. We tried, and the results weren&#8217;t ideal. They were totally random&#8230; We also tried plain categories and straight percentages. What held up best when we judged the same drafts again and again was two steps: the judge quotes evidence, picks one of six levels, each with a description and examples, and only then picks a number inside that level.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!jxBp!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7344cef1-8b33-4210-b08a-fa1a4125c446_1328x716.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!jxBp!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7344cef1-8b33-4210-b08a-fa1a4125c446_1328x716.png 424w, https://substackcdn.com/image/fetch/$s_!jxBp!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7344cef1-8b33-4210-b08a-fa1a4125c446_1328x716.png 848w, https://substackcdn.com/image/fetch/$s_!jxBp!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7344cef1-8b33-4210-b08a-fa1a4125c446_1328x716.png 1272w, https://substackcdn.com/image/fetch/$s_!jxBp!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7344cef1-8b33-4210-b08a-fa1a4125c446_1328x716.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!jxBp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7344cef1-8b33-4210-b08a-fa1a4125c446_1328x716.png" width="1328" height="716" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7344cef1-8b33-4210-b08a-fa1a4125c446_1328x716.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:716,&quot;width&quot;:1328,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;How a judge scores Tone &amp; Voice&quot;,&quot;title&quot;:&quot;How a judge scores Tone &amp; Voice&quot;,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="How a judge scores Tone &amp; Voice" title="How a judge scores Tone &amp; Voice" srcset="https://substackcdn.com/image/fetch/$s_!jxBp!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7344cef1-8b33-4210-b08a-fa1a4125c446_1328x716.png 424w, https://substackcdn.com/image/fetch/$s_!jxBp!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7344cef1-8b33-4210-b08a-fa1a4125c446_1328x716.png 848w, https://substackcdn.com/image/fetch/$s_!jxBp!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7344cef1-8b33-4210-b08a-fa1a4125c446_1328x716.png 1272w, https://substackcdn.com/image/fetch/$s_!jxBp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7344cef1-8b33-4210-b08a-fa1a4125c446_1328x716.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Figure 2. Quote evidence, pick the level that fits the whole script, then a score inside it. For tone and voice, my own script is the top of the scale.</em></figcaption></figure></div><p>That flexibility has a price (in tokens):</p><ul><li><p><strong>Write a lot, and write it yourself.</strong> LLM judges need extremely detailed descriptions to understand how to rate it the way you&#8217;d like. Claude cannot do this for you, especially on a highly subjective task. Our judges read about 16,000 words per judgment: rubric, brief, research, my script and the draft included. Tone and voice alone (one of the 9 metrics) gets about 1,400 words. I&#8217;m still constantly optimizing this rubric with more examples and comparing whether each change improves the judge&#8217;s consistency and reliability.</p></li><li><p><strong>Give scored examples, good and bad, with the why.</strong> Each metric has two of my own passages at the top of the scale, then weaker ones, each with a line on what earns that score. A generic passage next to what makes it generic teaches more than any quantifiable rating can on a subjective task. But it also means you need tons of examples for every single possibility to teach the judge what &#8220;good&#8221;, &#8220;bad&#8221; and everything in between looks like.</p></li><li><p><strong>Check your score histogram for magnets.</strong> When our rubric used 24 model-written examples, each with a number, Opus gave 52 about eight times as often as 51 or 53, and DeepSeek about forty times as often. We thus added more examples and improved the rubric so it didn&#8217;t happen, but you don&#8217;t know these things unless you measure them.</p></li><li><p><strong>Test that a new version separates good from bad.</strong> On October 5, a longer, more detailed rubric draft scored the weakest of those 60 scripts 12 to 16 points higher than the live rubric with Opus 5. A shorter version widened the best-to-bottom spread from 31 to 39 points. More detail only helps when it&#8217;s the right detail. If you just want to make the rubric as long as possible and as detailed as possible, you risk contradicting yourself and mix up the judges. So measure that too and carefully work on the rubrics iteratively.</p></li><li><p><strong>Quote before scoring, and hide what the judge shouldn&#8217;t use.</strong> One or two short verbatim quotes per metric, before the number, are our guard against one strong impression lifting every metric. Judges never see the model name or the word count; when they saw the count, it leaked into other scores. Length, the slop-word list and dashes are scored in code. Coming back to hard-coding evals, we always want to resort to purely deterministic measurements whenever we can.</p></li></ul><h2>4. One judge is a vote for its own model</h2><p>ToneBench started in June with one judge, GPT-5.5, and switched to Claude Opus 4.8 five days later. That&#8217;s when I hit a problem one judge can&#8217;t solve: Claude models led the board, and I couldn&#8217;t tell whether Claude led because it wrote best or because Claude was grading. In July we went to three judges from three labs, and since October 7 it&#8217;s four: Claude Opus 5.5, GPT-6.1 Sol, GLM 5.3 Flash (open weights), and Jev, a typed judge from TypeSafe that answers fixed multiple-choice questions and has no model on the board.</p><p>Judges never see model names, so whatever they prefer comes from the writing itself. Of course, there are some preferences. <strong>Every LLM judge on our panel leans toward its own model</strong>. GPT-6.1 Sol gives its own model 7.7 points more than the other judges would predict, and OpenAI 4.1 more. Claude Opus 5.5 gives Anthropic 2.2. GLM&#8217;s lean toward Z.ai as a lab is small enough to be noise, though it still gives its own model 1.8.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!KmJ2!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F532d73d0-e639-472a-803a-42cb446ec346_2000x758.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!KmJ2!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F532d73d0-e639-472a-803a-42cb446ec346_2000x758.png 424w, https://substackcdn.com/image/fetch/$s_!KmJ2!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F532d73d0-e639-472a-803a-42cb446ec346_2000x758.png 848w, https://substackcdn.com/image/fetch/$s_!KmJ2!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F532d73d0-e639-472a-803a-42cb446ec346_2000x758.png 1272w, https://substackcdn.com/image/fetch/$s_!KmJ2!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F532d73d0-e639-472a-803a-42cb446ec346_2000x758.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!KmJ2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F532d73d0-e639-472a-803a-42cb446ec346_2000x758.png" width="1456" height="552" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/532d73d0-e639-472a-803a-42cb446ec346_2000x758.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:552,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Can we trust the judges?&quot;,&quot;title&quot;:&quot;Can we trust the judges?&quot;,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Can we trust the judges?" title="Can we trust the judges?" srcset="https://substackcdn.com/image/fetch/$s_!KmJ2!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F532d73d0-e639-472a-803a-42cb446ec346_2000x758.png 424w, https://substackcdn.com/image/fetch/$s_!KmJ2!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F532d73d0-e639-472a-803a-42cb446ec346_2000x758.png 848w, https://substackcdn.com/image/fetch/$s_!KmJ2!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F532d73d0-e639-472a-803a-42cb446ec346_2000x758.png 1272w, https://substackcdn.com/image/fetch/$s_!KmJ2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F532d73d0-e639-472a-803a-42cb446ec346_2000x758.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Figure 3. Every AI judge has a favorite lab: points each judge adds to or removes from a lab&#8217;s drafts, compared with the other judges (board of October 26, 2026).</em></figcaption></figure></div><p>Our answer is a panel from different families with equal weights, because the preferences pull against each other: GPT-6.1 Sol docks Anthropic about as much as Opus adds. That dilutes the bias without removing it. For labs with five or more configurations, no single judge moves the lab&#8217;s average by more than 1.4 points, but on a crowded board that still matters: GPT-6.1 Sol&#8217;s lean alone moves OpenAI&#8217;s configurations about 8 places on average. So we drop one judge at a time and recompute whenever the scores change. On the October 26 board, removing any one of the four still leaves Opus 5.5 on max and extra high first and second. Even if we remove the Opus judge and only use the three others.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Jw9l!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4693c628-97d7-4f64-bdea-30fdd0a93382_2046x1074.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Jw9l!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4693c628-97d7-4f64-bdea-30fdd0a93382_2046x1074.png 424w, https://substackcdn.com/image/fetch/$s_!Jw9l!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4693c628-97d7-4f64-bdea-30fdd0a93382_2046x1074.png 848w, https://substackcdn.com/image/fetch/$s_!Jw9l!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4693c628-97d7-4f64-bdea-30fdd0a93382_2046x1074.png 1272w, https://substackcdn.com/image/fetch/$s_!Jw9l!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4693c628-97d7-4f64-bdea-30fdd0a93382_2046x1074.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!Jw9l!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4693c628-97d7-4f64-bdea-30fdd0a93382_2046x1074.png" width="1456" height="764" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4693c628-97d7-4f64-bdea-30fdd0a93382_2046x1074.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:764,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Four judges, four different behaviors&quot;,&quot;title&quot;:&quot;Four judges, four different behaviors&quot;,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Four judges, four different behaviors" title="Four judges, four different behaviors" srcset="https://substackcdn.com/image/fetch/$s_!Jw9l!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4693c628-97d7-4f64-bdea-30fdd0a93382_2046x1074.png 424w, https://substackcdn.com/image/fetch/$s_!Jw9l!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4693c628-97d7-4f64-bdea-30fdd0a93382_2046x1074.png 848w, https://substackcdn.com/image/fetch/$s_!Jw9l!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4693c628-97d7-4f64-bdea-30fdd0a93382_2046x1074.png 1272w, https://substackcdn.com/image/fetch/$s_!Jw9l!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4693c628-97d7-4f64-bdea-30fdd0a93382_2046x1074.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Figure 4. Claude, GPT, an open model and a typed judge on the same 7,050 drafts.</em></figcaption></figure></div><p>The panel also shows how differently these judges behave (Figure 4):</p><ul><li><p><strong>They disagree on generosity and agree on order.</strong> Opus averages 68.0, and GLM 82.4 on the same drafts, yet each judge&#8217;s ranking matches the final one at a Spearman of 0.92 to 0.99. It&#8217;s like a heart monitor that always reads three beats low. As long as the ratings stay consistent over time and the model ranking order stays the same across our judges, the benchmark works. The actual rating number isn&#8217;t so important to match between judges.</p></li><li><p><strong>The open judge has the smallest lab lean and is the hardest to run.</strong> GLM 5.3 Flash judged the whole board for about $65. It&#8217;s also the slowest by far, needed 84 schema retries where GPT needed 5, and seems to struggle more to separate good drafts near the top. Great as one voice out of four, and really token efficient, but I would favor &#8220;better and bigger models&#8221; for judges if the budget allows. Right now, this is a side project, and I can&#8217;t spend more than that on judging models, so GLM 5.3 Flash it is!</p></li></ul><h2>5. Calibrate against humans, on the same categories as your judges</h2><p>LLM judges are biased one way or the other, and so are humans, but writing is a human task, so I&#8217;d rather our judges be biased toward people. Only people can check that.</p><p>I lost three weeks here. My first idea was an arena where the community rates drafts head to head. My team wrote close to 1,000 reviews on 360 pairs, and rating by hand showed the first version was broken: about 90% of the first 50 pairs compared sections with nothing in common. We fixed it, but a deeper problem stayed. Our arena only recorded which passage someone preferred, with no reason and no metric, so it couldn&#8217;t tell me which part of my judges was off.</p><p>So we&#8217;re building something much simpler that I should have started with: a golden set. 240 standalone excerpts of at most 250 words, from strong, middle and weak drafts, plus a few of my own passages and 10 deliberately broken controls. Each gets rated once, by me or one teammate I trust, on 1-to-5 scales for the same kinds of categories the judges score: voice, clarity, slop and overall. Every LLM judge and rubric change will then be compared with it, category by category, in rank order. We already had a &#8220;golden dataset&#8221; with my real scripts for those 10 tasks, but we didn&#8217;t have proper ratings and justifications other than for the rubric itself with small excerpts.</p><p>We&#8217;ve only just started rating, so no agreement numbers yet to measure the calibration. If I restarted ToneBench tomorrow, I&#8217;d begin here, before writing the perfect rubric. This is something we always recommend doing, and, to be fully transparent, I didn&#8217;t do it at first because I had no clue if the benchmark would see any traction at all. But it did. If evals and these problems sound interesting, I go much deeper into evals in <a href="https://www.louisbouchard.ai/book/">my upcoming AI Engineering for Production book</a>, which will be out by the end of the year! We&#8217;ll kick it off with a live Q&amp;A and some cool perks for all those joining the waitlist. Hope to see you there!</p><h2>6. Keep it trustworthy over time</h2><p>An eval you rerun for months will fail if you don&#8217;t take the time to survey it properly. Most of our mistakes threw no error and left a slightly wrong board. Only my intuition and querying Claude on what it built and why made us solve them. A few best practices I got out of this project:</p><ul><li><p><strong>Pin the exact judge model, and check who answers.</strong> Twice, the model behind our Claude judge&#8217;s name changed without an error. In September, a generic &#8220;opus&#8221; alias reached Opus 5.5 while we were judging with Opus 5, and Opus 5.5 ended up grading its own drafts. Now every judge is pinned to an exact model ID, and a test call must return that model before a run starts. Measure everything, and ask Claude to double-check the monitoring to make sure everything looks fine!</p></li><li><p><strong>Treat a judge change as a new benchmark.</strong> Moving from Opus 4.8 to Opus 5 meant re-judging 4,199 drafts, and 76 of 140 models moved, mostly by a place or two. One changed rubric line costs about $2,350 to re-judge, $3,750 if the models rewrite too. Iterate on small samples: the first run is the cheapest one, but you will discover some issues only when scaling. Be sure to be transparent about how the board may change if you are still working on the rubrics and judges.</p></li><li><p><strong>Don&#8217;t use your judges as validation.</strong> All four scored 65 Grok drafts that opened with tool-progress notes instead of a script. The output format was wrong just because of how we prompted it. Instead of flagging this issue, the judges just scored them lower; only our audits caught them. Make sure to double-check the formats and actual outputs and inputs processed. Surprising biases could be breaking your evals. You need to know what&#8217;s happening behind the hood.</p></li><li><p><strong>Run pairwise comparisons in both orders.</strong> In our head-to-head check to double-check script-generation quality, the script read second won two times out of three, so a win now counts only when both orders agree.</p></li></ul><h2>What I&#8217;d do this week</h2><p>ToneBench measures my voice on my scripts. Use it to shortlist models, then evaluate them on your own outputs. It isn&#8217;t a ground truth on which models you should use. Just a good signal on what to test for your own use case when it comes to writing/editing with AI models. The board, more details on the methodology, and the judge data are live and free at <a href="https://benchmark.towardsai.com">benchmark.towardsai.com</a>.</p><p>And if you run an LLM judge, do one thing this week: <em>have two people rate a few dozen of your outputs blind, check whether your judge ranks them the same way, and keep those ratings to test every rubric change.</em> It&#8217;s the simplest check in this post, and the one I waited too long to run.</p><div class="callout-block" data-callout="true"><p>If this was useful, I&#8217;m finishing <em><strong>AI Engineering for Production</strong></em>, a book that goes much further into evals and what we learned building AI systems with our clients and building this benchmark. We&#8217;ll release the book by the end of the year, and the waitlist is open. Anyone joining it will get extra perks when we launch the book!</p><p style="text-align: center;"><strong><a href="https://www.louisbouchard.ai/book/">Read more &#8594;</a></strong></p></div><p><em>I hope it helps!</em><br><a href="https://substack.com/profile/130571458-louis-francois-bouchard?utm_source=global-search">Louis-Fran&#231;ois</a></p><div><hr></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.decodingai.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">Learn AI engineering end-to-end, from idea to production, from the author of the best-selling LLM Engineer&#8217;s Handbook.</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><div><hr></div><div class="callout-block" data-callout="true"><h4>Whenever you&#8217;re ready, here is how I can help you</h4><p><em>Go from agent user to agent builder.</em> Master the foundations of AI agents and turn fragile demo code into reliable, production-ready systems with my course, <strong><a href="https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering">Agent Engineering: Building Multi-Agent Systems</a></strong> (made with Towards AI).</p><p>35 lessons. Pure foundations from scratch. 4 mini-projects. 2 production systems. A certificate and direct access to me &amp; industry experts in our Discord.</p><p>Built for software and data professionals transitioning into AI engineering. <em>Rated 5/5 with 300+ students. The first 7 lessons are free:</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering&quot;,&quot;text&quot;:&quot;Start here&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering"><span>Start here</span></a></p><p><em>Not ready to commit?</em> Start with our <strong><a href="https://email-course.towardsai.net/?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering">free Agent AI Engineering Guide</a></strong>, a 6-day email course on the mistakes that silently break AI agents in production.</p></div><div><hr></div><h2>Images &amp; videos</h2><p>If not otherwise stated, all images and videos are created by the author.</p>]]></content:encoded></item><item><title><![CDATA[Harness Engineering Roadmap: Claude Code From First Principles]]></title><description><![CDATA[The harness took LangChain's agent from outside the top 30 to the top 5]]></description><link>https://www.decodingai.com/p/claude-code-from-scratch-harness-engineering-roadmap</link><guid isPermaLink="false">https://www.decodingai.com/p/claude-code-from-scratch-harness-engineering-roadmap</guid><dc:creator><![CDATA[Paul Iusztin]]></dc:creator><pubDate>Tue, 03 Nov 2026 06:01:13 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!6LcB!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6e4bcfd-29f8-41c6-8083-fa6c0bca750c_1376x768.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_!6LcB!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6e4bcfd-29f8-41c6-8083-fa6c0bca750c_1376x768.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!6LcB!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6e4bcfd-29f8-41c6-8083-fa6c0bca750c_1376x768.png 424w, https://substackcdn.com/image/fetch/$s_!6LcB!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6e4bcfd-29f8-41c6-8083-fa6c0bca750c_1376x768.png 848w, https://substackcdn.com/image/fetch/$s_!6LcB!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6e4bcfd-29f8-41c6-8083-fa6c0bca750c_1376x768.png 1272w, https://substackcdn.com/image/fetch/$s_!6LcB!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6e4bcfd-29f8-41c6-8083-fa6c0bca750c_1376x768.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!6LcB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6e4bcfd-29f8-41c6-8083-fa6c0bca750c_1376x768.png" width="1376" height="768" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e6e4bcfd-29f8-41c6-8083-fa6c0bca750c_1376x768.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:768,&quot;width&quot;:1376,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;The model is the glowing core. The harness is everything you build around it.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="The model is the glowing core. The harness is everything you build around it." title="The model is the glowing core. The harness is everything you build around it." srcset="https://substackcdn.com/image/fetch/$s_!6LcB!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6e4bcfd-29f8-41c6-8083-fa6c0bca750c_1376x768.png 424w, https://substackcdn.com/image/fetch/$s_!6LcB!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6e4bcfd-29f8-41c6-8083-fa6c0bca750c_1376x768.png 848w, https://substackcdn.com/image/fetch/$s_!6LcB!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6e4bcfd-29f8-41c6-8083-fa6c0bca750c_1376x768.png 1272w, https://substackcdn.com/image/fetch/$s_!6LcB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6e4bcfd-29f8-41c6-8083-fa6c0bca750c_1376x768.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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 fastest way to learn harness engineering? Build Claude Code from scratch.</p><p>Why harness engineering? LangChain kept the same model and changed only the harness. Their coding agent went from 53% to 67% on Terminal-Bench, a top coding-agent benchmark. From outside the top 30 to the top 5. Same model. Better harness.</p><p>Over the past few months, I&#8217;ve taken apart Claude Code, OpenCode, and Pi to see how they work under the hood.</p><p>And you don&#8217;t need to ship a coding agent for this to pay off. The same foundations power any agent, in e-commerce, finance, or sales.</p><p>On top of that, people are increasingly realizing they need to build their own harness instead of relying on Claude Code or Codex. Ramp is a perfect example: roughly half of its merged PRs now come out of a custom harness.</p><p>So I turned what I learned, not into a scrapped roadmap, BUT into an in-depth course on harness engineering by building Claude Code from scratch. It&#8217;s free and open source: 8 articles, 6 videos, and one codebase. Each lesson is a new brick. Perfect for people who learn by building.</p><p><em>Builders love it! It already has 1078 &#11088;&#65039; on GitHub.</em> </p><p><strong>TL;DR</strong>:<em> Here are the 8 steps that I think are core to building and maintaining any harness:</em></p><ol><li><p>Design the harness</p></li><li><p>Build the bare-bones agent loop</p></li><li><p>Sandbox it, locally and remotely</p></li><li><p>Apply 4 essential context engineering techniques</p></li><li><p>Add subagents as a context engineering technique</p></li><li><p>Deploy it headless to the cloud: CLI, webhooks, cron</p></li><li><p>Build custom benchmarks to measure the agent</p></li><li><p>Replay failed runs to debug agents</p></li></ol><p>All while building and evaluating Decode, the coding agent.</p><p>Before starting, a quick word from our sponsor &#8595;</p><div class="callout-block" data-callout="true"><h2><a href="https://inngest.link/dai-nl">Build for the long run (Sponsored)</a></h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://inngest.link/dai-nl" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!0XGX!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F32e8504e-caa6-4e9b-8773-27507e579eb6_2190x1061.png 424w, https://substackcdn.com/image/fetch/$s_!0XGX!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F32e8504e-caa6-4e9b-8773-27507e579eb6_2190x1061.png 848w, https://substackcdn.com/image/fetch/$s_!0XGX!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F32e8504e-caa6-4e9b-8773-27507e579eb6_2190x1061.png 1272w, https://substackcdn.com/image/fetch/$s_!0XGX!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F32e8504e-caa6-4e9b-8773-27507e579eb6_2190x1061.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!0XGX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F32e8504e-caa6-4e9b-8773-27507e579eb6_2190x1061.png" width="1456" height="705" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/32e8504e-caa6-4e9b-8773-27507e579eb6_2190x1061.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:705,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;If your code runs for minutes or days, it won't run straight through. Wrap functions in steps that automatically retry, pause, and fan out. Scale instantly, without thinking about infra.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:&quot;https://inngest.link/dai-nl&quot;,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="If your code runs for minutes or days, it won't run straight through. Wrap functions in steps that automatically retry, pause, and fan out. Scale instantly, without thinking about infra." title="If your code runs for minutes or days, it won't run straight through. Wrap functions in steps that automatically retry, pause, and fan out. Scale instantly, without thinking about infra." srcset="https://substackcdn.com/image/fetch/$s_!0XGX!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F32e8504e-caa6-4e9b-8773-27507e579eb6_2190x1061.png 424w, https://substackcdn.com/image/fetch/$s_!0XGX!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F32e8504e-caa6-4e9b-8773-27507e579eb6_2190x1061.png 848w, https://substackcdn.com/image/fetch/$s_!0XGX!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F32e8504e-caa6-4e9b-8773-27507e579eb6_2190x1061.png 1272w, https://substackcdn.com/image/fetch/$s_!0XGX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F32e8504e-caa6-4e9b-8773-27507e579eb6_2190x1061.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>You voted for the overnight agent (34%), and the comments kept asking one thing: &#8220;<em>What happens when it dies at 3 a.m.?&#8221;</em></p><p>Does it resume from a checkpoint or start over? And in the morning, how do you tell what actually ran from what the agent <em>says it did</em>?</p><p>&#9889;&#65039; <em>That&#8217;s the problem Inngest solves. It makes long-running agents durable and observable.</em></p><p>Crash at 3 a.m.? It picks up from the last completed step, not from zero. Morning review? Every run is traced, so you see what actually ran, not the agent&#8217;s summary.</p><p><strong>Free tier</strong>, plus a local dev server, so you can try it on your laptop tonight.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://inngest.link/dai-nl&quot;,&quot;text&quot;:&quot;Build for the long run with Inngest&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://inngest.link/dai-nl"><span>Build for the long run with Inngest</span></a></p></div><p>Now, let&#8217;s zoom in on each step.</p><h2>Step 1: Design the harness</h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!wxlh!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48e1064a-c6c8-4afd-a7b7-441b4be74354_1254x981.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!wxlh!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48e1064a-c6c8-4afd-a7b7-441b4be74354_1254x981.png 424w, https://substackcdn.com/image/fetch/$s_!wxlh!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48e1064a-c6c8-4afd-a7b7-441b4be74354_1254x981.png 848w, https://substackcdn.com/image/fetch/$s_!wxlh!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48e1064a-c6c8-4afd-a7b7-441b4be74354_1254x981.png 1272w, https://substackcdn.com/image/fetch/$s_!wxlh!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48e1064a-c6c8-4afd-a7b7-441b4be74354_1254x981.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!wxlh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48e1064a-c6c8-4afd-a7b7-441b4be74354_1254x981.png" width="1254" height="981" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/48e1064a-c6c8-4afd-a7b7-441b4be74354_1254x981.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:null,&quot;height&quot;:981,&quot;width&quot;:1254,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Image 2: Your harness is a headless core with six modules, driven by a TUI or a remote mode, with an evals layer underneath.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:&quot;center&quot;,&quot;offset&quot;:false}" class="sizing-normal" alt="Image 2: Your harness is a headless core with six modules, driven by a TUI or a remote mode, with an evals layer underneath." title="Image 2: Your harness is a headless core with six modules, driven by a TUI or a remote mode, with an evals layer underneath." srcset="https://substackcdn.com/image/fetch/$s_!wxlh!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48e1064a-c6c8-4afd-a7b7-441b4be74354_1254x981.png 424w, https://substackcdn.com/image/fetch/$s_!wxlh!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48e1064a-c6c8-4afd-a7b7-441b4be74354_1254x981.png 848w, https://substackcdn.com/image/fetch/$s_!wxlh!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48e1064a-c6c8-4afd-a7b7-441b4be74354_1254x981.png 1272w, https://substackcdn.com/image/fetch/$s_!wxlh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48e1064a-c6c8-4afd-a7b7-441b4be74354_1254x981.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>The Harness of a Coding Agent: Your harness is a headless core with six modules, driven by a TUI or a remote mode, with an evals layer underneath.</em></figcaption></figure></div><p>When I first started digging into coding agents, I couldn&#8217;t tell where the agent ended and the harness began.</p><p>So step 1 is to design the harness before you write any code. The agent itself is ~20 lines of Pydantic AI. Everything on top of it is the harness: 6 modules, 3 interfaces (a terminal UI, CLI (not in the diagram) and a remote mode on Modal), and an evals layer that answers whether it works, still works, and keeps working.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://www.decodingai.com/p/building-a-coding-agent-from-scratch-system-design&quot;,&quot;text&quot;:&quot;Read the article&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://www.decodingai.com/p/building-a-coding-agent-from-scratch-system-design"><span>Read the article</span></a></p><p>Or if you prefer video:</p><div id="youtube2-sJpop1juVBQ" class="youtube-wrap" data-attrs="{&quot;videoId&quot;:&quot;sJpop1juVBQ&quot;,&quot;startTime&quot;:null,&quot;endTime&quot;:null}" data-component-name="Youtube2ToDOM"><div class="youtube-inner"><iframe src="https://www.youtube-nocookie.com/embed/sJpop1juVBQ?rel=0&amp;autoplay=0&amp;showinfo=0&amp;enablejsapi=0" frameborder="0" loading="lazy" gesture="media" allow="autoplay; fullscreen" allowautoplay="true" allowfullscreen="true" width="728" height="409"></iframe></div></div><h2>Step 2: Build the bare-bones agent loop</h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!R03g!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd5cbc7e9-42cf-4bd8-a4e3-470b6ad4b06d_1209x1001.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!R03g!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd5cbc7e9-42cf-4bd8-a4e3-470b6ad4b06d_1209x1001.png 424w, https://substackcdn.com/image/fetch/$s_!R03g!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd5cbc7e9-42cf-4bd8-a4e3-470b6ad4b06d_1209x1001.png 848w, https://substackcdn.com/image/fetch/$s_!R03g!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd5cbc7e9-42cf-4bd8-a4e3-470b6ad4b06d_1209x1001.png 1272w, https://substackcdn.com/image/fetch/$s_!R03g!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd5cbc7e9-42cf-4bd8-a4e3-470b6ad4b06d_1209x1001.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!R03g!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd5cbc7e9-42cf-4bd8-a4e3-470b6ad4b06d_1209x1001.png" width="1209" height="1001" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d5cbc7e9-42cf-4bd8-a4e3-470b6ad4b06d_1209x1001.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:null,&quot;height&quot;:1001,&quot;width&quot;:1209,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Image 3: Your agent loops over 9 tools and 3 swappable LLM providers in a steerable TUI.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:&quot;center&quot;,&quot;offset&quot;:false}" class="sizing-normal" alt="Image 3: Your agent loops over 9 tools and 3 swappable LLM providers in a steerable TUI." title="Image 3: Your agent loops over 9 tools and 3 swappable LLM providers in a steerable TUI." srcset="https://substackcdn.com/image/fetch/$s_!R03g!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd5cbc7e9-42cf-4bd8-a4e3-470b6ad4b06d_1209x1001.png 424w, https://substackcdn.com/image/fetch/$s_!R03g!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd5cbc7e9-42cf-4bd8-a4e3-470b6ad4b06d_1209x1001.png 848w, https://substackcdn.com/image/fetch/$s_!R03g!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd5cbc7e9-42cf-4bd8-a4e3-470b6ad4b06d_1209x1001.png 1272w, https://substackcdn.com/image/fetch/$s_!R03g!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd5cbc7e9-42cf-4bd8-a4e3-470b6ad4b06d_1209x1001.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>The Coding Agent Loop: Your agent loops over 9 tools and 3 swappable LLM providers in a steerable TUI.</em></figcaption></figure></div><p>I got greedy. I tried to one-shot the harness in Python: a terminal UI (TUI), an agent, and a handful of tools. It worked, until I started adding skills, memory, and compaction. That&#8217;s when everything started to fall apart.</p><p>Step 2 builds the bare-bones loop at feature parity with Pi: one ReAct loop (Claude Code&#8217;s is ~150 lines) and 9 tools with read, write, edit, and bash at the core. A terminal UI with a steering queue lets you redirect the agent mid-turn.</p><p>The tools are 90% of why this is a coding agent and not any other kind of AI agent.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://www.decodingai.com/p/the-coding-agent-loop&quot;,&quot;text&quot;:&quot;Read the article&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://www.decodingai.com/p/the-coding-agent-loop"><span>Read the article</span></a></p><h2>Step 3: Sandbox it, locally and remotely</h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!GZUt!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1442fddc-a4c7-4ce4-87e3-83787ee9a814_1200x1200.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!GZUt!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1442fddc-a4c7-4ce4-87e3-83787ee9a814_1200x1200.png 424w, https://substackcdn.com/image/fetch/$s_!GZUt!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1442fddc-a4c7-4ce4-87e3-83787ee9a814_1200x1200.png 848w, https://substackcdn.com/image/fetch/$s_!GZUt!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1442fddc-a4c7-4ce4-87e3-83787ee9a814_1200x1200.png 1272w, https://substackcdn.com/image/fetch/$s_!GZUt!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1442fddc-a4c7-4ce4-87e3-83787ee9a814_1200x1200.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!GZUt!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1442fddc-a4c7-4ce4-87e3-83787ee9a814_1200x1200.png" width="1200" height="1200" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1442fddc-a4c7-4ce4-87e3-83787ee9a814_1200x1200.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:null,&quot;height&quot;:1200,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Image 4: Your agent's tools run in a Docker or Modal sandbox, never on your host.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:&quot;center&quot;,&quot;offset&quot;:false}" class="sizing-normal" alt="Image 4: Your agent's tools run in a Docker or Modal sandbox, never on your host." title="Image 4: Your agent's tools run in a Docker or Modal sandbox, never on your host." srcset="https://substackcdn.com/image/fetch/$s_!GZUt!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1442fddc-a4c7-4ce4-87e3-83787ee9a814_1200x1200.png 424w, https://substackcdn.com/image/fetch/$s_!GZUt!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1442fddc-a4c7-4ce4-87e3-83787ee9a814_1200x1200.png 848w, https://substackcdn.com/image/fetch/$s_!GZUt!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1442fddc-a4c7-4ce4-87e3-83787ee9a814_1200x1200.png 1272w, https://substackcdn.com/image/fetch/$s_!GZUt!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1442fddc-a4c7-4ce4-87e3-83787ee9a814_1200x1200.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Your agent&#8217;s tools run in a Docker or Modal sandbox, never on your host.</em></figcaption></figure></div><p>Claude Code was running inside my Obsidian Second Brain when it fired off a cleanup command that deleted half my notes. Or the popular example where, in July 2026, OpenAI&#8217;s agents hacked Hugging Face.</p><p>That&#8217;s why, in step 3, we will sandbox the agent locally (Docker) and remotely (Modal), where the agent&#8217;s tools run in an isolated container. One decision: put the whole harness in the sandbox, or keep it on the host and execute only the 4 computer-use tools within the sandbox.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://www.decodingai.com/p/run-coding-agents-safely&quot;,&quot;text&quot;:&quot;Read the article&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://www.decodingai.com/p/run-coding-agents-safely"><span>Read the article</span></a></p><p>Or if you prefer video:</p><div id="youtube2-7CHMb8jWs6A" class="youtube-wrap" data-attrs="{&quot;videoId&quot;:&quot;7CHMb8jWs6A&quot;,&quot;startTime&quot;:null,&quot;endTime&quot;:null}" data-component-name="Youtube2ToDOM"><div class="youtube-inner"><iframe src="https://www.youtube-nocookie.com/embed/7CHMb8jWs6A?rel=0&amp;autoplay=0&amp;showinfo=0&amp;enablejsapi=0" frameborder="0" loading="lazy" gesture="media" allow="autoplay; fullscreen" allowautoplay="true" allowfullscreen="true" width="728" height="409"></iframe></div></div><h2>Step 4: Apply 4 essential context engineering techniques</h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!huju!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba481e67-ef05-4ee2-86f9-eab4673424e8_1244x963.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!huju!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba481e67-ef05-4ee2-86f9-eab4673424e8_1244x963.png 424w, https://substackcdn.com/image/fetch/$s_!huju!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba481e67-ef05-4ee2-86f9-eab4673424e8_1244x963.png 848w, https://substackcdn.com/image/fetch/$s_!huju!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba481e67-ef05-4ee2-86f9-eab4673424e8_1244x963.png 1272w, https://substackcdn.com/image/fetch/$s_!huju!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba481e67-ef05-4ee2-86f9-eab4673424e8_1244x963.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!huju!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba481e67-ef05-4ee2-86f9-eab4673424e8_1244x963.png" width="1244" height="963" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ba481e67-ef05-4ee2-86f9-eab4673424e8_1244x963.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:null,&quot;height&quot;:963,&quot;width&quot;:1244,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Image 5: Your agent loads memory, invokes skills, reads LSP diagnostics, and auto-compacts at 80%.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:&quot;center&quot;,&quot;offset&quot;:false}" class="sizing-normal" alt="Image 5: Your agent loads memory, invokes skills, reads LSP diagnostics, and auto-compacts at 80%." title="Image 5: Your agent loads memory, invokes skills, reads LSP diagnostics, and auto-compacts at 80%." srcset="https://substackcdn.com/image/fetch/$s_!huju!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba481e67-ef05-4ee2-86f9-eab4673424e8_1244x963.png 424w, https://substackcdn.com/image/fetch/$s_!huju!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba481e67-ef05-4ee2-86f9-eab4673424e8_1244x963.png 848w, https://substackcdn.com/image/fetch/$s_!huju!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba481e67-ef05-4ee2-86f9-eab4673424e8_1244x963.png 1272w, https://substackcdn.com/image/fetch/$s_!huju!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba481e67-ef05-4ee2-86f9-eab4673424e8_1244x963.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Context Engineering for Coding Agents: Your agent loads memory, invokes skills, reads LSP diagnostics, and auto-compacts at 80%.</em></figcaption></figure></div><p>For a while, I got hooked on running Claude Code agents 24/7. Until my subscription maxed out mid-turn with the agent halfway through a feature. Throwing in more tokens only treats the symptom. The long-term solution is better context engineering.</p><p>In step 4, we will learn how to keep the context window (everything the model reads each turn) small and high-signal. There are 4 essential techniques to explore: memory (stop repeating your instructions), skills (never load what you can reference), the language-server (LSP) tool (to statically analyze the code), and compaction (delete before the window rots).</p><p>Anthropic frames the whole problem as &#8220;finding the smallest possible set of high-signal tokens&#8221;.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://www.decodingai.com/p/context-engineering-for-coding-agents&quot;,&quot;text&quot;:&quot;Read the article&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://www.decodingai.com/p/context-engineering-for-coding-agents"><span>Read the article</span></a></p><p>Or if you prefer video:</p><div id="youtube2-dx77BRFZ0_M" class="youtube-wrap" data-attrs="{&quot;videoId&quot;:&quot;dx77BRFZ0_M&quot;,&quot;startTime&quot;:null,&quot;endTime&quot;:null}" data-component-name="Youtube2ToDOM"><div class="youtube-inner"><iframe src="https://www.youtube-nocookie.com/embed/dx77BRFZ0_M?rel=0&amp;autoplay=0&amp;showinfo=0&amp;enablejsapi=0" frameborder="0" loading="lazy" gesture="media" allow="autoplay; fullscreen" allowautoplay="true" allowfullscreen="true" width="728" height="409"></iframe></div></div><h2>Step 5: Add subagents as a context engineering technique</h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!P4Wu!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4afeff07-3b80-468c-9837-b247eed15a0a_1219x565.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!P4Wu!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4afeff07-3b80-468c-9837-b247eed15a0a_1219x565.png 424w, https://substackcdn.com/image/fetch/$s_!P4Wu!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4afeff07-3b80-468c-9837-b247eed15a0a_1219x565.png 848w, https://substackcdn.com/image/fetch/$s_!P4Wu!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4afeff07-3b80-468c-9837-b247eed15a0a_1219x565.png 1272w, https://substackcdn.com/image/fetch/$s_!P4Wu!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4afeff07-3b80-468c-9837-b247eed15a0a_1219x565.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!P4Wu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4afeff07-3b80-468c-9837-b247eed15a0a_1219x565.png" width="1219" height="565" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4afeff07-3b80-468c-9837-b247eed15a0a_1219x565.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:null,&quot;height&quot;:565,&quot;width&quot;:1219,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Image 6: An orchestrator agent fans out Explore subagents in-harness through the agent tool, or spawns one harness per child through the CLI in tmux.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:&quot;center&quot;,&quot;offset&quot;:false}" class="sizing-normal" alt="Image 6: An orchestrator agent fans out Explore subagents in-harness through the agent tool, or spawns one harness per child through the CLI in tmux." title="Image 6: An orchestrator agent fans out Explore subagents in-harness through the agent tool, or spawns one harness per child through the CLI in tmux." srcset="https://substackcdn.com/image/fetch/$s_!P4Wu!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4afeff07-3b80-468c-9837-b247eed15a0a_1219x565.png 424w, https://substackcdn.com/image/fetch/$s_!P4Wu!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4afeff07-3b80-468c-9837-b247eed15a0a_1219x565.png 848w, https://substackcdn.com/image/fetch/$s_!P4Wu!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4afeff07-3b80-468c-9837-b247eed15a0a_1219x565.png 1272w, https://substackcdn.com/image/fetch/$s_!P4Wu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4afeff07-3b80-468c-9837-b247eed15a0a_1219x565.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Subagents Are Context Engineering: An orchestrator agent fans out Explore subagents in-harness through the agent tool, or spawns one harness per child through the CLI in tmux.</em></figcaption></figure></div><p>I was passing up to 200 notes, transcripts, and PDFs to a single Claude Code session. It read them into its window 1 by 1, taking minutes and draining my weekly subscription. The fix was 6 researcher subagents in parallel.</p><p>This lesson adds subagents (child agents with their own window) as a context engineering technique. We will explore the two main options to implement subagents. First is to build an <code>agent</code> tool directly into the harness that fans out up to 6 scoped children. The second, the Pi agent way, is to use the orchestrator agent to spawn new agents via the CLI and manage them directly or more professionally with tmux.</p><p>The in-harness tool is a <strong>context</strong> primitive, while tmux is a <strong>process</strong> primitive.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://www.decodingai.com/p/subagents-are-context-engineering&quot;,&quot;text&quot;:&quot;Read the article&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://www.decodingai.com/p/subagents-are-context-engineering"><span>Read the article</span></a></p><h2>Step 6: Deploy it headless to the cloud: CLI, webhooks, cron</h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!N382!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa934c4d2-0a63-4785-b5e2-8e5647adfea0_1239x993.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!N382!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa934c4d2-0a63-4785-b5e2-8e5647adfea0_1239x993.png 424w, https://substackcdn.com/image/fetch/$s_!N382!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa934c4d2-0a63-4785-b5e2-8e5647adfea0_1239x993.png 848w, https://substackcdn.com/image/fetch/$s_!N382!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa934c4d2-0a63-4785-b5e2-8e5647adfea0_1239x993.png 1272w, https://substackcdn.com/image/fetch/$s_!N382!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa934c4d2-0a63-4785-b5e2-8e5647adfea0_1239x993.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!N382!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa934c4d2-0a63-4785-b5e2-8e5647adfea0_1239x993.png" width="1239" height="993" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a934c4d2-0a63-4785-b5e2-8e5647adfea0_1239x993.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:null,&quot;height&quot;:993,&quot;width&quot;:1239,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Image 7: One harness, one loop, four hosts: interactive TUI, local CLI, parallel background jobs on Modal triggered by the CLI, a webhook, or a cron, and the evals harness.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:&quot;center&quot;,&quot;offset&quot;:false}" class="sizing-normal" alt="Image 7: One harness, one loop, four hosts: interactive TUI, local CLI, parallel background jobs on Modal triggered by the CLI, a webhook, or a cron, and the evals harness." title="Image 7: One harness, one loop, four hosts: interactive TUI, local CLI, parallel background jobs on Modal triggered by the CLI, a webhook, or a cron, and the evals harness." srcset="https://substackcdn.com/image/fetch/$s_!N382!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa934c4d2-0a63-4785-b5e2-8e5647adfea0_1239x993.png 424w, https://substackcdn.com/image/fetch/$s_!N382!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa934c4d2-0a63-4785-b5e2-8e5647adfea0_1239x993.png 848w, https://substackcdn.com/image/fetch/$s_!N382!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa934c4d2-0a63-4785-b5e2-8e5647adfea0_1239x993.png 1272w, https://substackcdn.com/image/fetch/$s_!N382!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa934c4d2-0a63-4785-b5e2-8e5647adfea0_1239x993.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>One harness, one loop, four hosts: interactive TUI, local CLI, parallel background jobs on Modal triggered by the CLI, a webhook, or a cron, and the evals harness.</em></figcaption></figure></div><p>I ended up with five coding agents running in parallel. After three hours, I was completely exhausted. The real issue wasn&#8217;t running five agents. It was babysitting them, each needing me present in a terminal.</p><p>Step 6 deploys the harness headless, with no terminal to babysit. We will implement a new CLI interface within Decode, the course&#8217;s coding agent, around the same loop that runs locally, allowing us to run it on Modal serverless functions with 3 triggers (CLI, webhook, nightly cron) and parallel attempts, each with its own container and branch.</p><p>You went to bed. The work did not.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://www.decodingai.com/p/coding-agents-in-remote-headless&quot;,&quot;text&quot;:&quot;Read the article&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://www.decodingai.com/p/coding-agents-in-remote-headless"><span>Read the article</span></a></p><p>Or if you prefer video:</p><div id="youtube2-nIhTdQH6z5g" class="youtube-wrap" data-attrs="{&quot;videoId&quot;:&quot;nIhTdQH6z5g&quot;,&quot;startTime&quot;:null,&quot;endTime&quot;:null}" data-component-name="Youtube2ToDOM"><div class="youtube-inner"><iframe src="https://www.youtube-nocookie.com/embed/nIhTdQH6z5g?rel=0&amp;autoplay=0&amp;showinfo=0&amp;enablejsapi=0" frameborder="0" loading="lazy" gesture="media" allow="autoplay; fullscreen" allowautoplay="true" allowfullscreen="true" width="728" height="409"></iframe></div></div><h2>Step 7: Build custom benchmarks to measure the agent</h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ifEM!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a6d4100-6b1c-4d44-bca4-f6aeb10dbf52_1202x808.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ifEM!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a6d4100-6b1c-4d44-bca4-f6aeb10dbf52_1202x808.png 424w, https://substackcdn.com/image/fetch/$s_!ifEM!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a6d4100-6b1c-4d44-bca4-f6aeb10dbf52_1202x808.png 848w, https://substackcdn.com/image/fetch/$s_!ifEM!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a6d4100-6b1c-4d44-bca4-f6aeb10dbf52_1202x808.png 1272w, https://substackcdn.com/image/fetch/$s_!ifEM!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a6d4100-6b1c-4d44-bca4-f6aeb10dbf52_1202x808.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!ifEM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a6d4100-6b1c-4d44-bca4-f6aeb10dbf52_1202x808.png" width="1202" height="808" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0a6d4100-6b1c-4d44-bca4-f6aeb10dbf52_1202x808.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:null,&quot;height&quot;:808,&quot;width&quot;:1202,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Image 8: The evaluation harness runs each dataset item against a sandboxed agent under test, a verifier scores the solution 0 or 1, and traces, datasets and experiments live in Opik.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:&quot;center&quot;,&quot;offset&quot;:false}" class="sizing-normal" alt="Image 8: The evaluation harness runs each dataset item against a sandboxed agent under test, a verifier scores the solution 0 or 1, and traces, datasets and experiments live in Opik." title="Image 8: The evaluation harness runs each dataset item against a sandboxed agent under test, a verifier scores the solution 0 or 1, and traces, datasets and experiments live in Opik." srcset="https://substackcdn.com/image/fetch/$s_!ifEM!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a6d4100-6b1c-4d44-bca4-f6aeb10dbf52_1202x808.png 424w, https://substackcdn.com/image/fetch/$s_!ifEM!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a6d4100-6b1c-4d44-bca4-f6aeb10dbf52_1202x808.png 848w, https://substackcdn.com/image/fetch/$s_!ifEM!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a6d4100-6b1c-4d44-bca4-f6aeb10dbf52_1202x808.png 1272w, https://substackcdn.com/image/fetch/$s_!ifEM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a6d4100-6b1c-4d44-bca4-f6aeb10dbf52_1202x808.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>The evaluation harness runs each dataset item against a sandboxed agent under test, a verifier scores the solution 0 or 1 and traces, datasets and experiments are tracked in the evals platform.</em></figcaption></figure></div><p>While optimizing my coding agent, I compared its performance against two models: a 35B and a 120B. The winner should be obvious, right? As the 120B model is x4 larger. Well... the 35B model had a success rate of 95%, while the larger one had 53%.</p><p>The difference shows the importance of building a custom benchmark that evaluates what you care about. That&#8217;s what we will build in step 7: an eval harness that never imports the agent&#8217;s loop, a 19-task Terminal-Bench-style benchmark with hidden verifiers, and a regression suite (past failures frozen into tests) grown from production traces, all compared in Opik.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://www.decodingai.com/p/evaluate-ai-agents-benchmarks-regression-tests&quot;,&quot;text&quot;:&quot;Read the article&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://www.decodingai.com/p/evaluate-ai-agents-benchmarks-regression-tests"><span>Read the article</span></a></p><p>Or if you prefer video:</p><div id="youtube2-3QQaonJyUf4" class="youtube-wrap" data-attrs="{&quot;videoId&quot;:&quot;3QQaonJyUf4&quot;,&quot;startTime&quot;:null,&quot;endTime&quot;:null}" data-component-name="Youtube2ToDOM"><div class="youtube-inner"><iframe src="https://www.youtube-nocookie.com/embed/3QQaonJyUf4?rel=0&amp;autoplay=0&amp;showinfo=0&amp;enablejsapi=0" frameborder="0" loading="lazy" gesture="media" allow="autoplay; fullscreen" allowautoplay="true" allowfullscreen="true" width="728" height="409"></iframe></div></div><h2>Step 8: Replay failed runs to debug agents</h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!eK3s!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10d055b0-4967-45f9-ae3e-b57ead3692fa_1184x1148.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!eK3s!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10d055b0-4967-45f9-ae3e-b57ead3692fa_1184x1148.png 424w, https://substackcdn.com/image/fetch/$s_!eK3s!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10d055b0-4967-45f9-ae3e-b57ead3692fa_1184x1148.png 848w, https://substackcdn.com/image/fetch/$s_!eK3s!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10d055b0-4967-45f9-ae3e-b57ead3692fa_1184x1148.png 1272w, https://substackcdn.com/image/fetch/$s_!eK3s!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10d055b0-4967-45f9-ae3e-b57ead3692fa_1184x1148.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!eK3s!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10d055b0-4967-45f9-ae3e-b57ead3692fa_1184x1148.png" width="1184" height="1148" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/10d055b0-4967-45f9-ae3e-b57ead3692fa_1184x1148.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:null,&quot;height&quot;:1148,&quot;width&quot;:1184,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Image 9: Record runs in Kitaru, cluster failures into cohorts, and replay them to verify fixes.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:&quot;center&quot;,&quot;offset&quot;:false}" class="sizing-normal" alt="Image 9: Record runs in Kitaru, cluster failures into cohorts, and replay them to verify fixes." title="Image 9: Record runs in Kitaru, cluster failures into cohorts, and replay them to verify fixes." srcset="https://substackcdn.com/image/fetch/$s_!eK3s!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10d055b0-4967-45f9-ae3e-b57ead3692fa_1184x1148.png 424w, https://substackcdn.com/image/fetch/$s_!eK3s!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10d055b0-4967-45f9-ae3e-b57ead3692fa_1184x1148.png 848w, https://substackcdn.com/image/fetch/$s_!eK3s!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10d055b0-4967-45f9-ae3e-b57ead3692fa_1184x1148.png 1272w, https://substackcdn.com/image/fetch/$s_!eK3s!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10d055b0-4967-45f9-ae3e-b57ead3692fa_1184x1148.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Turn Your Agent&#8217;s Failures Into a Regression Suite: Record runs in Kitaru, cluster failures into cohorts, and replay them to verify fixes.</em></figcaption></figure></div><p>One night, vibe-planning Decode&#8217;s evals layer with Claude Code. (Ironic, right?) The endpoint returned a 503 ... and instead of stopping, the coding agent found a Gemini API key in memory and decided to use it to achieve its goal no matter what, and 40 <em>of</em> <em>tokens</em> <em>burned</em> <em>on</em> 20 <em>benchmark</em> <em>tests</em> <em>by</em> <em>the</em> <em>next</em> <em>morning</em>.</p><p><em>In</em> <em>step</em> 8, <em>we</em> <em>will</em> <em>replay</em> <em>failed</em> <em>runs</em> <em>with</em> <em>Kitaru</em>&#8216;<em>s</em> <em>error</em> <em>analysis</em> <em>framework</em>: <em>record</em> <em>runs</em>, <em>label</em> <em>pass</em> <em>or</em> <em>fail</em>, <em>cluster</em> <em>failures</em> <em>into</em> <em>cohorts</em>, <em>and</em> <em>replay</em> <em>each</em> <em>cohort</em> <em>after</em> <em>every</em> <em>change</em> <em>with</em> <em>the</em> <em>exact</em> <em>tool</em> <em>outputs</em> <em>the</em> <em>agent</em> <em>saw</em> <em>to</em> <em>reproduce</em> <em>the</em> <em>bug</em> <em>without</em> <em>side</em> <em>effects</em>.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://www.decodingai.com/p/transform-agent-traces-into-regression-cases&quot;,&quot;text&quot;:&quot;Read the article&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://www.decodingai.com/p/transform-agent-traces-into-regression-cases"><span>Read the article</span></a></p><p>Or if you prefer video:</p><div id="youtube2-HuRLvkG7tVg" class="youtube-wrap" data-attrs="{&quot;videoId&quot;:&quot;HuRLvkG7tVg&quot;,&quot;startTime&quot;:null,&quot;endTime&quot;:null}" data-component-name="Youtube2ToDOM"><div class="youtube-inner"><iframe src="https://www.youtube-nocookie.com/embed/HuRLvkG7tVg?rel=0&amp;autoplay=0&amp;showinfo=0&amp;enablejsapi=0" frameborder="0" loading="lazy" gesture="media" allow="autoplay; fullscreen" allowautoplay="true" allowfullscreen="true" width="728" height="409"></iframe></div></div><h2>&#129488; How to take the course?</h2><p>The course is 100% open-source and free. The 8 articles are on the <a href="https://www.decodingai.com/t/building-a-coding-agent-from-scratch">Decoding AI Magazine</a> and the 6 videos are on the <a href="https://www.youtube.com/playlist?list=PLanusVPiXCT0">Decoding AI YouTube Channel</a>. The code is <a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course">available on GitHub</a>, with full details for you and your agent on how to run it and follow along.</p><p><strong>Who is it perfect for?</strong> Engineers who learn by building. You finish with a working coding agent that teaches you harness engineering patterns to steal for your own agentic applications.</p><p>The course takes ~4&#8211;8 hours, 4 if you read and watch, 6&#8211;8 if you run everything. If you&#8217;re short on time, paid subscribers have access to the <a href="https://www.decodingai.com/p/learning-harness-engineering-by-building">90-minute webinar</a> recording that distills all 8 lessons.</p><p>It&#8216;s an intermediate course, but with a little sweat, patience and tokens, anyone can do it. Everything is in Python, and it assumes you already understand the basics of LLMs and agents.</p><p>You don&#8216;t need any special hardware to run it (no GPU!), as everything runs in the cloud. We also picked the right providers to run everything end-to-end for $0.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!UVWw!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc234027-9654-4fdb-a97f-a30cd7482c73_1886x746.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!UVWw!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc234027-9654-4fdb-a97f-a30cd7482c73_1886x746.png 424w, https://substackcdn.com/image/fetch/$s_!UVWw!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc234027-9654-4fdb-a97f-a30cd7482c73_1886x746.png 848w, https://substackcdn.com/image/fetch/$s_!UVWw!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc234027-9654-4fdb-a97f-a30cd7482c73_1886x746.png 1272w, https://substackcdn.com/image/fetch/$s_!UVWw!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc234027-9654-4fdb-a97f-a30cd7482c73_1886x746.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!UVWw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc234027-9654-4fdb-a97f-a30cd7482c73_1886x746.png" width="1456" height="576" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/dc234027-9654-4fdb-a97f-a30cd7482c73_1886x746.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:576,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:190040,&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://www.decodingai.com/i/222328372?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc234027-9654-4fdb-a97f-a30cd7482c73_1886x746.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_!UVWw!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc234027-9654-4fdb-a97f-a30cd7482c73_1886x746.png 424w, https://substackcdn.com/image/fetch/$s_!UVWw!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc234027-9654-4fdb-a97f-a30cd7482c73_1886x746.png 848w, https://substackcdn.com/image/fetch/$s_!UVWw!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc234027-9654-4fdb-a97f-a30cd7482c73_1886x746.png 1272w, https://substackcdn.com/image/fetch/$s_!UVWw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc234027-9654-4fdb-a97f-a30cd7482c73_1886x746.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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 class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course&quot;,&quot;text&quot;:&quot;Find more details on GitHub&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course"><span>Find more details on GitHub</span></a></p><h2>Further reading</h2><ol><li><p><a href="https://www.langchain.com/blog/the-anatomy-of-an-agent-harness">The Anatomy of an Agent Harness</a></p></li><li><p><a href="https://modal.com/blog/how-ramp-built-a-full-context-background-coding-agent-on-modal">How Ramp Built a Full-Context Background Coding Agent on Modal</a></p></li><li><p><a href="https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents">Effective Context Engineering for AI Agents</a></p></li><li><p><a href="https://www.scientificamerican.com/article/openai-admits-its-agent-went-rogue-and-hacked-ai-startup-hugging-face/">OpenAI Admits Its Agent Went Rogue and Hacked AI Startup Hugging Face</a></p></li></ol><div><hr></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.decodingai.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">Learn AI engineering end-to-end, from idea to production, from the author of the best-selling LLM Engineer&#8217;s Handbook.</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><div><hr></div><div class="callout-block" data-callout="true"><h4>Whenever you&#8217;re ready, here is how I can help you</h4><p><em>Go from agent user to agent builder.</em> Master the foundations of AI agents and turn fragile demo code into reliable, production-ready systems with my course, <strong><a href="https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering">Agent Engineering: Building Multi-Agent Systems</a></strong> (made with Towards AI).</p><p>35 lessons. Pure foundations from scratch. 4 mini-projects. 2 production systems. A certificate and direct access to me &amp; industry experts in our Discord.</p><p>Built for software and data professionals transitioning into AI engineering. <em>Rated 5/5 with 300+ students. The first 7 lessons are free:</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering&quot;,&quot;text&quot;:&quot;Start here&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering"><span>Start here</span></a></p><p><em>Not ready to commit?</em> Start with our <strong><a href="https://email-course.towardsai.net/?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering">free Agent AI Engineering Guide</a></strong>, a 6-day email course on the mistakes that silently break AI agents in production.</p></div><div><hr></div><h2>Images &amp; videos</h2><p>If not otherwise stated, all images and videos are created by the author.</p>]]></content:encoded></item><item><title><![CDATA[Building a Support Chatbot on Amazon Bedrock]]></title><description><![CDATA[One search or an AI agent that can search again? I tested both.]]></description><link>https://www.decodingai.com/p/agentic-rag-vs-single-search-amazon-bedrock</link><guid isPermaLink="false">https://www.decodingai.com/p/agentic-rag-vs-single-search-amazon-bedrock</guid><dc:creator><![CDATA[Marcelo Acosta Cavalero]]></dc:creator><pubDate>Sat, 31 Oct 2026 12:03:27 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!CfX5!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c252f61-ec79-4d7c-94a6-d141d99ead8e_1376x768.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><strong>Paul:</strong> Today, the spotlight is on Marcelo Acosta.</p><p>He&#8217;s an AWS-certified Solutions Architect with more than 30 years in technology, focused on data, machine learning, and practical AI systems. He writes <em><a href="https://buildwithaws.substack.com/">Build with AWS</a></em>, where he helps software and cloud engineers build the skills, judgment, and real-world experience needed to move into AI engineering.</p><p>Enough chitchat. Let&#8217;s get into it &#128064; &#8595;</p><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_!CfX5!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c252f61-ec79-4d7c-94a6-d141d99ead8e_1376x768.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!CfX5!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c252f61-ec79-4d7c-94a6-d141d99ead8e_1376x768.png 424w, https://substackcdn.com/image/fetch/$s_!CfX5!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c252f61-ec79-4d7c-94a6-d141d99ead8e_1376x768.png 848w, https://substackcdn.com/image/fetch/$s_!CfX5!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c252f61-ec79-4d7c-94a6-d141d99ead8e_1376x768.png 1272w, https://substackcdn.com/image/fetch/$s_!CfX5!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c252f61-ec79-4d7c-94a6-d141d99ead8e_1376x768.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!CfX5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c252f61-ec79-4d7c-94a6-d141d99ead8e_1376x768.png" width="1376" height="768" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3c252f61-ec79-4d7c-94a6-d141d99ead8e_1376x768.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:768,&quot;width&quot;:1376,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1224371,&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://www.decodingai.com/i/222155591?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c252f61-ec79-4d7c-94a6-d141d99ead8e_1376x768.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_!CfX5!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c252f61-ec79-4d7c-94a6-d141d99ead8e_1376x768.png 424w, https://substackcdn.com/image/fetch/$s_!CfX5!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c252f61-ec79-4d7c-94a6-d141d99ead8e_1376x768.png 848w, https://substackcdn.com/image/fetch/$s_!CfX5!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c252f61-ec79-4d7c-94a6-d141d99ead8e_1376x768.png 1272w, https://substackcdn.com/image/fetch/$s_!CfX5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c252f61-ec79-4d7c-94a6-d141d99ead8e_1376x768.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>A customer wants to return one item from a gift set. Your chatbot promises a refund. It found the refund rules, but missed the gift-return window.</p><p>The missing rule is already in your documents. So why did the chatbot miss it? And what would help it get the answer right? A broader first search might be enough. Or perhaps it needs an agent that can recognize what&#8217;s missing and look again.</p><p>In this article, I&#8217;ll show how I built and tested both versions of a RAG support chatbot on Amazon Bedrock for a fictional outdoor store. We&#8217;ll follow the path from policy documents to customer answers, then compare quality, response time, and model cost to see whether the extra searches pay off.</p><h2>The two options</h2><p>A question comes in, the application searches your documents, and the model uses the returned text to write an answer. That&#8217;s retrieval-augmented generation, or <strong>RAG</strong>. Each piece of returned text is a passage.</p><p>The choice is how much control to give the model over that search:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!PgGw!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03bd4f98-1b91-4ade-a53c-9502f044ef14_1920x764.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!PgGw!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03bd4f98-1b91-4ade-a53c-9502f044ef14_1920x764.png 424w, https://substackcdn.com/image/fetch/$s_!PgGw!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03bd4f98-1b91-4ade-a53c-9502f044ef14_1920x764.png 848w, https://substackcdn.com/image/fetch/$s_!PgGw!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03bd4f98-1b91-4ade-a53c-9502f044ef14_1920x764.png 1272w, https://substackcdn.com/image/fetch/$s_!PgGw!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03bd4f98-1b91-4ade-a53c-9502f044ef14_1920x764.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!PgGw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03bd4f98-1b91-4ade-a53c-9502f044ef14_1920x764.png" width="728" height="289.5" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/03bd4f98-1b91-4ade-a53c-9502f044ef14_1920x764.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:579,&quot;width&quot;:1456,&quot;resizeWidth&quot;:728,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Approach | What happens. One search with more passages | Retrieve nine passages, then write the answer.. Search agent | Retrieve three passages. The model can request up to two more\nsearches, with three passages each, before answering.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Approach | What happens. One search with more passages | Retrieve nine passages, then write the answer.. Search agent | Retrieve three passages. The model can request up to two more
searches, with three passages each, before answering." title="Approach | What happens. One search with more passages | Retrieve nine passages, then write the answer.. Search agent | Retrieve three passages. The model can request up to two more
searches, with three passages each, before answering." srcset="https://substackcdn.com/image/fetch/$s_!PgGw!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03bd4f98-1b91-4ade-a53c-9502f044ef14_1920x764.png 424w, https://substackcdn.com/image/fetch/$s_!PgGw!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03bd4f98-1b91-4ade-a53c-9502f044ef14_1920x764.png 848w, https://substackcdn.com/image/fetch/$s_!PgGw!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03bd4f98-1b91-4ade-a53c-9502f044ef14_1920x764.png 1272w, https://substackcdn.com/image/fetch/$s_!PgGw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03bd4f98-1b91-4ade-a53c-9502f044ef14_1920x764.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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 single search gives the model more material immediately. The agent can choose a follow-up query based on what it has read. For the gift question, it could ask specifically about the return window for gift recipients.</p><p>Both are reasonable ways to find a missing rule. I wanted to see which produced better customer answers.</p><h2>What I tested</h2><p>The store has 24 policy articles covering returns, gifts, shipping, warranties, and repairs. They add up to about 29 KB.</p><p>The documents live in <strong>S3</strong>. <strong>Bedrock Knowledge Bases</strong> splits them into passages of around 200 tokens. <strong>Titan Text Embeddings V2</strong> converts those passages into numerical representations, stored in <strong>S3 Vectors</strong>, so Bedrock can find text related to a question. <strong>GLM 5 on Bedrock</strong> writes the answers.</p><p>A Python script calls Bedrock&#8217;s <code>Retrieve</code> API for passages and <code>Converse</code> for answers. It also records the searches, responses, token counts, and API times.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!sg9z!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8d624258-b3af-4432-b96f-91882189dc10_2400x1929.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!sg9z!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8d624258-b3af-4432-b96f-91882189dc10_2400x1929.png 424w, https://substackcdn.com/image/fetch/$s_!sg9z!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8d624258-b3af-4432-b96f-91882189dc10_2400x1929.png 848w, https://substackcdn.com/image/fetch/$s_!sg9z!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8d624258-b3af-4432-b96f-91882189dc10_2400x1929.png 1272w, https://substackcdn.com/image/fetch/$s_!sg9z!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8d624258-b3af-4432-b96f-91882189dc10_2400x1929.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!sg9z!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8d624258-b3af-4432-b96f-91882189dc10_2400x1929.png" width="1456" height="1170" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8d624258-b3af-4432-b96f-91882189dc10_2400x1929.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1170,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Policy articles are indexed with Bedrock Knowledge Bases, Titan Text Embeddings V2, and S3 Vectors. A local Python runner calls Retrieve and GLM 5 through Converse, coordinating the single-search and agent flows.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Policy articles are indexed with Bedrock Knowledge Bases, Titan Text Embeddings V2, and S3 Vectors. A local Python runner calls Retrieve and GLM 5 through Converse, coordinating the single-search and agent flows." title="Policy articles are indexed with Bedrock Knowledge Bases, Titan Text Embeddings V2, and S3 Vectors. A local Python runner calls Retrieve and GLM 5 through Converse, coordinating the single-search and agent flows." srcset="https://substackcdn.com/image/fetch/$s_!sg9z!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8d624258-b3af-4432-b96f-91882189dc10_2400x1929.png 424w, https://substackcdn.com/image/fetch/$s_!sg9z!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8d624258-b3af-4432-b96f-91882189dc10_2400x1929.png 848w, https://substackcdn.com/image/fetch/$s_!sg9z!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8d624258-b3af-4432-b96f-91882189dc10_2400x1929.png 1272w, https://substackcdn.com/image/fetch/$s_!sg9z!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8d624258-b3af-4432-b96f-91882189dc10_2400x1929.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>I chose nine passages using eight practice questions: nine was the smallest setting tested that retrieved all the required policy text. One practice question resembled the gift-return case.</p><p>In a retrieval request, the setting is <code>numberOfResults</code>:</p><pre><code><code>response = client.retrieve(
    knowledgeBaseId=knowledge_base_id,
    retrievalQuery={"text": question},
    retrievalConfiguration={
        "vectorSearchConfiguration": {
            "numberOfResults": 9,
            "overrideSearchType": "SEMANTIC",
        }
    },
)</code></code></pre><p>I added three checks to the main comparison: answer from only three passages, ask the model to check that draft using the same passages, and give it every document. The entire collection fits in a prompt, so sending everything was worth trying.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!VWVe!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72a39ffd-f7c6-4834-a546-7b83d9ec17f8_2400x1360.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!VWVe!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72a39ffd-f7c6-4834-a546-7b83d9ec17f8_2400x1360.png 424w, https://substackcdn.com/image/fetch/$s_!VWVe!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72a39ffd-f7c6-4834-a546-7b83d9ec17f8_2400x1360.png 848w, https://substackcdn.com/image/fetch/$s_!VWVe!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72a39ffd-f7c6-4834-a546-7b83d9ec17f8_2400x1360.png 1272w, https://substackcdn.com/image/fetch/$s_!VWVe!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72a39ffd-f7c6-4834-a546-7b83d9ec17f8_2400x1360.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!VWVe!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72a39ffd-f7c6-4834-a546-7b83d9ec17f8_2400x1360.png" width="1456" height="825" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/72a39ffd-f7c6-4834-a546-7b83d9ec17f8_2400x1360.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:825,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;The main comparison is one search returning nine passages versus an agent allowed follow-up searches. Three additional checks use three passages, a second look at the draft, or all documents.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="The main comparison is one search returning nine passages versus an agent allowed follow-up searches. Three additional checks use three passages, a second look at the draft, or all documents." title="The main comparison is one search returning nine passages versus an agent allowed follow-up searches. Three additional checks use three passages, a second look at the draft, or all documents." srcset="https://substackcdn.com/image/fetch/$s_!VWVe!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72a39ffd-f7c6-4834-a546-7b83d9ec17f8_2400x1360.png 424w, https://substackcdn.com/image/fetch/$s_!VWVe!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72a39ffd-f7c6-4834-a546-7b83d9ec17f8_2400x1360.png 848w, https://substackcdn.com/image/fetch/$s_!VWVe!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72a39ffd-f7c6-4834-a546-7b83d9ec17f8_2400x1360.png 1272w, https://substackcdn.com/image/fetch/$s_!VWVe!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72a39ffd-f7c6-4834-a546-7b83d9ec17f8_2400x1360.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>All versions used the same model and answer instructions. When the agent exhausted its search allowance, the script put the collected passages into a fresh prompt for the final answer. This happened on nine questions, including the pickup example below.</p><h3>How the answers were scored</h3><p>I tested <strong>24 customer questions</strong>: eight direct lookups, eight combining policies, and eight asking for information the documents didn&#8217;t contain. Five versions produced <strong>120 answers</strong>.</p><p>An AI evaluator checked the answers against rules written before the run. To pass, an answer needed correct policies and calculations, evidence for its claims, and an acknowledgment of missing information. Code checked citation IDs and recorded costs and timings.</p><p>This was a custom evaluation workflow. I wanted to inspect each answer alongside the exact passages it received. Bedrock handled retrieval and generation; the scoring used the saved outputs.</p><h2>The single search gave the better result</h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!kb6_!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e984eb9-c485-491c-be0e-c2630e70441d_1920x1292.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!kb6_!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e984eb9-c485-491c-be0e-c2630e70441d_1920x1292.png 424w, https://substackcdn.com/image/fetch/$s_!kb6_!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e984eb9-c485-491c-be0e-c2630e70441d_1920x1292.png 848w, https://substackcdn.com/image/fetch/$s_!kb6_!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e984eb9-c485-491c-be0e-c2630e70441d_1920x1292.png 1272w, https://substackcdn.com/image/fetch/$s_!kb6_!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e984eb9-c485-491c-be0e-c2630e70441d_1920x1292.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!kb6_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e984eb9-c485-491c-be0e-c2630e70441d_1920x1292.png" width="1456" height="980" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9e984eb9-c485-491c-be0e-c2630e70441d_1920x1292.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:980,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Version | Answers that passed | Median API time | Model cost for 24 answers. One search, nine passages | 22 / 24 | 2.58 s | USD 0.0540. Search agent | 20 / 24 | 4.42 s | USD 0.0662. Three passages | 21 / 24 | 2.45 s | USD 0.0278. Check the first answer | 21 / 24 | 5.14 s | USD 0.0590. Every document | 22 / 24 | 2.54 s | USD 0.1577&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Version | Answers that passed | Median API time | Model cost for 24 answers. One search, nine passages | 22 / 24 | 2.58 s | USD 0.0540. Search agent | 20 / 24 | 4.42 s | USD 0.0662. Three passages | 21 / 24 | 2.45 s | USD 0.0278. Check the first answer | 21 / 24 | 5.14 s | USD 0.0590. Every document | 22 / 24 | 2.54 s | USD 0.1577" title="Version | Answers that passed | Median API time | Model cost for 24 answers. One search, nine passages | 22 / 24 | 2.58 s | USD 0.0540. Search agent | 20 / 24 | 4.42 s | USD 0.0662. Three passages | 21 / 24 | 2.45 s | USD 0.0278. Check the first answer | 21 / 24 | 5.14 s | USD 0.0590. Every document | 22 / 24 | 2.54 s | USD 0.1577" srcset="https://substackcdn.com/image/fetch/$s_!kb6_!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e984eb9-c485-491c-be0e-c2630e70441d_1920x1292.png 424w, https://substackcdn.com/image/fetch/$s_!kb6_!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e984eb9-c485-491c-be0e-c2630e70441d_1920x1292.png 848w, https://substackcdn.com/image/fetch/$s_!kb6_!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e984eb9-c485-491c-be0e-c2630e70441d_1920x1292.png 1272w, https://substackcdn.com/image/fetch/$s_!kb6_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e984eb9-c485-491c-be0e-c2630e70441d_1920x1292.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><em>API time covers search and generation. Model cost is estimated from input and output tokens; storage, embeddings, and vector operations are separate. The three-passage answer also supplies the draft for &#8220;Check the first answer,&#8221; whose cost includes both calls.</em></p><p>The agent cost <strong>23% more</strong> than the nine-passage search and took <strong>72% longer</strong>, while producing two fewer passing answers. Sending every document matched the nine-passage score at almost three times the model cost.</p><p>The agent did find the missing gift-return policy from the opening. The wider single search found it too. Other answers showed why successfully finding a rule was only part of the job.</p><h2>Finding the rule didn&#8217;t guarantee a correct answer</h2><p>The store offers a 60-day trial for hiking boots. For an order collected in a store, that clock starts when the customer collects it.</p><p>The three-passage search missed the collection rule. The nine-passage search found it and correctly used collection as the start date.</p><p>The agent found the rule too. Its final answer named both delivery and collection as the start date, then said it couldn&#8217;t establish which one applied.</p><p>The customer now has three answers to one question. None of the extra searching helps them choose.</p><p>This gives us a specific next step: test whether the answer consistently applies the collection rule when that rule is present. The search had already supplied what the model needed.</p><h2>More text also broke a correct refund</h2><p>A customer paid <strong>USD 120 for boots, plus USD 6 for delivery</strong>. The boots qualified for a return, with a USD 7 return-label fee. The refund should be:</p><p><strong>120 &#8722; 7 = USD 113.</strong></p><p>The three-passage answer got this right. Asking the model to check that draft kept it right. The nine-passage, agent, and all-document versions each returned <strong>USD 107</strong>. They deducted the separately paid delivery charge from the boot price again.</p><p>The extra text contained a second statement that delivery charges were nonrefundable. I suspect the repeated rule encouraged the extra subtraction; removing that passage and repeating the test would help check that explanation.</p><p>The arithmetic is correct for the expression the model chose: <strong>120 &#8722; 6 &#8722; 7 = 107</strong>. The error is the extra shipping deduction. A calculator given that expression would produce the same wrong refund.</p><p>I&#8217;d test whether asking for a separate breakdown of the item&#8217;s paid amount, refundable delivery, and deductions prevents the mix-up. Each amount needs support from the order and the policy. If the store already has a returns service, the chatbot could request a refund quote using the order, returned items, and return method. That service would apply the store&#8217;s maintained rules across orders; nobody would be coding &#8220;this answer is 113.&#8221;</p><h2>When an agent is worth trying</h2><p>An agent helps when the next useful search depends on what the previous result reveals. Imagine investigating a product fault: one document identifies a component, which leads to a service bulletin, which identifies affected product versions. The agent can follow that trail.</p><p>For a direct lookup such as &#8220;How much is a return label?&#8221;, one search may be enough. <a href="https://aws.amazon.com/blogs/machine-learning/agentic-retrieval-for-amazon-bedrock-managed-knowledge-base/">AWS&#8217;s guidance</a> recommends standard retrieval for direct lookups and agentic retrieval for more involved questions, including comparisons and searches across knowledge bases.</p><p>The agent also needs to recognize when searching cannot help. In this experiment, ten of its 25 extra searches went to questions whose answers weren&#8217;t in the documents. They produced no additional passing answers.</p><p>For example, a policy can explain how refunds are processed. A customer&#8217;s current refund status requires an order-status service. Giving the chatbot access to that service would address the missing information.</p><p>I&#8217;d test an agent on investigations like the product-fault example. For requests with a fixed sequence of lookups, application code can run the sequence directly. A chatbot can also route only the harder questions to an agent; the evaluation needs to show whether that routing improves the result.</p><h2>From this experiment to a production chatbot</h2><p>This experiment gives me a version to develop further. Before release, I&#8217;d test new customer questions, run them repeatedly, and have someone who knows the policies check a sample of the judgments. I&#8217;d compare errors, total customer waiting time, and operating cost against targets agreed before launch.</p><p>For recurring evaluations, I&#8217;d add <strong><a href="https://docs.aws.amazon.com/bedrock/latest/userguide/evaluation-kb.html">Bedrock RAG evaluations</a></strong>. Its bring-your-own-responses option accepts saved answers and retrieved passages from a custom application. That would let me keep this search setup and use managed evaluation to track two things separately: whether retrieval found the necessary information, and whether the answer used it correctly.</p><p>The application would verify the customer&#8217;s identity, order, payment, and return history before approving a refund. A statement in a test question becomes a lookup against a real system in production. For calculated answers, check both the selected amounts and the arithmetic. Code can also verify that each citation points to a passage the model received.</p><p>For an agent, <strong><a href="https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/evaluations.html">AgentCore Evaluations</a></strong> can assess the sequence of tool calls. <a href="https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/supported-frameworks-telemetry.html">Tracing with OpenTelemetry and CloudWatch</a> helps locate slow calls and failed searches. I&#8217;d set limits on searches and retries, protect customer data in logs, and provide a support handoff when the chatbot gets stuck.</p><p>Document access and freshness also need testing: the right customer must receive the right version of the right policy.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!A4PN!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0c0f2f88-6e6e-4273-a10b-0c029bb0b673_2880x2000.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!A4PN!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0c0f2f88-6e6e-4273-a10b-0c029bb0b673_2880x2000.png 424w, https://substackcdn.com/image/fetch/$s_!A4PN!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0c0f2f88-6e6e-4273-a10b-0c029bb0b673_2880x2000.png 848w, https://substackcdn.com/image/fetch/$s_!A4PN!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0c0f2f88-6e6e-4273-a10b-0c029bb0b673_2880x2000.png 1272w, https://substackcdn.com/image/fetch/$s_!A4PN!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0c0f2f88-6e6e-4273-a10b-0c029bb0b673_2880x2000.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!A4PN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0c0f2f88-6e6e-4273-a10b-0c029bb0b673_2880x2000.png" width="1456" height="1011" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0c0f2f88-6e6e-4273-a10b-0c029bb0b673_2880x2000.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1011,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Compare the single-search and agent answers, with their search queries, source passages, and scoring reasons.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Compare the single-search and agent answers, with their search queries, source passages, and scoring reasons." title="Compare the single-search and agent answers, with their search queries, source passages, and scoring reasons." srcset="https://substackcdn.com/image/fetch/$s_!A4PN!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0c0f2f88-6e6e-4273-a10b-0c029bb0b673_2880x2000.png 424w, https://substackcdn.com/image/fetch/$s_!A4PN!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0c0f2f88-6e6e-4273-a10b-0c029bb0b673_2880x2000.png 848w, https://substackcdn.com/image/fetch/$s_!A4PN!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0c0f2f88-6e6e-4273-a10b-0c029bb0b673_2880x2000.png 1272w, https://substackcdn.com/image/fetch/$s_!A4PN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0c0f2f88-6e6e-4273-a10b-0c029bb0b673_2880x2000.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><h2>My choice: keep the single search</h2><p><strong>For this chatbot, I&#8217;d keep the single search with nine passages.</strong> It produced more passing answers than the agent, cost less, and responded faster. My next test would check whether an explicit refund breakdown prevents the extra deduction, then compare the updated version on new customer questions.</p><p>I&#8217;d add an agent when its follow-up searches improve answers enough to meet the service&#8217;s quality, cost, and response-time targets. This agent gave me no reason to add that complexity yet.</p><p>The practical check is simple: <strong>when an answer fails, look at the passages it received. If the policy was missing, work on retrieval. If the policy was present, work on how the answer applies it.</strong> That tells you which part of the chatbot to fix before paying for another search.</p><p>See you next time!<br><a href="https://substack.com/@marckush">Marcelo</a></p><div><hr></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.decodingai.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">Learn AI engineering end-to-end, from idea to production, from the author of the best-selling LLM Engineer&#8217;s Handbook.</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><div><hr></div><div class="callout-block" data-callout="true"><h4>Whenever you&#8217;re ready, here is how I can help you</h4><p><em>Go from agent user to agent builder.</em> Master the foundations of AI agents and turn fragile demo code into reliable, production-ready systems with my course, <strong><a href="https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering">Agent Engineering: Building Multi-Agent Systems</a></strong> (made with Towards AI).</p><p>35 lessons. Pure foundations from scratch. 4 mini-projects. 2 production systems. A certificate and direct access to me &amp; industry experts in our Discord.</p><p>Built for software and data professionals transitioning into AI engineering. <em>Rated 5/5 with 300+ students. The first 7 lessons are free:</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering&quot;,&quot;text&quot;:&quot;Start here&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering"><span>Start here</span></a></p><p><em>Not ready to commit?</em> Start with our <strong><a href="https://email-course.towardsai.net/?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering">free Agent AI Engineering Guide</a></strong>, a 6-day email course on the mistakes that silently break AI agents in production.</p></div><div><hr></div><h2>Resources</h2><p><a href="https://github.com/marceloacosta/bedrock-rag-lab">GitHub repository</a> &#183; <a href="https://www.marcelops.com/bedrock-rag-lab/explorer/">Compare the answers</a></p><div><hr></div><h2>Images &amp; videos</h2><p>If not otherwise stated, all images and videos are created by the author.</p>]]></content:encoded></item><item><title><![CDATA[4 Key Decisions to Solidify Your Harness]]></title><description><![CDATA[How to tell a harness bug from a model bug.]]></description><link>https://www.decodingai.com/p/4-key-decisions-to-solidify-your</link><guid isPermaLink="false">https://www.decodingai.com/p/4-key-decisions-to-solidify-your</guid><dc:creator><![CDATA[Tejas Kumar]]></dc:creator><pubDate>Tue, 27 Oct 2026 12:01:12 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!zRzO!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd0733ee1-60ff-4ab9-a776-b65c18fd8473_1376x768.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><strong>Paul:</strong> Today, the spotlight is on Tejas Kumar.</p><p>He&#8217;s an AI Engineer at IBM in Berlin, the bestselling author of&nbsp;<em>Fluent React</em>, and the host of the&nbsp;<em>ConTejas Code</em>&nbsp;podcast. At&nbsp;<a href="https://tej.as">tej.as</a>, he digs into the mechanics of agent harnesses, bringing the practical, hype-free technical rigor we love to highlight here.</p><p>Enough chitchat. Let&#8217;s get into it &#128064; &#8595;</p><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_!zRzO!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd0733ee1-60ff-4ab9-a776-b65c18fd8473_1376x768.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!zRzO!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd0733ee1-60ff-4ab9-a776-b65c18fd8473_1376x768.png 424w, https://substackcdn.com/image/fetch/$s_!zRzO!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd0733ee1-60ff-4ab9-a776-b65c18fd8473_1376x768.png 848w, https://substackcdn.com/image/fetch/$s_!zRzO!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd0733ee1-60ff-4ab9-a776-b65c18fd8473_1376x768.png 1272w, https://substackcdn.com/image/fetch/$s_!zRzO!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd0733ee1-60ff-4ab9-a776-b65c18fd8473_1376x768.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!zRzO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd0733ee1-60ff-4ab9-a776-b65c18fd8473_1376x768.png" width="1376" height="768" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d0733ee1-60ff-4ab9-a776-b65c18fd8473_1376x768.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:768,&quot;width&quot;:1376,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1385662,&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://www.decodingai.com/i/219063871?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd0733ee1-60ff-4ab9-a776-b65c18fd8473_1376x768.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_!zRzO!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd0733ee1-60ff-4ab9-a776-b65c18fd8473_1376x768.png 424w, https://substackcdn.com/image/fetch/$s_!zRzO!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd0733ee1-60ff-4ab9-a776-b65c18fd8473_1376x768.png 848w, https://substackcdn.com/image/fetch/$s_!zRzO!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd0733ee1-60ff-4ab9-a776-b65c18fd8473_1376x768.png 1272w, https://substackcdn.com/image/fetch/$s_!zRzO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd0733ee1-60ff-4ab9-a776-b65c18fd8473_1376x768.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>Once your agent loop works, harness engineering keeps coming back to 4 decisions about who owns what:</p><ol><li><p><strong>Who decides the task is done,</strong></p></li><li><p><strong>who holds the keys,</strong></p></li><li><p><strong>who says stop, and</strong></p></li><li><p><strong>who&#8217;s to blame when a run goes wrong.</strong></p></li></ol><p>My answer to the first 3 is the harness, in code, with the model proposing and the harness deciding. The fourth is how you find out which of the two to fix.</p><p>In April I gave <a href="https://www.youtube.com/watch?v=C_GG5g38vLU">a talk at AI Engineer Europe</a> in London where I harnessed GPT-3.5 Turbo into upvoting a story on Hacker News without changing the prompt once, and it&#8217;s been watched over 275,000 times since. The code is public, one branch per step. Since then 2 things have happened to that code that the talk never covered: a developer fixed a bug that made my agent upvote 2 stories when I&#8217;d asked for 1, and when I reread the code for this post, I found that my harness could be talked into typing a Hacker News password into a page that wasn&#8217;t Hacker News.</p><p>Now, to be fair, it&#8217;s because I made it to serve a bigger purpose: teach people &#8220;baby&#8217;s first harness&#8221; in ~20 minutes, and it accomplished its mission. Still, there&#8217;s a lot we could do to make this a lot more robust.</p><p>Paul has spent this series in his <a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course">course</a> building a coding agent&#8217;s harness from a bare loop up through <a href="https://www.decodingai.com/p/building-a-coding-agent-from-scratch-system-design">the harness architecture</a> and <a href="https://www.decodingai.com/p/run-coding-agents-safely">a sandbox</a>, so I won&#8217;t rebuild the loop here. Let&#8217;s pick up after it, at the decisions a framework can&#8217;t make for you. We&#8217;ll use those 2 bugs as the examples.</p><h4>TL;DR</h4><ul><li><p>A model saying it&#8217;s done is a <em>claim</em>. Let the harness decide when a task is done by reading the world before and after, from somewhere the agent can&#8217;t write to.</p></li><li><p>Keep secrets, fragile deterministic steps and irreversible actions in the harness and pin where they&#8217;re allowed to go by parsing URLs instead of searching them.</p></li><li><p>Split guardrails into budgets, which end the run, and policies, which refuse 1 action and let the model carry on.</p></li><li><p>Before you fix a failed run, find the first step that went wrong and replay it: wrong context means a harness bug, and right context that fails some of the time means you measure the model.</p></li><li><p>Every new piece of code here runs offline with tests, on the <a href="https://github.com/TejasQ/basically-ai-harness/tree/after-the-loop">after-the-loop branch</a> of the demo repo. The snippets below are trimmed.</p></li></ul><h2>The Demo</h2><div class="native-video-embed" data-component-name="VideoPlaceholder" data-attrs="{&quot;mediaUploadId&quot;:&quot;7483616e-fb28-43c6-a2f4-268733193c0e&quot;,&quot;duration&quot;:null}"></div><p>The agent&#8217;s job is to open <a href="https://news.ycombinator.com">Hacker News</a> and upvote the highest-ranked story it hasn&#8217;t voted on yet, driving a real browser through <a href="https://playwright.dev">Playwright</a>. The bare loop hit a login page and reported success anyway. Guardrails capped the iterations and trimmed the context, a verifier read the tool trace and turned the lie into an honest failure. From there, a login handler let the harness sign in so the password never went near the prompt. GPT-3.5 Turbo succeeded in 6 iterations with the same prompt. The <a href="https://tej.as/blog/what-is-an-agent-harness">full write-up is on my site</a>, and everything below builds on its last branch.</p><h3>1. Let the harness decide when the task is done</h3><p>In June, a developer named <a href="https://github.com/jonjia">jonjia</a> opened <a href="https://github.com/TejasQ/basically-ai-harness/pull/2">a pull request</a> called &#8220;Fix duplicate upvotes after login redirect&#8221; that addressed this directly. When you&#8217;re logged out, Hacker News sends an upvote click to /vote?id=NNN&amp;how=up&amp;goto=news, which shows a login form. My harness logged in right there. The thing is, when you log in from that URL, it completes the vote. The harness&#8217;s success check only recognized an upvote click that landed back on the front page, so it didn&#8217;t count <em>this one</em>, and it told the model, word for word, &#8220;Authentication completed by harness. You are now logged in. Navigate back to <a href="https://news.ycombinator.com/">https://news.ycombinator.com</a> and complete your upvote task.&#8221;</p><p>So the model did exactly that, and since the top story was already voted on by then, it upvoted the next one. Read the code from before the fix, and you can see how the run ends: the loop stops with &#8220;Successfully upvoted&#8221;, my verifier finds an upvote click that landed on the front page and passes the run, and 2 stories have been upvoted for a task that asked for 1. </p><blockquote><p><em>My verifier answered the question I&#8217;d asked it, &#8220;did an upvote click happen?&#8221;, while the task was asking something else: &#8220;is exactly the right story upvoted now, and nothing else?&#8221;</em></p></blockquote><p>That&#8217;s the gap between the 3 things a harness can trust:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Y4_v!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb390fe69-2518-4a34-8ef6-fc9ab885c316_677x227.png 424w, https://substackcdn.com/image/fetch/$s_!Y4_v!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb390fe69-2518-4a34-8ef6-fc9ab885c316_677x227.png 848w, https://substackcdn.com/image/fetch/$s_!Y4_v!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb390fe69-2518-4a34-8ef6-fc9ab885c316_677x227.png 1272w, https://substackcdn.com/image/fetch/$s_!Y4_v!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb390fe69-2518-4a34-8ef6-fc9ab885c316_677x227.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!Y4_v!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb390fe69-2518-4a34-8ef6-fc9ab885c316_677x227.png" width="728" height="244.10044313146233" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b390fe69-2518-4a34-8ef6-fc9ab885c316_677x227.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:227,&quot;width&quot;:677,&quot;resizeWidth&quot;:728,&quot;bytes&quot;:42408,&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://www.decodingai.com/i/219063871?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb390fe69-2518-4a34-8ef6-fc9ab885c316_677x227.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_!Y4_v!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb390fe69-2518-4a34-8ef6-fc9ab885c316_677x227.png 424w, https://substackcdn.com/image/fetch/$s_!Y4_v!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb390fe69-2518-4a34-8ef6-fc9ab885c316_677x227.png 848w, https://substackcdn.com/image/fetch/$s_!Y4_v!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb390fe69-2518-4a34-8ef6-fc9ab885c316_677x227.png 1272w, https://substackcdn.com/image/fetch/$s_!Y4_v!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb390fe69-2518-4a34-8ef6-fc9ab885c316_677x227.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>The trace is a real step up from the model&#8217;s word, and it&#8217;s still a proxy for what you care about. Sierra&#8217;s <a href="https://arxiv.org/abs/2406.12045">&#964;-bench</a>, a benchmark for customer service agents, grades a run the bottom-row way: it &#8220;compares the database state at the end of a conversation with the annotated goal state&#8221;. Anthropic ran into the top row in <a href="https://www.anthropic.com/engineering/effective-harnesses-for-long-running-agents">their harness for long-running coding agents</a>, where they saw &#8220;Claude&#8217;s tendency to mark a feature as complete without proper testing.&#8221; Asking the model whether it&#8217;s really done doesn&#8217;t close the gap either. <a href="https://arxiv.org/abs/2310.01798">Huang and colleagues</a> found that models struggle to correct their own reasoning without external feedback, and sometimes do worse after trying.</p><p>Here&#8217;s the verifier from the branch, written from the task:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;javascript&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-javascript">export function verifyOneUpvote(before: Snapshot, after: Snapshot): Verdict {

  const target = [...before]

    .filter(([, story]) =&gt; !story.voted)

    .sort(([, a], [, b]) =&gt; a.rank - b.rank)[0]?.[0];

  if (!target) return { status: &#8220;stop&#8221;, reason: &#8220;Every story on the page was already voted on&#8221; };

  const newVotes = [...after]

    .filter(([id, story]) =&gt; story.voted &amp;&amp; before.get(id)?.voted === false)

    .map(([id]) =&gt; id);

  if (newVotes.length &gt; 1) return { status: &#8220;stop&#8221;, reason: `Expected 1 new vote, found ${newVotes.length}: ${newVotes.join(&#8221;, &#8220;)}` };

  if (newVotes.length === 1) {

    return newVotes[0] === target

      ? { status: &#8220;done&#8221;, reason: `Story ${target} is now voted on` }

      : { status: &#8220;stop&#8221;, reason: `Voted on story ${newVotes[0]}, expected ${target}` };

  }

  if (!after.has(target)) return { status: &#8220;unknown&#8221;, reason: `Story ${target} left the front page, so the vote can&#8217;t be checked` };

  return { status: &#8220;retry&#8221;, reason: `Story ${target} isn&#8217;t voted on yet` };

}</code></pre></div><p>The branch has a test that runs the PR #2 run through both verifiers: the trace verifier passes it, and this one stops it with &#8220;Expected 1 new vote, found 2: 111, 222&#8221;. Three rules go with it:</p><ol><li><p><strong>Take the before snapshot once per task, not once per attempt.</strong> A retry that reads a fresh &#8220;before&#8221; counts the last attempt&#8217;s side effect as part of the starting state, and then happily does the task again.</p></li><li><p><strong>Read the world through the harness, and keep the check where the agent can&#8217;t write.</strong> In the branch, snapshot is a function the harness owns, and no tool the agent has can reach it. A stronger model doesn&#8217;t make this go away: <a href="https://metr.org/blog/2025-06-05-recent-reward-hacking/">METR reported</a> recent frontier models &#8220;attempting (often successfully) to get a higher score by modifying the tests or scoring code&#8221;.</p></li><li><p><strong>Give the verifier 4 answers.</strong> done ends the task, retry means nothing happened yet so another attempt is safe, stop means something happened that another attempt would make worse, and unknown means the check can&#8217;t tell. A verifier that can only say yes or no has to round &#8220;I can&#8217;t tell&#8221; one way or the other, and whichever way it rounds, you find out in production.</p></li></ol><p>LangChain made the same move from another direction when they <a href="https://www.langchain.com/blog/improving-deep-agents-with-harness-engineering">took their coding agent from 52.8% to 66.5% on Terminal Bench 2.0</a> without changing the model: one of their changes was middleware that catches the agent on its way out and reminds it to check its work against the task, so the harness decides whether the run gets to end.</p><blockquote><p><em>Pro tip: write the verifier from the task, not the trace. &#8220;Upvote a story&#8221; means exactly 1 new vote, on the right story, and nothing else.</em></p></blockquote><h3>2. Keep the keys in the harness, and pin where they go</h3><p>Branch 4&#8217;s login handler does the thing I still believe in: the password lives in environment variables the model never sees, and the harness types it in. Here&#8217;s how it decides it&#8217;s looking at a login page:</p><p><code>const isLoginPage = currentUrl.includes(&#8221;login&#8221;) || currentUrl.includes(&#8221;vote&#8221;);</code></p><p>Now put that next to the tool registry. browser_navigate accepts any URL and browser_get_text reads any page, so all it takes is a page, or a story title, that talks the model into visiting https://some-other-site.example/login, and if that page has fields named acct and pw, my harness fills in the credentials from its environment and presses submit. <em><strong>The model never saw the password, and it still got to decide where the password went.</strong></em> I haven&#8217;t seen this happen, and it would take a page built for it, but nothing in the code stops it, and a test in the branch shows the handler typing the password into https://evil.example/login. Simon Willison calls this combination <a href="https://simonwillison.net/2025/Jun/16/the-lethal-trifecta/">the lethal trifecta</a>: &#8220;private data, untrusted content, and external communication&#8221; in one agent, and my demo has all 3 in about 750 lines. OWASP files it under <a href="https://genai.owasp.org/llmrisk/llm062025-excessive-agency/">Excessive Agency</a>: a tool that can go anywhere, for a task that needs 1 site.</p><p>The fix takes 3 changes, and none of them touches the prompt:</p><ol><li><p><strong>Log in before the run starts.</strong> Playwright can <a href="https://playwright.dev/docs/auth">save an authenticated browser state and load it into a new context</a>, so the agent starts signed in and never meets a login form. Playwright&#8217;s docs warn that the file &#8220;may contain sensitive cookies and headers that could be used to impersonate you&#8221;, so it&#8217;s a secret too, and it stays with the harness.</p></li><li><p><strong>When the harness has to act mid-run, parse the URL and compare origins.</strong> Searching a string for &#8220;login&#8221; matches evil.example/login, news.ycombinator.com.evil.example/login and evil.example/?next=news.ycombinator.com/login, and a parsed URL matches none of them:</p></li></ol><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;javascript&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-javascript">export const HN = new URL(&#8221;https://news.ycombinator.com&#8221;);

const AUTH_PATHS = new Set([&#8221;/login&#8221;, &#8220;/vote&#8221;]);

export function needsHarnessLogin(rawUrl: string): boolean {

  if (!URL.canParse(rawUrl)) return false;

  const url = new URL(rawUrl);

  return url.origin === HN.origin &amp;&amp; AUTH_PATHS.has(url.pathname);

}</code></pre></div><ol start="3"><li><p><strong>Give the model a narrower tool.</strong> The branch swaps browser_navigate(url) for hn_open(path), which resolves the path against Hacker News and then checks where it actually points, because //evil.example/login looks like a path and resolves to another site. Anthropic&#8217;s advice for this is to <a href="https://www.anthropic.com/engineering/building-effective-agents">&#8220;poka-yoke your tools&#8221;</a>: &#8220;Change the arguments so that it is harder to make mistakes.&#8221;</p></li></ol><p>The paper on <a href="https://arxiv.org/abs/2506.08837">design patterns for securing LLM agents against prompt injections</a> states the rule behind all 3 as plainly as I&#8217;ve seen it: &#8220;once an LLM agent has ingested untrusted input, it must be constrained so that it is impossible for that input to trigger any consequential actions&#8221;. Typing a password into a form is a consequential action, and so is an upvote.</p><p>The harness holds a second kind of key, too. If your agent calls an API with side effects, like issuing a refund, and your harness retries, <a href="https://docs.stripe.com/api/idempotent_requests">idempotency keys</a> are how Stripe lets you retry &#8220;without accidentally performing the same operation twice&#8221;. The harness should make that key once per task and send the same one on every attempt, because if the model makes it up, a retry can make up a new one, and the API has no way to know it&#8217;s the same refund. Hacker News has no idempotency keys, which is why the task-level snapshot from decision 1 does that job here.</p><blockquote><p><em>Pro tip: moving a secret out of the prompt is half of it. Also pin where the harness is allowed to use it, with a check that nothing the model reads can steer.</em></p></blockquote><h3>3. Split guardrails into budgets and policies</h3><p>Paul wrote earlier in this series that <a href="https://www.decodingai.com/p/building-a-coding-agent-from-scratch-system-design">&#8220;the permission layer is the most important guardrail&#8221;</a>, the thing that asks you before risky actions, and for a coding agent with you sitting next to it I agree. Plenty of agents run with nobody there to ask, like my Hacker News one, so the harness has to answer by itself, and it helps to split guardrails into 2 kinds:</p><ul><li><p><strong>Budgets</strong> (iterations, tokens, money, wall clock time) end the run, with a reason the harness can route: retry, escalate or report.</p></li><li><p><strong>Policies</strong> (this action, with these arguments, isn&#8217;t allowed in this task) refuse 1 action and hand the refusal back to the model as the tool result, so it can pick something else.</p></li></ul><p>My demo only had budgets, and when I went back to them for this post, I found one that can&#8217;t fire. The guardrails include maxMessages(50), and the loop trims the context to 20 messages right before the guardrails run, so the count that guardrail sees never gets past 20. I showed that guardrail on stage and wrote about it, and it has never once been able to stop anything. Wild. The same trimmer keeps the last 18 messages whatever they are, so it can keep a tool result and drop the assistant message that asked for it, and OpenAI&#8217;s API rejects exactly that with <a href="https://github.com/openai/openai-agents-python/issues/873">&#8220;messages with role &#8216;tool&#8217; must be a response to a preceding message with &#8216;tool_calls&#8217;&#8221;</a> (their spelling). Neither one broke the demo on stage, which finished in 6 iterations, and the branch now has a test that shows each of them. <em><strong>Every guardrail gets a test that drives it past its limit through the real loop, and every trimmer cuts in whole turns.</strong></em></p><p>The cheapest policy I didn&#8217;t write came straight from the task: &#8220;upvote a story&#8221; allows 1 upvote, so the harness should refuse a second, and that alone would have stopped the PR #2 run before the second vote.</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;typescript&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-typescript">beforeTool(tool: string, args: Record&lt;string, unknown&gt;): GuardDecision {

  if (policy.classify(tool, args) !== &#8220;irreversible&#8221;) return { kind: &#8220;run&#8221; };

  if (irreversible &gt;= policy.maxIrreversible) {

    return {

      kind: &#8220;refuse&#8221;,

      tellModel: `Refused: this task allows ${policy.maxIrreversible} such action and it has been used. Check the page and report what happened.`,

    };

  }

  irreversible++; // count the attempt, not the success

  return { kind: &#8220;run&#8221; };

}</code></pre></div><p>It counts the attempt and not the success, because in PR #2 the click &#8220;failed&#8221; into a login page and the vote landed anyway. And it has to classify a generic browser_click by looking inside its arguments, since the same tool clicks a harmless &#8220;More&#8221; link and casts a public vote. A dedicated hn_upvote(storyId) tool would let the harness see the consequence by name, which is one more reason to give the model narrow tools.</p><p>A refusal only helps if the model can do something with it. Anthropic&#8217;s <a href="https://www.anthropic.com/engineering/writing-tools-for-agents">guide to writing tools for agents</a> says error responses should &#8220;clearly communicate specific and actionable improvements, rather than opaque error codes or tracebacks&#8221;, and a refusal is an error response. For the order in which policies apply, Claude Code&#8217;s permission rules are a good model: they&#8217;re <a href="https://code.claude.com/docs/en/permissions">&#8220;evaluated in order: deny, then ask, then allow&#8221;</a> and the first match wins, so a narrow &#8220;yes&#8221; can&#8217;t undo a broad &#8220;no&#8221;.</p><p>For budgets, take the number from your runs. My demo succeeded in 6 iterations on stage, and the repo caps it at 15, and the way to pick that number is to run the task a few dozen times, look at how many iterations the successful runs took, set the cap a little above the slowest one, and then watch how often it fires, because a cap that fires on runs that were about to succeed is making your agent worse.</p><blockquote><p><em>Pro tip: save ending the run for budgets, and make every policy refusal a tool result the model can act on.</em></p></blockquote><h3>4. Find the first wrong step, then replay it</h3><p>When a run fails, you have to decide what to fix, and finding the cause is harder than it looks. The <a href="https://arxiv.org/abs/2505.00212">Who&amp;When study</a> (ICML 2025) tested automated ways to find the cause of failures in logs from 127 multi-agent systems, and the best method named the responsible agent 53.5% of the time and the decisive step 14.2% of the time. Meanwhile, both sides moved results: LangChain&#8217;s jump came from the harness alone, and Paul&nbsp;<a href="https://www.decodingai.com/p/evaluate-ai-agents-benchmarks-regression-tests">built a benchmark for his own agent</a>&nbsp;where the smaller model won. Here&#8217;s the order I&#8217;d go in:</p><ol><li><p><strong>Find the first step that went wrong, not the last.</strong> In PR #2, the last wrong step was the second upvote, and the first was my harness telling the model to &#8220;complete your upvote task&#8221; after the vote had already landed.</p></li><li><p><strong>Look at exactly what the model saw at that step.</strong> My demo can&#8217;t do this, because it records how many messages the model saw and not the messages. The branch wraps the completion call and keeps a copy of every request, and it has to be a copy, since the loop keeps pushing into the same array after the call:</p></li></ol><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;javascript&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-javascript">export function recording(complete: Complete, log: RecordedCall[]): Complete {

  return async (model, messages, tools) =&gt; {

    const reply = await complete(model, messages, tools);

    log.push({ model, messages: structuredClone(messages), tools, reply });

    return reply;

  };

}</code></pre></div><ol start="3"><li><p><strong>Ask whether a careful person with that exact context would have done better.</strong> If they wouldn&#8217;t have, because something was missing, stale, trimmed away or misleading, it&#8217;s the harness. In PR #2, the model followed the harness&#8217;s instructions to the letter, so that one&#8217;s on me. On branch 0, the last tool result the model got said it was now on a /vote URL and not back on the front page, and it had tools to check, and it claimed success anyway, so the lie is the model&#8217;s, and believing it was the harness&#8217;s.</p></li><li><p><strong>If the context was right, replay that step.</strong> The branch&#8217;s replay sends the recorded request to your model and to a stronger one, 10 or 20 times each, and counts the wrong answers. Wrong every time on every model usually means the task or the tool is confusing, which is the harness again. Wrong only on the weaker model is the model. Wrong some of the time is a distribution, and &#964;-bench&#8217;s pass^k is the number to watch there: it asks whether an agent succeeds on all k tries of the same task, and GPT-4o came in under 25% at k = 8 on the retail tasks, so 1 green run tells you very little.</p></li><li><p><strong>Fix it once, then keep the run.</strong> Add the failing case to your evals so it can&#8217;t come back quietly.</p></li></ol><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!I9vE!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F941e3217-4800-462c-b87e-abdde06b5755_678x365.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!I9vE!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F941e3217-4800-462c-b87e-abdde06b5755_678x365.png 424w, https://substackcdn.com/image/fetch/$s_!I9vE!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F941e3217-4800-462c-b87e-abdde06b5755_678x365.png 848w, https://substackcdn.com/image/fetch/$s_!I9vE!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F941e3217-4800-462c-b87e-abdde06b5755_678x365.png 1272w, https://substackcdn.com/image/fetch/$s_!I9vE!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F941e3217-4800-462c-b87e-abdde06b5755_678x365.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!I9vE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F941e3217-4800-462c-b87e-abdde06b5755_678x365.png" width="728" height="391.9174041297935" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/941e3217-4800-462c-b87e-abdde06b5755_678x365.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:365,&quot;width&quot;:678,&quot;resizeWidth&quot;:728,&quot;bytes&quot;:57797,&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://www.decodingai.com/i/219063871?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F941e3217-4800-462c-b87e-abdde06b5755_678x365.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_!I9vE!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F941e3217-4800-462c-b87e-abdde06b5755_678x365.png 424w, https://substackcdn.com/image/fetch/$s_!I9vE!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F941e3217-4800-462c-b87e-abdde06b5755_678x365.png 848w, https://substackcdn.com/image/fetch/$s_!I9vE!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F941e3217-4800-462c-b87e-abdde06b5755_678x365.png 1272w, https://substackcdn.com/image/fetch/$s_!I9vE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F941e3217-4800-462c-b87e-abdde06b5755_678x365.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><blockquote><p><em>Pro tip: if a failure reproduces every time with the same inputs, look at the harness first, and if it comes and goes, measure it before you blame anything.</em></p></blockquote><h2>What I still don&#8217;t know</h2><p>Everything here leans on the world having a source of truth the harness can read. Hacker News has one, a database has one, and a test suite is one, but a lot of agent work doesn&#8217;t: a summary, a research answer, a plan. The usual answer there is a model grading the output, which is a model checking a model, and I don&#8217;t know yet how to make that as trustworthy as reading a database.</p><p>In the talk, I said I hope 2027 is the year of dynamic harnesses, where an agent builds the harness for a task before it starts. I still want that, and writing this made me wonder who writes the verifier in that world, since the whole point of decision 1 is that the agent can&#8217;t touch it. If you&#8217;ve got either of these working, I&#8217;d love to hear how.</p><h2>Takeaways</h2><ul><li><p><strong>Let the harness decide done</strong>, from the world before and after, with 4 possible answers, from somewhere the agent can&#8217;t write.</p></li><li><p><strong>Keep the keys in the harness</strong>, and pin where they go by parsing URLs, not searching them.</p></li><li><p><strong>Budgets end runs and policies refuse actions</strong>, and every guardrail gets a test that makes it fire.</p></li><li><p><strong>Find the first wrong step and replay it</strong> before you decide whether to fix the harness or change the model.</p></li></ul><p>If you want to go further:</p><ul><li><p>Watch the talk: <a href="https://www.youtube.com/watch?v=C_GG5g38vLU">Harnesses in AI: A Deep Dive</a></p></li><li><p>Read the demo write-up: <a href="https://tej.as/blog/what-is-an-agent-harness">What Is an Agent Harness?</a></p></li><li><p>Run the code: the <a href="https://github.com/TejasQ/basically-ai-harness/tree/after-the-loop">after-the-loop branch</a>, then npm test</p></li><li><p>Build one live with me: a <a href="https://maven.com/p/799bd8/what-is-an-agent-harness-build-one-from-scratch">free Maven Lightning Lesson on November 18</a></p></li><li><p>Bring it to your team: <a href="https://tej.as/workshops#ai-agents">my workshop on building agent harnesses</a></p></li></ul><p><em>&#8220;Till next time<br></em><a href="https://substack.com/@tejasq">Tejas Kumar</a></p><div><hr></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.decodingai.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">Learn AI engineering end-to-end, from idea to production, from the author of the best-selling LLM Engineer&#8217;s Handbook.</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><div><hr></div><p><em>Enjoyed the article? The most sincere compliment is to restack this for your readers.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://www.decodingai.com/p/4-key-decisions-to-solidify-your?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;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://www.decodingai.com/p/4-key-decisions-to-solidify-your?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p><div><hr></div><div class="callout-block" data-callout="true"><h4>Whenever you&#8217;re ready, here is how I can help you</h4><p><em>Go from agent user to agent builder.</em> Master the foundations of AI agents and turn fragile demo code into reliable, production-ready systems with my course, <strong><a href="https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering">Agent Engineering: Building Multi-Agent Systems</a></strong> (made with Towards AI).</p><p>35 lessons. Pure foundations from scratch. 4 mini-projects. 2 production systems. A certificate and direct access to me &amp; industry experts in our Discord.</p><p>Built for software and data professionals transitioning into AI engineering. <em>Rated 5/5 with 300+ students. The first 7 lessons are free:</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering&quot;,&quot;text&quot;:&quot;Start here&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering"><span>Start here</span></a></p><p><em>Not ready to commit?</em> Start with our <strong><a href="https://email-course.towardsai.net/?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering">free Agent AI Engineering Guide</a></strong>, a 6-day email course on the mistakes that silently break AI agents in production.</p></div><div><hr></div><h2>Images &amp; videos</h2><p>If not otherwise stated, all images and videos are created by the author.</p>]]></content:encoded></item><item><title><![CDATA[Build an LLM Wiki From First Principles]]></title><description><![CDATA[One token-efficient memory for your repos, company docs, articles, and videos.]]></description><link>https://www.decodingai.com/p/build-llm-wiki-first-principles</link><guid isPermaLink="false">https://www.decodingai.com/p/build-llm-wiki-first-principles</guid><dc:creator><![CDATA[Paul Iusztin]]></dc:creator><pubDate>Tue, 20 Oct 2026 05:01:00 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!06f1!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0c9ca844-0075-4e9d-b01a-a7b15173b40b_1376x768.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_!06f1!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0c9ca844-0075-4e9d-b01a-a7b15173b40b_1376x768.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!06f1!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0c9ca844-0075-4e9d-b01a-a7b15173b40b_1376x768.png 424w, https://substackcdn.com/image/fetch/$s_!06f1!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0c9ca844-0075-4e9d-b01a-a7b15173b40b_1376x768.png 848w, https://substackcdn.com/image/fetch/$s_!06f1!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0c9ca844-0075-4e9d-b01a-a7b15173b40b_1376x768.png 1272w, https://substackcdn.com/image/fetch/$s_!06f1!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0c9ca844-0075-4e9d-b01a-a7b15173b40b_1376x768.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!06f1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0c9ca844-0075-4e9d-b01a-a7b15173b40b_1376x768.png" width="1376" height="768" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0c9ca844-0075-4e9d-b01a-a7b15173b40b_1376x768.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:768,&quot;width&quot;:1376,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Read every page once. Remember where it belongs.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Read every page once. Remember where it belongs." title="Read every page once. Remember where it belongs." srcset="https://substackcdn.com/image/fetch/$s_!06f1!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0c9ca844-0075-4e9d-b01a-a7b15173b40b_1376x768.png 424w, https://substackcdn.com/image/fetch/$s_!06f1!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0c9ca844-0075-4e9d-b01a-a7b15173b40b_1376x768.png 848w, https://substackcdn.com/image/fetch/$s_!06f1!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0c9ca844-0075-4e9d-b01a-a7b15173b40b_1376x768.png 1272w, https://substackcdn.com/image/fetch/$s_!06f1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0c9ca844-0075-4e9d-b01a-a7b15173b40b_1376x768.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>When I was researching about harness engineering I asked Claude Code to compare 7 large repos: Claude Code&#8217;s leaked source, OpenCode, Pi and a bunch more. Directly pointing Claude Code to these repos was a mess, generating superficial answers.</p><p>The standard fix is to ask the agent to compile notes for each repo and then compare them, which works, but it&#8217;s cumbersome to manage. Especially if you want to repeat the process. On top of that, what if you want to mix your research with other company docs, articles, papers and YouTube videos?</p><p>That&#8217;s where an LLM wiki kicks in. It&#8217;s the best way I&#8217;ve found to merge all my research into one token-efficient memory layer that I can easily pass to my agent to anchor its reasoning in it.</p><p>The method is popularized by Andrej Karpathy as a pattern to give agents memory built only from Markdown files. He calls the wiki <em><a href="https://gist.github.com/karpathy/442a6bf555914893e9891c11519de94f">&#8220;a persistent, compounding artifact.&#8221;</a></em> I use mine the opposite way: one wiki per project, deleted when the project ends.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!yIAj!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8a87008-0156-4440-a7d2-5baa9715a7b6_1200x501.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!yIAj!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8a87008-0156-4440-a7d2-5baa9715a7b6_1200x501.png 424w, https://substackcdn.com/image/fetch/$s_!yIAj!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8a87008-0156-4440-a7d2-5baa9715a7b6_1200x501.png 848w, https://substackcdn.com/image/fetch/$s_!yIAj!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8a87008-0156-4440-a7d2-5baa9715a7b6_1200x501.png 1272w, https://substackcdn.com/image/fetch/$s_!yIAj!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8a87008-0156-4440-a7d2-5baa9715a7b6_1200x501.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!yIAj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8a87008-0156-4440-a7d2-5baa9715a7b6_1200x501.png" width="1200" height="501" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d8a87008-0156-4440-a7d2-5baa9715a7b6_1200x501.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:501,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;LLM wiki architecture: sources ingested into an immutable raw layer, transformed into the wiki, queried by an agent.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="LLM wiki architecture: sources ingested into an immutable raw layer, transformed into the wiki, queried by an agent." title="LLM wiki architecture: sources ingested into an immutable raw layer, transformed into the wiki, queried by an agent." srcset="https://substackcdn.com/image/fetch/$s_!yIAj!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8a87008-0156-4440-a7d2-5baa9715a7b6_1200x501.png 424w, https://substackcdn.com/image/fetch/$s_!yIAj!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8a87008-0156-4440-a7d2-5baa9715a7b6_1200x501.png 848w, https://substackcdn.com/image/fetch/$s_!yIAj!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8a87008-0156-4440-a7d2-5baa9715a7b6_1200x501.png 1272w, https://substackcdn.com/image/fetch/$s_!yIAj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8a87008-0156-4440-a7d2-5baa9715a7b6_1200x501.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>You can use it as memory for coding, research, journaling, education, and brainstorming. The only issue is that it eats a lot of tokens unless you know how it works inside to customize it to your needs. </p><p>In my <a href="https://www.decodingai.com/p/llm-wiki-agent-memory">previous piece</a>, I showed how I run it on top of my Second Brain. </p><p>In this article, I'll show you how to build an LLM wiki from first principles in 3 exercises, each upgrading the same skill. Available in <a href="https://github.com/decodingai-magazine/llm-wiki-workshop">this GitHub repo</a>:</p><ul><li><p><strong>Exercise 1, vanilla:</strong> ingest, index, and query local files.</p></li><li><p><strong>Exercise 2, ingest:</strong> add custom sources.</p></li><li><p><strong>Exercise 3, interactive:</strong> learn continually from your questions.</p></li></ul><p><em>First, a quick word from our sponsor</em> &#8595;</p><div class="callout-block" data-callout="true"><h2><a href="https://inngest.link/dai-nl">Build for the long run (Sponsored)</a></h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://inngest.link/dai-nl" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!0XGX!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F32e8504e-caa6-4e9b-8773-27507e579eb6_2190x1061.png 424w, https://substackcdn.com/image/fetch/$s_!0XGX!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F32e8504e-caa6-4e9b-8773-27507e579eb6_2190x1061.png 848w, https://substackcdn.com/image/fetch/$s_!0XGX!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F32e8504e-caa6-4e9b-8773-27507e579eb6_2190x1061.png 1272w, https://substackcdn.com/image/fetch/$s_!0XGX!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F32e8504e-caa6-4e9b-8773-27507e579eb6_2190x1061.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!0XGX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F32e8504e-caa6-4e9b-8773-27507e579eb6_2190x1061.png" width="1456" height="705" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/32e8504e-caa6-4e9b-8773-27507e579eb6_2190x1061.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:705,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:5699007,&quot;alt&quot;:&quot;If your code runs for minutes or days, it won't run straight through. Wrap functions in steps that automatically retry, pause, and fan out. Scale instantly, without thinking about infra.&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:&quot;https://inngest.link/dai-nl&quot;,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.decodingai.com/i/220571093?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F32e8504e-caa6-4e9b-8773-27507e579eb6_2190x1061.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="If your code runs for minutes or days, it won't run straight through. Wrap functions in steps that automatically retry, pause, and fan out. Scale instantly, without thinking about infra." title="If your code runs for minutes or days, it won't run straight through. Wrap functions in steps that automatically retry, pause, and fan out. Scale instantly, without thinking about infra." srcset="https://substackcdn.com/image/fetch/$s_!0XGX!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F32e8504e-caa6-4e9b-8773-27507e579eb6_2190x1061.png 424w, https://substackcdn.com/image/fetch/$s_!0XGX!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F32e8504e-caa6-4e9b-8773-27507e579eb6_2190x1061.png 848w, https://substackcdn.com/image/fetch/$s_!0XGX!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F32e8504e-caa6-4e9b-8773-27507e579eb6_2190x1061.png 1272w, https://substackcdn.com/image/fetch/$s_!0XGX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F32e8504e-caa6-4e9b-8773-27507e579eb6_2190x1061.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>Long-running agents need endurance.</p><p>They must survive waiting for users and withstand tool failures. They must adapt to every leap in model intelligence.</p><p>&#9889;&#65039;<em> Inngest makes long-running agents durable, observable, and improvable over time.</em></p><p>Check out their <strong>generous free tier</strong> and a sleek local dev server for testing your workflows.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://inngest.link/dai-nl&quot;,&quot;text&quot;:&quot;Build for the long run with Inngest&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://inngest.link/dai-nl"><span>Build for the long run with Inngest</span></a></p></div><p>Now, let&#8217;s go!</p><h2>What are LLM wikis?</h2><p>In <a href="https://github.com/decodingai-magazine/llm-wiki-workshop/tree/main/01-llm-wiki-vanilla">exercise 1</a>, we have 5 notes on MCP and skills ingested into the LLM wiki. If, using our agent, we ask <em>&#8220;What do my notes say about when to use an MCP server vs. a CLI?&#8221;</em>, the agent finds the 3 most relevant wiki pages (<code>agent-connectivity</code>, <code>cli</code>, <code>mcp</code>) and answers with links to them. Each link leads down to the sources and raw notes behind the claim.</p><p>The LLM wiki is a directory of Markdown files that an LLM writes and an agent reads. Zero databases have seen the query. It&#8217;s surprising how much complexity you can squeeze out of Markdown files.</p><p>Sources go in, derived pages (the nodes) come out. As each page links to other relevant pages, plus the sources it was created from, the wiki indirectly forms a knowledge graph. To sum up:</p><blockquote><p><em>An LLM wiki is a knowledge graph represented with Markdown files.</em></p></blockquote><p>Image 1 shows the LLM wiki from <a href="https://github.com/decodingai-magazine/llm-wiki-workshop/tree/main/02-llm-wiki-ingest">exercise 2</a>, rendered as an Obsidian graph, with 14 sources and 17 nodes.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!YQiW!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F741af43e-3e35-48b8-a324-1cfb2509a2c2_725x647.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!YQiW!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F741af43e-3e35-48b8-a324-1cfb2509a2c2_725x647.png 424w, https://substackcdn.com/image/fetch/$s_!YQiW!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F741af43e-3e35-48b8-a324-1cfb2509a2c2_725x647.png 848w, https://substackcdn.com/image/fetch/$s_!YQiW!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F741af43e-3e35-48b8-a324-1cfb2509a2c2_725x647.png 1272w, https://substackcdn.com/image/fetch/$s_!YQiW!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F741af43e-3e35-48b8-a324-1cfb2509a2c2_725x647.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!YQiW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F741af43e-3e35-48b8-a324-1cfb2509a2c2_725x647.png" width="725" height="647" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/741af43e-3e35-48b8-a324-1cfb2509a2c2_725x647.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:647,&quot;width&quot;:725,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!YQiW!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F741af43e-3e35-48b8-a324-1cfb2509a2c2_725x647.png 424w, https://substackcdn.com/image/fetch/$s_!YQiW!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F741af43e-3e35-48b8-a324-1cfb2509a2c2_725x647.png 848w, https://substackcdn.com/image/fetch/$s_!YQiW!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F741af43e-3e35-48b8-a324-1cfb2509a2c2_725x647.png 1272w, https://substackcdn.com/image/fetch/$s_!YQiW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F741af43e-3e35-48b8-a324-1cfb2509a2c2_725x647.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Image 1: A small LLM wiki: 14 sources, 17 nodes.</em></figcaption></figure></div><p>Image 2 shows an earlier snapshot of the wiki behind my current book, with 135 sources and 120 nodes.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!as9B!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4540129e-6c4d-4a44-927a-634adf942f4a_725x647.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!as9B!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4540129e-6c4d-4a44-927a-634adf942f4a_725x647.png 424w, https://substackcdn.com/image/fetch/$s_!as9B!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4540129e-6c4d-4a44-927a-634adf942f4a_725x647.png 848w, https://substackcdn.com/image/fetch/$s_!as9B!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4540129e-6c4d-4a44-927a-634adf942f4a_725x647.png 1272w, https://substackcdn.com/image/fetch/$s_!as9B!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4540129e-6c4d-4a44-927a-634adf942f4a_725x647.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!as9B!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4540129e-6c4d-4a44-927a-634adf942f4a_725x647.png" width="725" height="647" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4540129e-6c4d-4a44-927a-634adf942f4a_725x647.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:647,&quot;width&quot;:725,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!as9B!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4540129e-6c4d-4a44-927a-634adf942f4a_725x647.png 424w, https://substackcdn.com/image/fetch/$s_!as9B!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4540129e-6c4d-4a44-927a-634adf942f4a_725x647.png 848w, https://substackcdn.com/image/fetch/$s_!as9B!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4540129e-6c4d-4a44-927a-634adf942f4a_725x647.png 1272w, https://substackcdn.com/image/fetch/$s_!as9B!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4540129e-6c4d-4a44-927a-634adf942f4a_725x647.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Image 2: The same system on a real corpus: 135 sources, 120 nodes.</em></figcaption></figure></div><p>But Obsidian is only a viewer. Every tutorial recommends it because it renders linked Markdown beautifully. The files are still plain Markdown and work in any editor. The agent doesn&#8217;t need Obsidian to operate the wiki. Just point it to the wiki dir, and it&#8217;s good to go. Zero setup, zero dependencies.</p><p>The architecture comes down to 4 steps, illustrated in Image 3:</p><ol><li><p>Ingestion copies notes, repos, articles, and videos into <code>raw/</code>.</p></li><li><p><code>raw/</code> is immutable: the source of truth, never edited.</p></li><li><p>An LLM transforms it into <code>wiki/</code>, derived pages for what we know.</p></li><li><p>The agent queries only <code>wiki/</code>.</p></li></ol><p>The point is to turn raw data into something easy to query, instead of throwing all of it at the LLM and hoping for the best. In other words, we want to do RAG.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!yIAj!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8a87008-0156-4440-a7d2-5baa9715a7b6_1200x501.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!yIAj!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8a87008-0156-4440-a7d2-5baa9715a7b6_1200x501.png 424w, https://substackcdn.com/image/fetch/$s_!yIAj!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8a87008-0156-4440-a7d2-5baa9715a7b6_1200x501.png 848w, https://substackcdn.com/image/fetch/$s_!yIAj!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8a87008-0156-4440-a7d2-5baa9715a7b6_1200x501.png 1272w, https://substackcdn.com/image/fetch/$s_!yIAj!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8a87008-0156-4440-a7d2-5baa9715a7b6_1200x501.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!yIAj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8a87008-0156-4440-a7d2-5baa9715a7b6_1200x501.png" width="1200" height="501" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d8a87008-0156-4440-a7d2-5baa9715a7b6_1200x501.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:501,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;LLM wiki architecture: sources ingested into an immutable raw layer, transformed into the wiki, queried by an agent.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="LLM wiki architecture: sources ingested into an immutable raw layer, transformed into the wiki, queried by an agent." title="LLM wiki architecture: sources ingested into an immutable raw layer, transformed into the wiki, queried by an agent." srcset="https://substackcdn.com/image/fetch/$s_!yIAj!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8a87008-0156-4440-a7d2-5baa9715a7b6_1200x501.png 424w, https://substackcdn.com/image/fetch/$s_!yIAj!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8a87008-0156-4440-a7d2-5baa9715a7b6_1200x501.png 848w, https://substackcdn.com/image/fetch/$s_!yIAj!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8a87008-0156-4440-a7d2-5baa9715a7b6_1200x501.png 1272w, https://substackcdn.com/image/fetch/$s_!yIAj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8a87008-0156-4440-a7d2-5baa9715a7b6_1200x501.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Image 3: Raw data is ingested once and kept immutable. An LLM transforms it into the wiki, and the agent queries only the wiki.</em></figcaption></figure></div><p>On disk, one wiki looks like this:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;plaintext&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-plaintext">wiki-&lt;slug&gt;/
&#9500;&#9472;&#9472; log.md            # append-only history
&#9500;&#9472;&#9472; raw/              # immutable copies of what was ingested
&#9474;   &#9500;&#9472;&#9472; &lt;slug&gt;.md
&#9474;   &#9492;&#9472;&#9472; assets/
&#9492;&#9472;&#9472; wiki/
    &#9500;&#9472;&#9472; index.md      # generated root
    &#9500;&#9472;&#9472; overview.md   # LLM-written summary of the whole wiki
    &#9500;&#9472;&#9472; sources/      # one page per raw file
    &#9500;&#9472;&#9472; entities/
    &#9492;&#9472;&#9472; concepts/</code></pre></div><p>Each raw file gets exactly one source page, an executive summary of what matters in it: a summary, key claims, notable quotes, and connections. From it, the LLM extracts <strong>entities</strong> and <strong>concepts</strong>. Entities are tools or frameworks, clear things that you can point at, while concepts are more like theoretical ideas.</p><p>In <a href="https://github.com/decodingai-magazine/llm-wiki-workshop/tree/main/01-llm-wiki-vanilla">exercise 1</a>, the 5 ingested notes yield 5 source pages, 4 entities, and 5 concepts. The note <em>&#8220;The Future of MCP vs. Skills&#8221;</em> alone yields 3 entities (MCP, Claude Code, FastMCP) and 4 concepts (skills, CLI, agent connectivity, orchestration).</p><p>Entities and concepts are just an ontology. Swap them for whatever your domain needs: people, companies, organizations, locations, tools. Go too narrow, and extraction misses things. Go too wide, and it extracts everything. <em>&#8220;Entities + Concepts&#8221;</em> is a very generic ontology that works on anything, which can be a blessing and a curse. To go deeper, see how to <a href="https://www.decodingai.com/p/ship-a-knowledge-graph-ontology-in-5-minutes">ship a knowledge graph ontology in 5 minutes</a>.</p><p>Next, follow a single item from the moment you ingest it to see where those pages come from.</p><h2>How ingestion builds the wiki</h2><p>As shown in Image 4, every item starts with the same 2 steps. First, the item is copied into <code>raw/</code>. We use the slug as its ID, so an item ingested twice is skipped. Second, the LLM writes its source page, listing in the frontmatter the entities and concepts it extracted.</p><p>An entity or concept gets its own page only when at least 2 distinct sources extract it. One note mentioning something is a fact about the note. Two notes mentioning it is a fact about your knowledge.</p><p>In exercise 1, Obsidian appeared in 1 source and stayed unpromoted. Agent memory appeared in 2, so <code>wiki/concepts/agent-memory.md</code> was synthesized across both. The threshold is tunable, and it&#8217;s what <a href="https://www.decodingai.com/p/keep-knowledge-graph-clean">keeps the knowledge graph clean</a>: it cuts noise and keeps what recurs across your data.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!JXgZ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c456837-e10e-4f7e-9c96-f289e4b68033_1200x546.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!JXgZ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c456837-e10e-4f7e-9c96-f289e4b68033_1200x546.png 424w, https://substackcdn.com/image/fetch/$s_!JXgZ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c456837-e10e-4f7e-9c96-f289e4b68033_1200x546.png 848w, https://substackcdn.com/image/fetch/$s_!JXgZ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c456837-e10e-4f7e-9c96-f289e4b68033_1200x546.png 1272w, https://substackcdn.com/image/fetch/$s_!JXgZ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c456837-e10e-4f7e-9c96-f289e4b68033_1200x546.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!JXgZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c456837-e10e-4f7e-9c96-f289e4b68033_1200x546.png" width="1200" height="546" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5c456837-e10e-4f7e-9c96-f289e4b68033_1200x546.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:546,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;One ingested item: copied to raw, distilled into a source page with key insights, entities, and concepts; a concept reaching two sources becomes a synthesized page.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="One ingested item: copied to raw, distilled into a source page with key insights, entities, and concepts; a concept reaching two sources becomes a synthesized page." title="One ingested item: copied to raw, distilled into a source page with key insights, entities, and concepts; a concept reaching two sources becomes a synthesized page." srcset="https://substackcdn.com/image/fetch/$s_!JXgZ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c456837-e10e-4f7e-9c96-f289e4b68033_1200x546.png 424w, https://substackcdn.com/image/fetch/$s_!JXgZ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c456837-e10e-4f7e-9c96-f289e4b68033_1200x546.png 848w, https://substackcdn.com/image/fetch/$s_!JXgZ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c456837-e10e-4f7e-9c96-f289e4b68033_1200x546.png 1272w, https://substackcdn.com/image/fetch/$s_!JXgZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c456837-e10e-4f7e-9c96-f289e4b68033_1200x546.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Image 4: A concept or entity earns its own page only once two sources engage with it.</em></figcaption></figure></div><p>This is graph ingestion, scaled down: extract per document, merge across documents, threshold to cut noise. This strategy has a huge overlap with how you can actually do GraphRAG because, at its core, it is a very light GraphRAG technique. <a href="https://www.decodingai.com/p/agentic-graphrag">See the full architecture</a>.</p><p>Updates recompute only what changed. A new source triggers a recount, and only the entity and concept pages it touches are rewritten. The skill never overwrites <code>raw/</code>, so for a changed note we swap the raw copy, rewrite its source page, and recompute just the pages linked to it. There&#8217;s no full re-ingest.</p><p>Here is what the <a href="https://github.com/decodingai-magazine/llm-wiki-workshop/blob/main/01-llm-wiki-vanilla/examples/wiki-01-ai-engineering/wiki/concepts/agent-memory.md">agent memory concept from exercise 1</a> looks like:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;markdown&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-markdown">---
type: concept
title: Agent Memory
description: Unified, agent-accessible memory built from ingested documents, knowledge-graph extraction, and embeddings, exposed to agents through MCP search/write tools.
aliases:
  - unified memory
  - knowledge graph memory
  - GraphRAG
sources:
  - "[[wiki/sources/the-right-way-of-building-agents-with-mcp-servers]]"
  - "[[wiki/sources/why-mcp-is-not-dead]]"
related:
  - "[[wiki/concepts/orchestration]]"
  - "[[wiki/entities/prefect]]"
  - "[[wiki/entities/mcp]]"
created: 2026-08-29T15:32:43Z
timestamp: 2026-08-29T15:32:43Z
source_count: 2
---

# Agent Memory
...

## Definition
...

## Key claims
...

## Relationships
...</code></pre></div><p>The index is created by a Python script, not an LLM. After the pages, a script rebuilds one index per folder (<code>wiki/sources/</code>, <code>wiki/concepts/</code>, <code>wiki/entities/</code>), each a list of <code>title &#8212; description</code> bullets. For entities, it looks like this:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;markdown&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-markdown"># Entities

- [[wiki/entities/claude-code|Claude Code]] &#8212; Anthropic's terminal-based coding agent and MCP client, which also natively runs skills placed in `.claude/skills/`.
- [[wiki/entities/fastmcp|FastMCP]] &#8212; The de facto default Python SDK for building MCP servers and clients, maintained by Prefect.</code></pre></div><p>As seen in Images 5, 6, and 7, the root <code>wiki/index.md</code> points to the 3 sub-indexes, with page counts. It&#8217;s the agent&#8217;s first entry point into the wiki. Finally, the skill rewrites the overview and appends the event to <code>log.md</code> as an append-only log.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!5gmI!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe2f24aa3-7fc4-4ef9-83a8-c3cce9e7dbe4_1200x469.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!5gmI!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe2f24aa3-7fc4-4ef9-83a8-c3cce9e7dbe4_1200x469.png 424w, https://substackcdn.com/image/fetch/$s_!5gmI!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe2f24aa3-7fc4-4ef9-83a8-c3cce9e7dbe4_1200x469.png 848w, https://substackcdn.com/image/fetch/$s_!5gmI!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe2f24aa3-7fc4-4ef9-83a8-c3cce9e7dbe4_1200x469.png 1272w, https://substackcdn.com/image/fetch/$s_!5gmI!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe2f24aa3-7fc4-4ef9-83a8-c3cce9e7dbe4_1200x469.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!5gmI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe2f24aa3-7fc4-4ef9-83a8-c3cce9e7dbe4_1200x469.png" width="1200" height="469" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e2f24aa3-7fc4-4ef9-83a8-c3cce9e7dbe4_1200x469.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:469,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;How the index works: pages feed per-folder indexes, which feed the root index, the overview, and the log.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="How the index works: pages feed per-folder indexes, which feed the root index, the overview, and the log." title="How the index works: pages feed per-folder indexes, which feed the root index, the overview, and the log." srcset="https://substackcdn.com/image/fetch/$s_!5gmI!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe2f24aa3-7fc4-4ef9-83a8-c3cce9e7dbe4_1200x469.png 424w, https://substackcdn.com/image/fetch/$s_!5gmI!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe2f24aa3-7fc4-4ef9-83a8-c3cce9e7dbe4_1200x469.png 848w, https://substackcdn.com/image/fetch/$s_!5gmI!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe2f24aa3-7fc4-4ef9-83a8-c3cce9e7dbe4_1200x469.png 1272w, https://substackcdn.com/image/fetch/$s_!5gmI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe2f24aa3-7fc4-4ef9-83a8-c3cce9e7dbe4_1200x469.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Image 5: Every ingest ends by rebuilding the index hierarchy, the overview, and the log.</em></figcaption></figure></div><p>In Obsidian, you can see the hierarchy. The root <code>index.md</code> sits 1 hop from every section index:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!NKaq!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbefacb90-b7a2-47c4-aaf7-7d9aa030dca0_589x583.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!NKaq!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbefacb90-b7a2-47c4-aaf7-7d9aa030dca0_589x583.png 424w, https://substackcdn.com/image/fetch/$s_!NKaq!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbefacb90-b7a2-47c4-aaf7-7d9aa030dca0_589x583.png 848w, https://substackcdn.com/image/fetch/$s_!NKaq!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbefacb90-b7a2-47c4-aaf7-7d9aa030dca0_589x583.png 1272w, https://substackcdn.com/image/fetch/$s_!NKaq!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbefacb90-b7a2-47c4-aaf7-7d9aa030dca0_589x583.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!NKaq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbefacb90-b7a2-47c4-aaf7-7d9aa030dca0_589x583.png" width="589" height="583" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/befacb90-b7a2-47c4-aaf7-7d9aa030dca0_589x583.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:583,&quot;width&quot;:589,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Obsidian graph with the root index.md highlighted, linking out to each section index.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Obsidian graph with the root index.md highlighted, linking out to each section index." title="Obsidian graph with the root index.md highlighted, linking out to each section index." srcset="https://substackcdn.com/image/fetch/$s_!NKaq!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbefacb90-b7a2-47c4-aaf7-7d9aa030dca0_589x583.png 424w, https://substackcdn.com/image/fetch/$s_!NKaq!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbefacb90-b7a2-47c4-aaf7-7d9aa030dca0_589x583.png 848w, https://substackcdn.com/image/fetch/$s_!NKaq!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbefacb90-b7a2-47c4-aaf7-7d9aa030dca0_589x583.png 1272w, https://substackcdn.com/image/fetch/$s_!NKaq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbefacb90-b7a2-47c4-aaf7-7d9aa030dca0_589x583.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Image 6: The root index, one hop to every section.</em></figcaption></figure></div><p>And <code>concepts/index.md</code> sits 1 hop from every concept page:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!_n3s!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F023ea434-ba40-470c-8836-63d2d6ced9ea_589x583.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!_n3s!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F023ea434-ba40-470c-8836-63d2d6ced9ea_589x583.png 424w, https://substackcdn.com/image/fetch/$s_!_n3s!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F023ea434-ba40-470c-8836-63d2d6ced9ea_589x583.png 848w, https://substackcdn.com/image/fetch/$s_!_n3s!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F023ea434-ba40-470c-8836-63d2d6ced9ea_589x583.png 1272w, https://substackcdn.com/image/fetch/$s_!_n3s!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F023ea434-ba40-470c-8836-63d2d6ced9ea_589x583.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!_n3s!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F023ea434-ba40-470c-8836-63d2d6ced9ea_589x583.png" width="589" height="583" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/023ea434-ba40-470c-8836-63d2d6ced9ea_589x583.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:583,&quot;width&quot;:589,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Obsidian graph with concepts/index.md highlighted, linking out to every concept page.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Obsidian graph with concepts/index.md highlighted, linking out to every concept page." title="Obsidian graph with concepts/index.md highlighted, linking out to every concept page." srcset="https://substackcdn.com/image/fetch/$s_!_n3s!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F023ea434-ba40-470c-8836-63d2d6ced9ea_589x583.png 424w, https://substackcdn.com/image/fetch/$s_!_n3s!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F023ea434-ba40-470c-8836-63d2d6ced9ea_589x583.png 848w, https://substackcdn.com/image/fetch/$s_!_n3s!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F023ea434-ba40-470c-8836-63d2d6ced9ea_589x583.png 1272w, https://substackcdn.com/image/fetch/$s_!_n3s!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F023ea434-ba40-470c-8836-63d2d6ced9ea_589x583.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Image 7: The concepts index, one hop to every concept page.</em></figcaption></figure></div><p>The agent walks these indexes every time it answers a question.</p><h2>Querying the wiki via progressive disclosure</h2><p>The <code>raw/</code> directory is the last folder the agent accesses. It walks a 3-step ladder and stops as soon as the question is answered, since each index line is enough to choose a page:</p><ol><li><p>The root <code>index.md</code>, then the 1 or 2 relevant sub-indexes.</p></li><li><p>Then 1&#8211;3 pages, preferring entity and concept pages, already synthesized across sources, over single-source pages.</p></li><li><p>Only if those fall short does it access the linked source pages, then the raw files.</p></li></ol><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!jhHK!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad5ded05-419d-4123-9798-dee3aac8f7e6_1200x359.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!jhHK!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad5ded05-419d-4123-9798-dee3aac8f7e6_1200x359.png 424w, https://substackcdn.com/image/fetch/$s_!jhHK!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad5ded05-419d-4123-9798-dee3aac8f7e6_1200x359.png 848w, https://substackcdn.com/image/fetch/$s_!jhHK!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad5ded05-419d-4123-9798-dee3aac8f7e6_1200x359.png 1272w, https://substackcdn.com/image/fetch/$s_!jhHK!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad5ded05-419d-4123-9798-dee3aac8f7e6_1200x359.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!jhHK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad5ded05-419d-4123-9798-dee3aac8f7e6_1200x359.png" width="1200" height="359" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ad5ded05-419d-4123-9798-dee3aac8f7e6_1200x359.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:359,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Querying via progressive disclosure: agent to index.md, to a sub-index, to concept and entity pages, to sources, to raw.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Querying via progressive disclosure: agent to index.md, to a sub-index, to concept and entity pages, to sources, to raw." title="Querying via progressive disclosure: agent to index.md, to a sub-index, to concept and entity pages, to sources, to raw." srcset="https://substackcdn.com/image/fetch/$s_!jhHK!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad5ded05-419d-4123-9798-dee3aac8f7e6_1200x359.png 424w, https://substackcdn.com/image/fetch/$s_!jhHK!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad5ded05-419d-4123-9798-dee3aac8f7e6_1200x359.png 848w, https://substackcdn.com/image/fetch/$s_!jhHK!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad5ded05-419d-4123-9798-dee3aac8f7e6_1200x359.png 1272w, https://substackcdn.com/image/fetch/$s_!jhHK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad5ded05-419d-4123-9798-dee3aac8f7e6_1200x359.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Image 8: Each step down the ladder is taken only when the step above can&#8217;t answer.</em></figcaption></figure></div><p>It&#8217;s RAG built from files. Reading 1&#8211;3 pages is the top-k: stop at the first hits. Following links from page to page is multi-hop graph traversal, used only when the top hits fall short. Beautiful!</p><p>This beats dumping files into context because every raw file is read in full once, at ingest. A query pays for a few index lines plus 1&#8211;3 curated pages (that already cross-pollinate ideas between docs), not your whole corpus. The MCP-vs-CLI question took 3 pages.</p><p>The price is latency and scalability. A graph database returns neighbors in 1 call. Here the agent opens one file, then another. And scaling ingestion and search past 1,000 sources can be challenging. That&#8217;s the trade-off of a knowledge graph built from Markdown files instead of Neo4j or Postgres.</p><p>Every claim cites the page it came from. To avoid hallucinations, if the wiki doesn&#8217;t know, the agent says so.</p><p>So how do I know it works? To be honest, with just vibes at this point. I don&#8217;t want to lie to you. Precision holds up when I check answers against topics I know. As for recall, I can&#8217;t tell whether it found everything relevant. Proper RAG-style evals are the next step.</p><p>Let&#8217;s take a look at the skill used for both ingestion and queries.</p><h2>Implementing the skill</h2><p>The <code>llm-wiki-vanilla</code> skill from <a href="https://github.com/decodingai-magazine/llm-wiki-workshop/tree/main/01-llm-wiki-vanilla/.agents/skills/01-llm-wiki-vanilla">exercise 1</a> is 3 Markdown files and 2 scripts:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;plaintext&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-plaintext">01-llm-wiki-vanilla/
&#9500;&#9472;&#9472; SKILL.md              # the workflow: locate, detect mode, ingest or query
&#9500;&#9472;&#9472; CONVENTIONS.md        # the data contract: layout, threshold, links, log
&#9500;&#9472;&#9472; PAGES.md              # one template per page type
&#9492;&#9472;&#9472; scripts/
    &#9500;&#9472;&#9472; count_mentions.py # which slugs crossed the &#8805;2 threshold
    &#9492;&#9472;&#9472; build_index_md.py # regenerates every index.md</code></pre></div><p>The frontmatter is the trigger. Until the skill is invoked, only its name and description sit in the agent&#8217;s context, and the description is what makes the agent pick the skill for the right request:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;yaml&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-yaml">---
name: 01-llm-wiki-vanilla
description: "Build and query a minimal LLM-maintained wiki from local markdown notes (modes: ingest, query)."
---</code></pre></div><p><code>SKILL.md</code> holds the core steps. Step 0 locates the wiki: a <code>wiki-*/</code> folder holding both <code>raw/</code> and <code>wiki/</code>. Step 1 detects the mode. It routes to ingest only on an explicit verb (ingest, add, build) or dropped paths, and to query otherwise.</p><p>The ingest path then runs collect and dedup, copy to <code>raw/</code>, source pages, count mentions, entity and concept pages, overview, rebuild index, and log.</p><p><code>SKILL.md</code> stays lean. It tells the agent to read <code>CONVENTIONS.md</code> and <code>PAGES.md</code> only when it needs to write something, so queries <a href="https://www.decodingai.com/p/context-engineering-for-coding-agents">keep the context small</a> via progressive disclosure.</p><p>The pages&#8217; Markdown YAML frontmatter follows Google&#8217;s <a href="https://github.com/GoogleCloudPlatform/open-knowledge-format/blob/main/SPEC.md">Open Knowledge Format</a>, which requires a mandatory <code>type</code> field, plus a name and description. Other fields depend on the type. For example, ontology objects (entities and concepts) include graph attributes such as aliases, sources, and related concepts or entities. All of this is encoded in the <a href="https://github.com/decodingai-magazine/llm-wiki-workshop/blob/main/01-llm-wiki-vanilla/.agents/skills/01-llm-wiki-vanilla/PAGES.md">PAGES.md</a> templates.</p><p><code>count_mentions.py</code> walks every source page&#8217;s frontmatter and returns which entity or concept passed the 2-source threshold. <code>build_index_md.py</code> regenerates every index from the frontmatter metadata.</p><p>Basic math and deterministic transformations belong in scripts. Otherwise, you uselessly consume tokens, and you kind of assume that the LLM will count right. It mostly does, but not always.</p><blockquote><p>A major advantage over passing all documents into context is that a smaller model handles ingestion, while a larger model queries only a fraction of the data.</p></blockquote><p>I ran ingestion with Sonnet 5.5 and queries with Opus 5.5 for better reasoning across pages and better goal execution.</p><p>So far, we&#8217;ve implemented a vanilla skill that reads only local Markdown. In <a href="https://github.com/decodingai-magazine/llm-wiki-workshop/tree/main/02-llm-wiki-ingest">exercise 2</a>, we show how to extend it with multiple sources.</p><h2>How to support multiple sources (exercise 2)</h2><p>An LLM wiki gets powerful when local notes, web articles, code repos, YouTube videos, and Reddit threads are interconnected in one graph. Mine pulls from my Readwise saves, Obsidian vault, and GitHub stars: separate silos that the wiki compiles into one interface I can chat with.</p><p>The <a href="https://github.com/decodingai-magazine/llm-wiki-workshop/tree/main/02-llm-wiki-ingest">upgraded skill from exercise 2</a> handles 5 sources, each with its own adapter script that turns one URI into exactly one raw artifact that has the same interface across sources (origin, original path, title, authors, published date, raw path):</p><ul><li><p>Local files use <code>cp</code>.</p></li><li><p><code>fetch_article.py</code> is a <code>curl</code> plus HTML cleanup.</p></li><li><p><code>clone_repo.py</code> is a shallow clone.</p></li><li><p><code>fetch_youtube.py</code> and <code>reddit_threads.py</code> are API calls.</p></li></ul><p>Everything downstream of <code>raw/</code> is origin-agnostic, so adding a source is one small fetch-and-normalize script, a per-origin ETL pipeline.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ekNL!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2850ec65-759f-46c4-bd4d-4a35ea6244f9_1200x571.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ekNL!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2850ec65-759f-46c4-bd4d-4a35ea6244f9_1200x571.png 424w, https://substackcdn.com/image/fetch/$s_!ekNL!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2850ec65-759f-46c4-bd4d-4a35ea6244f9_1200x571.png 848w, https://substackcdn.com/image/fetch/$s_!ekNL!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2850ec65-759f-46c4-bd4d-4a35ea6244f9_1200x571.png 1272w, https://substackcdn.com/image/fetch/$s_!ekNL!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2850ec65-759f-46c4-bd4d-4a35ea6244f9_1200x571.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!ekNL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2850ec65-759f-46c4-bd4d-4a35ea6244f9_1200x571.png" width="1200" height="571" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2850ec65-759f-46c4-bd4d-4a35ea6244f9_1200x571.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:571,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Every URI type routes to its own source script and normalizes to one adapter interface plus a raw artifact.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Every URI type routes to its own source script and normalizes to one adapter interface plus a raw artifact." title="Every URI type routes to its own source script and normalizes to one adapter interface plus a raw artifact." srcset="https://substackcdn.com/image/fetch/$s_!ekNL!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2850ec65-759f-46c4-bd4d-4a35ea6244f9_1200x571.png 424w, https://substackcdn.com/image/fetch/$s_!ekNL!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2850ec65-759f-46c4-bd4d-4a35ea6244f9_1200x571.png 848w, https://substackcdn.com/image/fetch/$s_!ekNL!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2850ec65-759f-46c4-bd4d-4a35ea6244f9_1200x571.png 1272w, https://substackcdn.com/image/fetch/$s_!ekNL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2850ec65-759f-46c4-bd4d-4a35ea6244f9_1200x571.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Image 9: Five origins, one interface. Downstream of raw, the wiki never knows where a source came from.</em></figcaption></figure></div><p>Repos get their own page type, since a repo is a tree, not a file. Its writer produces one short <code>ARCHITECTURE.md</code> summary in <code>wiki/repos/&lt;repo&gt;/</code> and, to avoid assuming the consumer needs more, it goes deeper only on demand.</p><p>The exercise 2 skill grows the <code>agents/</code> and <code>scripts/</code> directories with one per source:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;plaintext&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-plaintext">02-llm-wiki-ingest/
&#9500;&#9472;&#9472; SKILL.md
&#9500;&#9472;&#9472; CONVENTIONS.md
&#9500;&#9472;&#9472; PAGES.md
&#9500;&#9472;&#9472; SOURCES.md            # adapter contract + routing table
&#9500;&#9472;&#9472; agents/
&#9474;   &#9500;&#9472;&#9472; source_writer.md
&#9474;   &#9500;&#9472;&#9472; repo_writer.md
&#9474;   &#9500;&#9472;&#9472; page_writer.md
&#9474;   &#9492;&#9472;&#9472; overview_writer.md
&#9492;&#9472;&#9472; scripts/
    &#9500;&#9472;&#9472; fetch_article.py
    &#9500;&#9472;&#9472; clone_repo.py
    &#9500;&#9472;&#9472; fetch_youtube.py
    &#9500;&#9472;&#9472; count_mentions.py
    &#9492;&#9472;&#9472; build_index_md.py</code></pre></div><p>Fetching runs in parallel, then one source writer per raw file reads it exactly once. A barrier waits for every source page because page writers combine sources, then one page writer per qualifying slug runs, then the overview writer.</p><p>As shown in Image 10, fetching and writing source pages happen in parallel. Entity and concept compilation requires all sources to determine what to combine. Ontology pages can also be written in parallel once all source pages are ready.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!oYKE!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14770138-9904-40ac-8fdb-6557565d5402_1200x462.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!oYKE!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14770138-9904-40ac-8fdb-6557565d5402_1200x462.png 424w, https://substackcdn.com/image/fetch/$s_!oYKE!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14770138-9904-40ac-8fdb-6557565d5402_1200x462.png 848w, https://substackcdn.com/image/fetch/$s_!oYKE!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14770138-9904-40ac-8fdb-6557565d5402_1200x462.png 1272w, https://substackcdn.com/image/fetch/$s_!oYKE!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14770138-9904-40ac-8fdb-6557565d5402_1200x462.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!oYKE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14770138-9904-40ac-8fdb-6557565d5402_1200x462.png" width="1200" height="462" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/14770138-9904-40ac-8fdb-6557565d5402_1200x462.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:462,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Fan-out: URIs fetched in parallel into raw, source writers and page writers in parallel, one overview writer at the end.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Fan-out: URIs fetched in parallel into raw, source writers and page writers in parallel, one overview writer at the end." title="Fan-out: URIs fetched in parallel into raw, source writers and page writers in parallel, one overview writer at the end." srcset="https://substackcdn.com/image/fetch/$s_!oYKE!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14770138-9904-40ac-8fdb-6557565d5402_1200x462.png 424w, https://substackcdn.com/image/fetch/$s_!oYKE!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14770138-9904-40ac-8fdb-6557565d5402_1200x462.png 848w, https://substackcdn.com/image/fetch/$s_!oYKE!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14770138-9904-40ac-8fdb-6557565d5402_1200x462.png 1272w, https://substackcdn.com/image/fetch/$s_!oYKE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14770138-9904-40ac-8fdb-6557565d5402_1200x462.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Image 10: Everything up to the source pages is independent. Only the page writers wait, because they combine sources.</em></figcaption></figure></div><p>The agents are plain <code>.md</code> files inside the skill. The main <code>SKILL.md</code> instructs the harness to <em>&#8220;create subagents&#8221;</em> based on these files, defaulting to Sonnet. This is a powerful and easy strategy to make your skills harness-agnostic.</p><p>So far, the wiki grows only when you ingest. In <a href="https://github.com/decodingai-magazine/llm-wiki-workshop/tree/main/03-llm-wiki-interactive">exercise 3</a>, we will see how to capture the interactions with the wiki as a signal.</p><h2>Interactive LLM wikis (exercise 3)</h2><p>Your questions are data. They show what isn&#8217;t clear to you yet. For me, as a content creator, that&#8217;s often exactly what my audience won&#8217;t understand either. The questions leave breadcrumbs of my own learning curve.</p><p>So, with this upgrade, we add 3 new components:</p><ul><li><p><code>questions/</code> logs each question as a slim pointer page.</p></li><li><p><code>notes/</code> is a second layer of pages on top of sources, entities, and concepts.</p></li><li><p><code>open-questions.md</code> lists what the wiki can&#8217;t answer yet.</p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!BQ99!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8463c20-3c02-4402-a25f-dfbd662a6336_1200x384.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!BQ99!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8463c20-3c02-4402-a25f-dfbd662a6336_1200x384.png 424w, https://substackcdn.com/image/fetch/$s_!BQ99!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8463c20-3c02-4402-a25f-dfbd662a6336_1200x384.png 848w, https://substackcdn.com/image/fetch/$s_!BQ99!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8463c20-3c02-4402-a25f-dfbd662a6336_1200x384.png 1272w, https://substackcdn.com/image/fetch/$s_!BQ99!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8463c20-3c02-4402-a25f-dfbd662a6336_1200x384.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!BQ99!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8463c20-3c02-4402-a25f-dfbd662a6336_1200x384.png" width="1200" height="384" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d8463c20-3c02-4402-a25f-dfbd662a6336_1200x384.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:384,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;The interactive wiki adds questions, notes, and open-questions.md beside the existing pages, plus repo notes inside the existing repos folder.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="The interactive wiki adds questions, notes, and open-questions.md beside the existing pages, plus repo notes inside the existing repos folder." title="The interactive wiki adds questions, notes, and open-questions.md beside the existing pages, plus repo notes inside the existing repos folder." srcset="https://substackcdn.com/image/fetch/$s_!BQ99!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8463c20-3c02-4402-a25f-dfbd662a6336_1200x384.png 424w, https://substackcdn.com/image/fetch/$s_!BQ99!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8463c20-3c02-4402-a25f-dfbd662a6336_1200x384.png 848w, https://substackcdn.com/image/fetch/$s_!BQ99!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8463c20-3c02-4402-a25f-dfbd662a6336_1200x384.png 1272w, https://substackcdn.com/image/fetch/$s_!BQ99!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8463c20-3c02-4402-a25f-dfbd662a6336_1200x384.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Image 11: Three new components beside the ingest-owned pages. Repo notes live inside the existing repos folder.</em></figcaption></figure></div><p>Every logged question has 4 possible outcomes:</p><ul><li><p>A single-concept answer stays an answer.</p></li><li><p>An answer synthesizing 2 or more pages, or one you ask to save, becomes a note. If the wiki created notes out of every answer, it would quickly become useless.</p></li><li><p>An unanswerable question gets saved in <code>open-questions.md</code>.</p></li><li><p>A repo question that <code>ARCHITECTURE.md</code> can&#8217;t answer makes the agent read the clone and write a repo note, which re-enters ingest and can push a concept over the threshold.</p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!zKtc!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F854c7021-31a8-4d97-ad62-c3736b6ac9a0_1200x572.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!zKtc!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F854c7021-31a8-4d97-ad62-c3736b6ac9a0_1200x572.png 424w, https://substackcdn.com/image/fetch/$s_!zKtc!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F854c7021-31a8-4d97-ad62-c3736b6ac9a0_1200x572.png 848w, https://substackcdn.com/image/fetch/$s_!zKtc!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F854c7021-31a8-4d97-ad62-c3736b6ac9a0_1200x572.png 1272w, https://substackcdn.com/image/fetch/$s_!zKtc!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F854c7021-31a8-4d97-ad62-c3736b6ac9a0_1200x572.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!zKtc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F854c7021-31a8-4d97-ad62-c3736b6ac9a0_1200x572.png" width="1200" height="572" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/854c7021-31a8-4d97-ad62-c3736b6ac9a0_1200x572.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:572,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;The interactive workflow: questions logged, multi-page answers become notes, unanswerable questions go to open-questions.md, repo questions produce repo notes that re-enter ingest.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="The interactive workflow: questions logged, multi-page answers become notes, unanswerable questions go to open-questions.md, repo questions produce repo notes that re-enter ingest." title="The interactive workflow: questions logged, multi-page answers become notes, unanswerable questions go to open-questions.md, repo questions produce repo notes that re-enter ingest." srcset="https://substackcdn.com/image/fetch/$s_!zKtc!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F854c7021-31a8-4d97-ad62-c3736b6ac9a0_1200x572.png 424w, https://substackcdn.com/image/fetch/$s_!zKtc!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F854c7021-31a8-4d97-ad62-c3736b6ac9a0_1200x572.png 848w, https://substackcdn.com/image/fetch/$s_!zKtc!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F854c7021-31a8-4d97-ad62-c3736b6ac9a0_1200x572.png 1272w, https://substackcdn.com/image/fetch/$s_!zKtc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F854c7021-31a8-4d97-ad62-c3736b6ac9a0_1200x572.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Image 12: One question, four possible outcomes. Only repo notes flow back into the graph.</em></figcaption></figure></div><p>One thing I am still trying to calibrate is when to create a note from multiple concepts or entities, since doing this every time can quickly add a lot of noise.</p><h2>So where are LLM wikis actually useful?</h2><p>LLM wikis burn tokens at ingest, so for a one-off question over a pile of files, you waste tokens and time. They&#8217;re also hard to maintain and scale next to a full knowledge graph, which makes them the wrong long-term memory for a product serving millions of users. There, use a real database, as I show in <a href="https://www.decodingai.com/p/how-to-implement-a-unified-memory-from-scratch">implementing a unified memory from scratch</a>.</p><p>Also, transforming your codebase into a wiki is an anti-pattern. You&#8217;d re-sync the wiki on every commit, and the code is already a graph that coding agents are trained to walk. The repo is already the wiki. You have to pick your battles. It doesn&#8217;t work for everything.</p><p>Where they shine is personal long-term memory scoped to one project or use case. Unlike Karpathy&#8217;s wikis, mine don&#8217;t outlive the project. Even though I can maintain them, I use them as one-off memory layers for researching a project, writing an article, or implementing a feature. Whenever the project is done, I can just kill them.</p><p>The hardcore case is my book. One wiki holds 196 raw sources, 7 repos, and 399 nodes, and I&#8217;m only at chapter 5 of 12. A second, separate wiki models the context between chapters. It answers questions like <em>&#8220;Are chunking strategies already covered in depth in previous chapters?&#8221;</em> across a ~350-page draft with hundreds of layered concepts.</p><p>Alternatives exist, like <a href="https://github.com/Graphify-Labs/graphify">graphify</a>, a Claude Code skill that turns any folder into a queryable knowledge graph, but I keep everything light with my own custom skill.</p><p>So I encourage you to go to <a href="https://github.com/decodingai-magazine/llm-wiki-workshop/tree/main">our repository</a>, look at the 3 exercises (vanilla, ingest, and interactive), understand the principles behind them, and build your own version.</p><p><em>But here is what I&#8217;m wondering:</em></p><blockquote><p><em><strong>What is the No. 1 use case you&#8217;ve used, or plan to use, LLM wikis for?</strong></em></p></blockquote><p><em>Click the button below and tell me. I read every response.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://www.decodingai.com/p/build-llm-wiki-first-principles/comments&quot;,&quot;text&quot;:&quot;Leave a comment&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://www.decodingai.com/p/build-llm-wiki-first-principles/comments"><span>Leave a comment</span></a></p><div><hr></div><p><em>Enjoyed the article? The most sincere compliment is to restack this for your readers.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://www.decodingai.com/p/build-llm-wiki-first-principles?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;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://www.decodingai.com/p/build-llm-wiki-first-principles?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p><div><hr></div><div class="callout-block" data-callout="true"><h4>Whenever you&#8217;re ready, here is how I can help you</h4><p><em>Go from agent user to agent builder.</em> Master the foundations of AI agents and turn fragile demo code into reliable, production-ready systems with my course, <strong><a href="https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering">Agent Engineering: Building Multi-Agent Systems</a></strong> (made with Towards AI).</p><p>35 lessons. Pure foundations from scratch. 4 mini-projects. 2 production systems. A certificate and direct access to me &amp; industry experts in our Discord.</p><p>Built for software and data professionals transitioning into AI engineering. <em>Rated 5/5 with 300+ students. The first 7 lessons are free:</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering&quot;,&quot;text&quot;:&quot;Start here&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering"><span>Start here</span></a></p><p><em>Not ready to commit?</em> Start with our <strong><a href="https://email-course.towardsai.net/?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering">free Agent AI Engineering Guide</a></strong>, a 6-day email course on the mistakes that silently break AI agents in production.</p></div><div><hr></div><h2>Images &amp; videos</h2><p>If not otherwise stated, all images and videos are created by the author.</p>]]></content:encoded></item><item><title><![CDATA[Context Inspector: Measuring Context Quality Before the LLM Call]]></title><description><![CDATA[6 signals that catch missing, stale, or conflicting evidence in your RAG pipeline]]></description><link>https://www.decodingai.com/p/pre-inference-rag-evaluation-metrics</link><guid isPermaLink="false">https://www.decodingai.com/p/pre-inference-rag-evaluation-metrics</guid><pubDate>Sat, 17 Oct 2026 11:01:11 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!Sl4v!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5bb7790f-878c-4c45-8ffd-6096cc9c43dd_1376x768.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><strong>Paul:&nbsp;</strong>Today, Decoding AI features two engineering leaders from American Express, Thangavel Subramaniam and Saurabh Gupta.</p><p><a href="https://americanexpress.io/u/thangavelsubramaniam/">Thangavel</a>&nbsp;is a Senior Software Engineer focused on applied ML and scalable software solutions built with cloud technologies.&nbsp;<a href="https://americanexpress.io/u/saurabhgupta/">Saurabh</a>&nbsp;is an Engineering Director with 10+ years of experience building real-time ML decisioning and personalization platforms at scale.</p><p>Let&#8217;s hear from them! &#128251;</p><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_!Sl4v!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5bb7790f-878c-4c45-8ffd-6096cc9c43dd_1376x768.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Sl4v!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5bb7790f-878c-4c45-8ffd-6096cc9c43dd_1376x768.png 424w, https://substackcdn.com/image/fetch/$s_!Sl4v!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5bb7790f-878c-4c45-8ffd-6096cc9c43dd_1376x768.png 848w, https://substackcdn.com/image/fetch/$s_!Sl4v!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5bb7790f-878c-4c45-8ffd-6096cc9c43dd_1376x768.png 1272w, https://substackcdn.com/image/fetch/$s_!Sl4v!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5bb7790f-878c-4c45-8ffd-6096cc9c43dd_1376x768.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Sl4v!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5bb7790f-878c-4c45-8ffd-6096cc9c43dd_1376x768.png" width="1376" height="768" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5bb7790f-878c-4c45-8ffd-6096cc9c43dd_1376x768.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:768,&quot;width&quot;:1376,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1347561,&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://www.decodingai.com/i/220187631?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5bb7790f-878c-4c45-8ffd-6096cc9c43dd_1376x768.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_!Sl4v!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5bb7790f-878c-4c45-8ffd-6096cc9c43dd_1376x768.png 424w, https://substackcdn.com/image/fetch/$s_!Sl4v!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5bb7790f-878c-4c45-8ffd-6096cc9c43dd_1376x768.png 848w, https://substackcdn.com/image/fetch/$s_!Sl4v!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5bb7790f-878c-4c45-8ffd-6096cc9c43dd_1376x768.png 1272w, https://substackcdn.com/image/fetch/$s_!Sl4v!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5bb7790f-878c-4c45-8ffd-6096cc9c43dd_1376x768.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><blockquote><p><em>All examples in this article are synthetic &#8212; they illustrate engineering patterns only, not production or customer data.</em></p></blockquote><p>Most Gen AI evaluation focuses on the generated response: whether it is accurate, grounded, and safe. Those evaluations are essential, but they cannot detect problems that originate before the model generates a single token.</p><p>In Retrieval-Augmented Generation, or RAG, the model is only as good as what it&#8217;s handed. If the retrieved context is stale, one-sided, missing a required source, or quietly contradicts itself, the model can still produce a fluent, confident-sounding answer &#8212; one that happens to be wrong. By the time you&#8217;re evaluating that answer, you&#8217;re debugging the wrong layer.</p><p>Context Inspector is a research prototype built to catch this type of issue earlier, at the moment after context is assembled but before it&#8217;s sent to the LLM. It asks a simple question: has the model been given a reliable basis to answer before we spend the inference call finding out?</p><p>In this article, we&#8217;ll look at what makes context &#8220;good&#8221; before inference, how to measure common failure modes such as missing, stale, or conflicting evidence, and how those signals can be used to catch context-quality problems before the LLM call.</p><h2>Pre-Inference Quality vs. Post-Inference Quality</h2><p>Post-inference quality asks whether the model produced a good answer. This response-centric evaluation examines the generated output for accuracy, clarity, groundedness, completeness, tone, and policy alignment.</p><p>Pre-inference context quality asks a different question: did we give the model the right evidence to produce a good answer? This becomes an evidence-centric approach. It evaluates the assembled context before generation and asks whether the context is sufficient, current, balanced, consistent, and appropriate for the task.</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;plaintext&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-plaintext">User query
    -&gt; Retrieval
    -&gt; Context assembly
    -&gt; Pre-inference context inspection
    -&gt; LLM call
    -&gt; Generated response
    -&gt; Post-inference evaluation</code></pre></div><p>Both stages matter. Post-inference evaluation validates the final answer, while pre-inference inspection validates the evidence that the model is about to use.</p><p>The distinction is important because many RAG failures are not caused by the model alone. They are caused by context assembly failures.</p><div class="callout-block" data-callout="true"><h2><a href="https://conf.cosprints.ai/?utm_source=decodingaimagazine&amp;utm_medium=partner&amp;utm_campaign=conf-oct29">AI Champions Big FREE Virtual Conference, 29 October (Affiliate)</a></h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!1KgG!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1f83231f-b59f-4324-bc19-67a9be6e77e1_2400x1260.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!1KgG!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1f83231f-b59f-4324-bc19-67a9be6e77e1_2400x1260.png 424w, https://substackcdn.com/image/fetch/$s_!1KgG!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1f83231f-b59f-4324-bc19-67a9be6e77e1_2400x1260.png 848w, https://substackcdn.com/image/fetch/$s_!1KgG!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1f83231f-b59f-4324-bc19-67a9be6e77e1_2400x1260.png 1272w, https://substackcdn.com/image/fetch/$s_!1KgG!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1f83231f-b59f-4324-bc19-67a9be6e77e1_2400x1260.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!1KgG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1f83231f-b59f-4324-bc19-67a9be6e77e1_2400x1260.png" width="1456" height="764" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1f83231f-b59f-4324-bc19-67a9be6e77e1_2400x1260.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:764,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1462941,&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://www.decodingai.com/i/220187631?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1f83231f-b59f-4324-bc19-67a9be6e77e1_2400x1260.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_!1KgG!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1f83231f-b59f-4324-bc19-67a9be6e77e1_2400x1260.png 424w, https://substackcdn.com/image/fetch/$s_!1KgG!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1f83231f-b59f-4324-bc19-67a9be6e77e1_2400x1260.png 848w, https://substackcdn.com/image/fetch/$s_!1KgG!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1f83231f-b59f-4324-bc19-67a9be6e77e1_2400x1260.png 1272w, https://substackcdn.com/image/fetch/$s_!1KgG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1f83231f-b59f-4324-bc19-67a9be6e77e1_2400x1260.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>Join 5000+ attendees and hear from 20+ speakers from Google, Amazon, DoorDash and more during 4 hours of AI case studies.</p><p>These sessions will help you become AI-native and build an AI-first<br>organization!</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://conf.cosprints.ai/?utm_source=decodingaimagazine&amp;utm_medium=partner&amp;utm_campaign=conf-oct29&quot;,&quot;text&quot;:&quot;Register here&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://conf.cosprints.ai/?utm_source=decodingaimagazine&amp;utm_medium=partner&amp;utm_campaign=conf-oct29"><span>Register here</span></a></p></div><h2>Why Pre-Inference Context Quality Matters</h2><p>In a RAG-based Gen AI system, the LLM does not receive only the user&#8217;s question. It receives a carefully assembled context window that may include the system prompt, tool definitions, retrieved knowledge, conversation history, memory, agent scratchpad content, and the current user message. Each layer serves a different purpose, and each consumes part of the available token budget.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!WU3c!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7cb2db8a-94dd-4fc4-9e09-82d041bfb929_1500x835.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!WU3c!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7cb2db8a-94dd-4fc4-9e09-82d041bfb929_1500x835.png 424w, https://substackcdn.com/image/fetch/$s_!WU3c!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7cb2db8a-94dd-4fc4-9e09-82d041bfb929_1500x835.png 848w, https://substackcdn.com/image/fetch/$s_!WU3c!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7cb2db8a-94dd-4fc4-9e09-82d041bfb929_1500x835.png 1272w, https://substackcdn.com/image/fetch/$s_!WU3c!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7cb2db8a-94dd-4fc4-9e09-82d041bfb929_1500x835.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!WU3c!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7cb2db8a-94dd-4fc4-9e09-82d041bfb929_1500x835.png" width="1456" height="811" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7cb2db8a-94dd-4fc4-9e09-82d041bfb929_1500x835.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:811,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!WU3c!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7cb2db8a-94dd-4fc4-9e09-82d041bfb929_1500x835.png 424w, https://substackcdn.com/image/fetch/$s_!WU3c!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7cb2db8a-94dd-4fc4-9e09-82d041bfb929_1500x835.png 848w, https://substackcdn.com/image/fetch/$s_!WU3c!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7cb2db8a-94dd-4fc4-9e09-82d041bfb929_1500x835.png 1272w, https://substackcdn.com/image/fetch/$s_!WU3c!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7cb2db8a-94dd-4fc4-9e09-82d041bfb929_1500x835.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Figure 1: Representative LLM context-window anatomy. Context Inspector operates pre- inference on the RAG context layer, measuring coverage, utilization, source starvation, and contradiction risk before the LLM call.</em></figcaption></figure></div><p>The diagram shows that the RAG context layer is only one part of the full prompt, but it is often the layer that determines whether the model has the right evidence to answer. In the representative allocation, the RAG context occupies approximately 18,000 tokens out of a 128,000-token context window. The remaining budget is allocated across system instructions, tool definitions, conversation history, memory, scratchpad content, the current user message, and unused headroom.</p><p>A larger context window does not automatically create a better answer. A model can have plenty of remaining token capacity and still receive poor-quality evidence. The RAG layer may be incomplete, stale, contradictory, or dominated by a single source. In those cases, the model may generate an answer that appears confident but is not properly grounded.</p><p>This is where Context Inspector is positioned. Rather than inspecting every part of the prompt or waiting until after the model generates a response, Context Inspector fires pre-inference and focuses on the retrieved context layer. It evaluates whether the RAG context is fit for purpose before the LLM call happens.</p><p>From a privacy and governance perspective, this scoping is intentional. Context Inspector can operate on approved metadata and minimized signals such as source, version, timestamp, token count, and policy labels. The purpose is not to broaden access to user or system data. The purpose is to reduce risk by preventing low-quality or inappropriate context from entering the prompt.</p><h2>What Does &#8220;Good Context&#8221; Even Mean?</h2><p>Let the user query be represented as: <code>q</code></p><p>Let the retrieval system return a candidate set of chunks:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ztUO!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9a39143-2c7a-4a4c-944d-167548df90f4_596x154.png 424w, https://substackcdn.com/image/fetch/$s_!ztUO!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9a39143-2c7a-4a4c-944d-167548df90f4_596x154.png 848w, https://substackcdn.com/image/fetch/$s_!ztUO!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9a39143-2c7a-4a4c-944d-167548df90f4_596x154.png 1272w, https://substackcdn.com/image/fetch/$s_!ztUO!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9a39143-2c7a-4a4c-944d-167548df90f4_596x154.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!ztUO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9a39143-2c7a-4a4c-944d-167548df90f4_596x154.png" width="376" height="97.15436241610739" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b9a39143-2c7a-4a4c-944d-167548df90f4_596x154.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:154,&quot;width&quot;:596,&quot;resizeWidth&quot;:376,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ztUO!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9a39143-2c7a-4a4c-944d-167548df90f4_596x154.png 424w, https://substackcdn.com/image/fetch/$s_!ztUO!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9a39143-2c7a-4a4c-944d-167548df90f4_596x154.png 848w, https://substackcdn.com/image/fetch/$s_!ztUO!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9a39143-2c7a-4a4c-944d-167548df90f4_596x154.png 1272w, https://substackcdn.com/image/fetch/$s_!ztUO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9a39143-2c7a-4a4c-944d-167548df90f4_596x154.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>Represent each chunk as:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!2bRL!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3481fcd6-4d55-404f-9827-e49ff98f792b_770x130.png 424w, https://substackcdn.com/image/fetch/$s_!2bRL!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3481fcd6-4d55-404f-9827-e49ff98f792b_770x130.png 848w, https://substackcdn.com/image/fetch/$s_!2bRL!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3481fcd6-4d55-404f-9827-e49ff98f792b_770x130.png 1272w, https://substackcdn.com/image/fetch/$s_!2bRL!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3481fcd6-4d55-404f-9827-e49ff98f792b_770x130.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!2bRL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3481fcd6-4d55-404f-9827-e49ff98f792b_770x130.png" width="480" height="81.03896103896103" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3481fcd6-4d55-404f-9827-e49ff98f792b_770x130.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:130,&quot;width&quot;:770,&quot;resizeWidth&quot;:480,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!2bRL!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3481fcd6-4d55-404f-9827-e49ff98f792b_770x130.png 424w, https://substackcdn.com/image/fetch/$s_!2bRL!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3481fcd6-4d55-404f-9827-e49ff98f792b_770x130.png 848w, https://substackcdn.com/image/fetch/$s_!2bRL!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3481fcd6-4d55-404f-9827-e49ff98f792b_770x130.png 1272w, https://substackcdn.com/image/fetch/$s_!2bRL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3481fcd6-4d55-404f-9827-e49ff98f792b_770x130.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>where x~i is chunk text, s~i is source, T~i is token count, R~i is retrieval relevance, t~i is timestamp, v~i is version, and m~i is metadata.</p><p>The final context sent to the model is a selected subset:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!CvN4!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff445c5cf-99ed-4ce8-a5ab-effef7bf100c_242x142.png 424w, https://substackcdn.com/image/fetch/$s_!CvN4!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff445c5cf-99ed-4ce8-a5ab-effef7bf100c_242x142.png 848w, https://substackcdn.com/image/fetch/$s_!CvN4!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff445c5cf-99ed-4ce8-a5ab-effef7bf100c_242x142.png 1272w, https://substackcdn.com/image/fetch/$s_!CvN4!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff445c5cf-99ed-4ce8-a5ab-effef7bf100c_242x142.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!CvN4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff445c5cf-99ed-4ce8-a5ab-effef7bf100c_242x142.png" width="170" height="99.75206611570248" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f445c5cf-99ed-4ce8-a5ab-effef7bf100c_242x142.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:142,&quot;width&quot;:242,&quot;resizeWidth&quot;:170,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!CvN4!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff445c5cf-99ed-4ce8-a5ab-effef7bf100c_242x142.png 424w, https://substackcdn.com/image/fetch/$s_!CvN4!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff445c5cf-99ed-4ce8-a5ab-effef7bf100c_242x142.png 848w, https://substackcdn.com/image/fetch/$s_!CvN4!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff445c5cf-99ed-4ce8-a5ab-effef7bf100c_242x142.png 1272w, https://substackcdn.com/image/fetch/$s_!CvN4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff445c5cf-99ed-4ce8-a5ab-effef7bf100c_242x142.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>The selected context must satisfy a token budget:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!I4T2!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54a4ee39-c9d4-4056-8e41-04acc72f4c5e_378x234.png 424w, https://substackcdn.com/image/fetch/$s_!I4T2!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54a4ee39-c9d4-4056-8e41-04acc72f4c5e_378x234.png 848w, https://substackcdn.com/image/fetch/$s_!I4T2!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54a4ee39-c9d4-4056-8e41-04acc72f4c5e_378x234.png 1272w, https://substackcdn.com/image/fetch/$s_!I4T2!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54a4ee39-c9d4-4056-8e41-04acc72f4c5e_378x234.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!I4T2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54a4ee39-c9d4-4056-8e41-04acc72f4c5e_378x234.png" width="208" height="128.76190476190476" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/54a4ee39-c9d4-4056-8e41-04acc72f4c5e_378x234.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:234,&quot;width&quot;:378,&quot;resizeWidth&quot;:208,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!I4T2!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54a4ee39-c9d4-4056-8e41-04acc72f4c5e_378x234.png 424w, https://substackcdn.com/image/fetch/$s_!I4T2!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54a4ee39-c9d4-4056-8e41-04acc72f4c5e_378x234.png 848w, https://substackcdn.com/image/fetch/$s_!I4T2!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54a4ee39-c9d4-4056-8e41-04acc72f4c5e_378x234.png 1272w, https://substackcdn.com/image/fetch/$s_!I4T2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54a4ee39-c9d4-4056-8e41-04acc72f4c5e_378x234.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><h3>Example</h3><p>Suppose the token budget is B = 20,000. The selected context contains four chunks with token counts 2,200, 1,800, 6,000, and 1,200. The total token use is:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!HoWf!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe68fbc5c-42ce-4ceb-9c79-642768416615_736x158.png 424w, https://substackcdn.com/image/fetch/$s_!HoWf!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe68fbc5c-42ce-4ceb-9c79-642768416615_736x158.png 848w, https://substackcdn.com/image/fetch/$s_!HoWf!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe68fbc5c-42ce-4ceb-9c79-642768416615_736x158.png 1272w, https://substackcdn.com/image/fetch/$s_!HoWf!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe68fbc5c-42ce-4ceb-9c79-642768416615_736x158.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!HoWf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe68fbc5c-42ce-4ceb-9c79-642768416615_736x158.png" width="520" height="111.6304347826087" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e68fbc5c-42ce-4ceb-9c79-642768416615_736x158.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:158,&quot;width&quot;:736,&quot;resizeWidth&quot;:520,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!HoWf!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe68fbc5c-42ce-4ceb-9c79-642768416615_736x158.png 424w, https://substackcdn.com/image/fetch/$s_!HoWf!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe68fbc5c-42ce-4ceb-9c79-642768416615_736x158.png 848w, https://substackcdn.com/image/fetch/$s_!HoWf!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe68fbc5c-42ce-4ceb-9c79-642768416615_736x158.png 1272w, https://substackcdn.com/image/fetch/$s_!HoWf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe68fbc5c-42ce-4ceb-9c79-642768416615_736x158.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>Because 11,200 &#8804; 20,000, the selected context satisfies the token budget. However, satisfying the budget does not prove that the context is good. It only proves that it fits. The objective is not simply to maximize relevance. A high-quality context package may need to satisfy multiple constraints at once: source coverage, freshness, token efficiency, contradiction avoidance, and policy admissibility. This makes pre-inference context quality both a measurement problem and an optimization challenge.</p><h2>The Context Quality Vector (Six Numbers Instead of One Score)</h2><p>A practical representation is a context-quality vector:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!LxUv!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99780e3b-b1c9-49e2-acd3-c62ca08c4c61_1172x160.png 424w, https://substackcdn.com/image/fetch/$s_!LxUv!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99780e3b-b1c9-49e2-acd3-c62ca08c4c61_1172x160.png 848w, https://substackcdn.com/image/fetch/$s_!LxUv!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99780e3b-b1c9-49e2-acd3-c62ca08c4c61_1172x160.png 1272w, https://substackcdn.com/image/fetch/$s_!LxUv!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99780e3b-b1c9-49e2-acd3-c62ca08c4c61_1172x160.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!LxUv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99780e3b-b1c9-49e2-acd3-c62ca08c4c61_1172x160.png" width="620" height="84.64163822525597" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/99780e3b-b1c9-49e2-acd3-c62ca08c4c61_1172x160.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:160,&quot;width&quot;:1172,&quot;resizeWidth&quot;:620,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!LxUv!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99780e3b-b1c9-49e2-acd3-c62ca08c4c61_1172x160.png 424w, https://substackcdn.com/image/fetch/$s_!LxUv!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99780e3b-b1c9-49e2-acd3-c62ca08c4c61_1172x160.png 848w, https://substackcdn.com/image/fetch/$s_!LxUv!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99780e3b-b1c9-49e2-acd3-c62ca08c4c61_1172x160.png 1272w, https://substackcdn.com/image/fetch/$s_!LxUv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99780e3b-b1c9-49e2-acd3-c62ca08c4c61_1172x160.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>In this vector, &#120588; represents coverage, &#120591; represents token utilization, &#120575; represents source starvation, &#120581; represents contradiction density, &#120601; represents freshness, and &#120587; represents policy admissibility.</p><h3>Example</h3><p>A context package may produce:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!IcOg!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8dec8dbb-7eee-4318-83a3-f3da58b26d1e_608x162.png 424w, https://substackcdn.com/image/fetch/$s_!IcOg!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8dec8dbb-7eee-4318-83a3-f3da58b26d1e_608x162.png 848w, https://substackcdn.com/image/fetch/$s_!IcOg!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8dec8dbb-7eee-4318-83a3-f3da58b26d1e_608x162.png 1272w, https://substackcdn.com/image/fetch/$s_!IcOg!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8dec8dbb-7eee-4318-83a3-f3da58b26d1e_608x162.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!IcOg!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8dec8dbb-7eee-4318-83a3-f3da58b26d1e_608x162.png" width="420" height="111.90789473684211" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8dec8dbb-7eee-4318-83a3-f3da58b26d1e_608x162.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:162,&quot;width&quot;:608,&quot;resizeWidth&quot;:420,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!IcOg!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8dec8dbb-7eee-4318-83a3-f3da58b26d1e_608x162.png 424w, https://substackcdn.com/image/fetch/$s_!IcOg!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8dec8dbb-7eee-4318-83a3-f3da58b26d1e_608x162.png 848w, https://substackcdn.com/image/fetch/$s_!IcOg!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8dec8dbb-7eee-4318-83a3-f3da58b26d1e_608x162.png 1272w, https://substackcdn.com/image/fetch/$s_!IcOg!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8dec8dbb-7eee-4318-83a3-f3da58b26d1e_608x162.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>This means the context covers 75% of the required aspects, uses 56% of the token budget, has one-third of required sources starved, has contradiction density of 17%, has freshness score of 81%, and contains only policy-admissible chunks. The vector is useful because it explains why a context may be risky rather than hiding everything behind a single score.</p><h2>Coverage: Is the Required Evidence Present?</h2><p>Coverage measures whether the selected context contains the information needed to answer the query. Let the required answer aspects for query q be:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!kvJD!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a55e299-3112-4eaf-bb87-1fefb185e1b0_374x148.png 424w, https://substackcdn.com/image/fetch/$s_!kvJD!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a55e299-3112-4eaf-bb87-1fefb185e1b0_374x148.png 848w, https://substackcdn.com/image/fetch/$s_!kvJD!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a55e299-3112-4eaf-bb87-1fefb185e1b0_374x148.png 1272w, https://substackcdn.com/image/fetch/$s_!kvJD!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a55e299-3112-4eaf-bb87-1fefb185e1b0_374x148.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!kvJD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a55e299-3112-4eaf-bb87-1fefb185e1b0_374x148.png" width="320" height="126.63101604278074" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9a55e299-3112-4eaf-bb87-1fefb185e1b0_374x148.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:148,&quot;width&quot;:374,&quot;resizeWidth&quot;:320,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!kvJD!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a55e299-3112-4eaf-bb87-1fefb185e1b0_374x148.png 424w, https://substackcdn.com/image/fetch/$s_!kvJD!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a55e299-3112-4eaf-bb87-1fefb185e1b0_374x148.png 848w, https://substackcdn.com/image/fetch/$s_!kvJD!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a55e299-3112-4eaf-bb87-1fefb185e1b0_374x148.png 1272w, https://substackcdn.com/image/fetch/$s_!kvJD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a55e299-3112-4eaf-bb87-1fefb185e1b0_374x148.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>Let A(d~i) be the set of required aspects covered by chunk d~i:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!kLu-!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F028b7642-807a-4b1e-aa0c-968cd272662d_750x336.png 424w, https://substackcdn.com/image/fetch/$s_!kLu-!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F028b7642-807a-4b1e-aa0c-968cd272662d_750x336.png 848w, https://substackcdn.com/image/fetch/$s_!kLu-!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F028b7642-807a-4b1e-aa0c-968cd272662d_750x336.png 1272w, https://substackcdn.com/image/fetch/$s_!kLu-!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F028b7642-807a-4b1e-aa0c-968cd272662d_750x336.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!kLu-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F028b7642-807a-4b1e-aa0c-968cd272662d_750x336.png" width="520" height="232.96" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/028b7642-807a-4b1e-aa0c-968cd272662d_750x336.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:336,&quot;width&quot;:750,&quot;resizeWidth&quot;:520,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!kLu-!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F028b7642-807a-4b1e-aa0c-968cd272662d_750x336.png 424w, https://substackcdn.com/image/fetch/$s_!kLu-!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F028b7642-807a-4b1e-aa0c-968cd272662d_750x336.png 848w, https://substackcdn.com/image/fetch/$s_!kLu-!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F028b7642-807a-4b1e-aa0c-968cd272662d_750x336.png 1272w, https://substackcdn.com/image/fetch/$s_!kLu-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F028b7642-807a-4b1e-aa0c-968cd272662d_750x336.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>Coverage is defined as:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!n4__!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdfeeaa8-9ded-480c-b53b-4b00a0a50b12_1142x358.png 424w, https://substackcdn.com/image/fetch/$s_!n4__!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdfeeaa8-9ded-480c-b53b-4b00a0a50b12_1142x358.png 848w, https://substackcdn.com/image/fetch/$s_!n4__!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdfeeaa8-9ded-480c-b53b-4b00a0a50b12_1142x358.png 1272w, https://substackcdn.com/image/fetch/$s_!n4__!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdfeeaa8-9ded-480c-b53b-4b00a0a50b12_1142x358.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!n4__!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdfeeaa8-9ded-480c-b53b-4b00a0a50b12_1142x358.png" width="620" height="194.36077057793344" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fdfeeaa8-9ded-480c-b53b-4b00a0a50b12_1142x358.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:358,&quot;width&quot;:1142,&quot;resizeWidth&quot;:620,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!n4__!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdfeeaa8-9ded-480c-b53b-4b00a0a50b12_1142x358.png 424w, https://substackcdn.com/image/fetch/$s_!n4__!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdfeeaa8-9ded-480c-b53b-4b00a0a50b12_1142x358.png 848w, https://substackcdn.com/image/fetch/$s_!n4__!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdfeeaa8-9ded-480c-b53b-4b00a0a50b12_1142x358.png 1272w, https://substackcdn.com/image/fetch/$s_!n4__!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdfeeaa8-9ded-480c-b53b-4b00a0a50b12_1142x358.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>A weighted version can account for aspect importance:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Hyau!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b602b12-1a31-4ffa-9d77-145bdb25c6a3_610x236.png 424w, https://substackcdn.com/image/fetch/$s_!Hyau!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b602b12-1a31-4ffa-9d77-145bdb25c6a3_610x236.png 848w, https://substackcdn.com/image/fetch/$s_!Hyau!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b602b12-1a31-4ffa-9d77-145bdb25c6a3_610x236.png 1272w, https://substackcdn.com/image/fetch/$s_!Hyau!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b602b12-1a31-4ffa-9d77-145bdb25c6a3_610x236.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!Hyau!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b602b12-1a31-4ffa-9d77-145bdb25c6a3_610x236.png" width="420" height="162.49180327868854" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3b602b12-1a31-4ffa-9d77-145bdb25c6a3_610x236.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:236,&quot;width&quot;:610,&quot;resizeWidth&quot;:420,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Hyau!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b602b12-1a31-4ffa-9d77-145bdb25c6a3_610x236.png 424w, https://substackcdn.com/image/fetch/$s_!Hyau!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b602b12-1a31-4ffa-9d77-145bdb25c6a3_610x236.png 848w, https://substackcdn.com/image/fetch/$s_!Hyau!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b602b12-1a31-4ffa-9d77-145bdb25c6a3_610x236.png 1272w, https://substackcdn.com/image/fetch/$s_!Hyau!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b602b12-1a31-4ffa-9d77-145bdb25c6a3_610x236.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>Here, w~j represents the importance of aspect a~j, and I(&#8901;) is an indicator function.</p><h3>Example</h3><p>Suppose a query requires four aspects: eligibility, effective date, steps, and availability. The selected context covers eligibility, effective date, and steps, but it does not cover availability. Unweighted coverage is:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!PeJE!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6f79ce8-f2cf-4d6e-8ed4-7a7796404faa_1326x238.png 424w, https://substackcdn.com/image/fetch/$s_!PeJE!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6f79ce8-f2cf-4d6e-8ed4-7a7796404faa_1326x238.png 848w, https://substackcdn.com/image/fetch/$s_!PeJE!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6f79ce8-f2cf-4d6e-8ed4-7a7796404faa_1326x238.png 1272w, https://substackcdn.com/image/fetch/$s_!PeJE!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6f79ce8-f2cf-4d6e-8ed4-7a7796404faa_1326x238.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!PeJE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6f79ce8-f2cf-4d6e-8ed4-7a7796404faa_1326x238.png" width="620" height="111.28205128205128" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a6f79ce8-f2cf-4d6e-8ed4-7a7796404faa_1326x238.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:238,&quot;width&quot;:1326,&quot;resizeWidth&quot;:620,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!PeJE!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6f79ce8-f2cf-4d6e-8ed4-7a7796404faa_1326x238.png 424w, https://substackcdn.com/image/fetch/$s_!PeJE!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6f79ce8-f2cf-4d6e-8ed4-7a7796404faa_1326x238.png 848w, https://substackcdn.com/image/fetch/$s_!PeJE!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6f79ce8-f2cf-4d6e-8ed4-7a7796404faa_1326x238.png 1272w, https://substackcdn.com/image/fetch/$s_!PeJE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6f79ce8-f2cf-4d6e-8ed4-7a7796404faa_1326x238.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>For a weighted example, suppose the aspect weights are 0.40, 0.20, 0.25, and 0.15, respectively. Because the first three aspects are covered, weighted coverage is:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!-NNM!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ddf11e6-31de-4165-9644-22ea245ef133_536x248.png 424w, https://substackcdn.com/image/fetch/$s_!-NNM!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ddf11e6-31de-4165-9644-22ea245ef133_536x248.png 848w, https://substackcdn.com/image/fetch/$s_!-NNM!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ddf11e6-31de-4165-9644-22ea245ef133_536x248.png 1272w, https://substackcdn.com/image/fetch/$s_!-NNM!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ddf11e6-31de-4165-9644-22ea245ef133_536x248.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!-NNM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ddf11e6-31de-4165-9644-22ea245ef133_536x248.png" width="320" height="148.0597014925373" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7ddf11e6-31de-4165-9644-22ea245ef133_536x248.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:248,&quot;width&quot;:536,&quot;resizeWidth&quot;:320,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!-NNM!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ddf11e6-31de-4165-9644-22ea245ef133_536x248.png 424w, https://substackcdn.com/image/fetch/$s_!-NNM!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ddf11e6-31de-4165-9644-22ea245ef133_536x248.png 848w, https://substackcdn.com/image/fetch/$s_!-NNM!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ddf11e6-31de-4165-9644-22ea245ef133_536x248.png 1272w, https://substackcdn.com/image/fetch/$s_!-NNM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ddf11e6-31de-4165-9644-22ea245ef133_536x248.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>The weighted score shows that the selected context contains most of the high-value evidence, but the missing availability aspect still represents a concrete risk.</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">def coverage_score(selected_chunks, required_aspects):

    covered = set()

    for chunk in selected_chunks:

        covered.update(chunk.get(&#8221;aspects&#8221;, []))

    if not required_aspects:

        return 1.0

    return len(covered.intersection(required_aspects)) / len(required_aspects

)</code></pre></div><h2>Token Utilization: Is the Context Window Being Used Effectively?</h2><p>Every LLM call operates under a token budget. Too little context can produce under-informed responses. Too much context can increase cost, latency, and noise.</p><p>Let B be the token budget and T~i be the token count of chunk d~i. Token utilization is:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Q9hm!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe28fe4ce-224a-45cb-b5ae-583d9ffb5a62_1030x366.png 424w, https://substackcdn.com/image/fetch/$s_!Q9hm!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe28fe4ce-224a-45cb-b5ae-583d9ffb5a62_1030x366.png 848w, https://substackcdn.com/image/fetch/$s_!Q9hm!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe28fe4ce-224a-45cb-b5ae-583d9ffb5a62_1030x366.png 1272w, https://substackcdn.com/image/fetch/$s_!Q9hm!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe28fe4ce-224a-45cb-b5ae-583d9ffb5a62_1030x366.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!Q9hm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe28fe4ce-224a-45cb-b5ae-583d9ffb5a62_1030x366.png" width="600" height="213.20388349514562" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e28fe4ce-224a-45cb-b5ae-583d9ffb5a62_1030x366.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:366,&quot;width&quot;:1030,&quot;resizeWidth&quot;:600,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Q9hm!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe28fe4ce-224a-45cb-b5ae-583d9ffb5a62_1030x366.png 424w, https://substackcdn.com/image/fetch/$s_!Q9hm!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe28fe4ce-224a-45cb-b5ae-583d9ffb5a62_1030x366.png 848w, https://substackcdn.com/image/fetch/$s_!Q9hm!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe28fe4ce-224a-45cb-b5ae-583d9ffb5a62_1030x366.png 1272w, https://substackcdn.com/image/fetch/$s_!Q9hm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe28fe4ce-224a-45cb-b5ae-583d9ffb5a62_1030x366.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>A simple utilization risk function is:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!5kXf!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60e10d12-028e-48b4-a127-14e13e7b3eed_702x238.png 424w, https://substackcdn.com/image/fetch/$s_!5kXf!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60e10d12-028e-48b4-a127-14e13e7b3eed_702x238.png 848w, https://substackcdn.com/image/fetch/$s_!5kXf!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60e10d12-028e-48b4-a127-14e13e7b3eed_702x238.png 1272w, https://substackcdn.com/image/fetch/$s_!5kXf!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60e10d12-028e-48b4-a127-14e13e7b3eed_702x238.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!5kXf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60e10d12-028e-48b4-a127-14e13e7b3eed_702x238.png" width="500" height="169.51566951566952" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/60e10d12-028e-48b4-a127-14e13e7b3eed_702x238.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:238,&quot;width&quot;:702,&quot;resizeWidth&quot;:500,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!5kXf!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60e10d12-028e-48b4-a127-14e13e7b3eed_702x238.png 424w, https://substackcdn.com/image/fetch/$s_!5kXf!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60e10d12-028e-48b4-a127-14e13e7b3eed_702x238.png 848w, https://substackcdn.com/image/fetch/$s_!5kXf!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60e10d12-028e-48b4-a127-14e13e7b3eed_702x238.png 1272w, https://substackcdn.com/image/fetch/$s_!5kXf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60e10d12-028e-48b4-a127-14e13e7b3eed_702x238.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><h3>Example</h3><p>Suppose B = 20,000 and the selected context uses 11,200 tokens. Then:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!7Ytp!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe1c69b28-fa02-4085-a05d-395bca78dc79_702x284.png 424w, https://substackcdn.com/image/fetch/$s_!7Ytp!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe1c69b28-fa02-4085-a05d-395bca78dc79_702x284.png 848w, https://substackcdn.com/image/fetch/$s_!7Ytp!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe1c69b28-fa02-4085-a05d-395bca78dc79_702x284.png 1272w, https://substackcdn.com/image/fetch/$s_!7Ytp!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe1c69b28-fa02-4085-a05d-395bca78dc79_702x284.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!7Ytp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe1c69b28-fa02-4085-a05d-395bca78dc79_702x284.png" width="500" height="202.27920227920228" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e1c69b28-fa02-4085-a05d-395bca78dc79_702x284.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:284,&quot;width&quot;:702,&quot;resizeWidth&quot;:500,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!7Ytp!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe1c69b28-fa02-4085-a05d-395bca78dc79_702x284.png 424w, https://substackcdn.com/image/fetch/$s_!7Ytp!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe1c69b28-fa02-4085-a05d-395bca78dc79_702x284.png 848w, https://substackcdn.com/image/fetch/$s_!7Ytp!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe1c69b28-fa02-4085-a05d-395bca78dc79_702x284.png 1272w, https://substackcdn.com/image/fetch/$s_!7Ytp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe1c69b28-fa02-4085-a05d-395bca78dc79_702x284.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>If the configured healthy range is 0.10 &#8804; &#120591; &#8804; 0.90, then r~&#120591;(&#119862;) = 0. If a different context used 19,400 tokens, then:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!5NZv!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f0dd6b9-5917-4a9c-978b-f75cb7a3a6f2_572x176.png 424w, https://substackcdn.com/image/fetch/$s_!5NZv!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f0dd6b9-5917-4a9c-978b-f75cb7a3a6f2_572x176.png 848w, https://substackcdn.com/image/fetch/$s_!5NZv!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f0dd6b9-5917-4a9c-978b-f75cb7a3a6f2_572x176.png 1272w, https://substackcdn.com/image/fetch/$s_!5NZv!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f0dd6b9-5917-4a9c-978b-f75cb7a3a6f2_572x176.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!5NZv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f0dd6b9-5917-4a9c-978b-f75cb7a3a6f2_572x176.png" width="420" height="129.23076923076923" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0f0dd6b9-5917-4a9c-978b-f75cb7a3a6f2_572x176.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:176,&quot;width&quot;:572,&quot;resizeWidth&quot;:420,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!5NZv!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f0dd6b9-5917-4a9c-978b-f75cb7a3a6f2_572x176.png 424w, https://substackcdn.com/image/fetch/$s_!5NZv!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f0dd6b9-5917-4a9c-978b-f75cb7a3a6f2_572x176.png 848w, https://substackcdn.com/image/fetch/$s_!5NZv!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f0dd6b9-5917-4a9c-978b-f75cb7a3a6f2_572x176.png 1272w, https://substackcdn.com/image/fetch/$s_!5NZv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f0dd6b9-5917-4a9c-978b-f75cb7a3a6f2_572x176.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>Because 0.97 &gt; 0.90, the utilization risk would be 1. This does not mean the context is wrong, but it indicates token-budget pressure and a higher chance that important evidence was crowded out.</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">def token_utilization(selected_chunks, token_budget):

    used_tokens = sum(chunk[&#8221;tokens&#8221;] for chunk in selected_chunks)

    if token_budget &lt;= 0:

        raise ValueError(&#8221;token_budget must be positive&#8221;)

    return used_tokens / token_budget</code></pre></div><h2>Source Starvation: Are Required Sources Missing?</h2><p>Many enterprise workflows require evidence from more than one source. A reliable answer may depend on policy, procedure, current system status, or approved reference material. If one source dominates the context, other required sources may be starved.</p><p>Let S~q be the set of required sources:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!9kRb!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5f1b918-7774-4989-a041-6d06b8973bb3_700x252.png 424w, https://substackcdn.com/image/fetch/$s_!9kRb!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5f1b918-7774-4989-a041-6d06b8973bb3_700x252.png 848w, https://substackcdn.com/image/fetch/$s_!9kRb!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5f1b918-7774-4989-a041-6d06b8973bb3_700x252.png 1272w, https://substackcdn.com/image/fetch/$s_!9kRb!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5f1b918-7774-4989-a041-6d06b8973bb3_700x252.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!9kRb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5f1b918-7774-4989-a041-6d06b8973bb3_700x252.png" width="500" height="180" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a5f1b918-7774-4989-a041-6d06b8973bb3_700x252.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:252,&quot;width&quot;:700,&quot;resizeWidth&quot;:500,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!9kRb!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5f1b918-7774-4989-a041-6d06b8973bb3_700x252.png 424w, https://substackcdn.com/image/fetch/$s_!9kRb!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5f1b918-7774-4989-a041-6d06b8973bb3_700x252.png 848w, https://substackcdn.com/image/fetch/$s_!9kRb!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5f1b918-7774-4989-a041-6d06b8973bb3_700x252.png 1272w, https://substackcdn.com/image/fetch/$s_!9kRb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5f1b918-7774-4989-a041-6d06b8973bb3_700x252.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>Let n~s(C) be the number of selected chunks from source s:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!WBu2!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc6c1f90-1930-420c-a089-7ae89bfde858_988x302.png 424w, https://substackcdn.com/image/fetch/$s_!WBu2!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc6c1f90-1930-420c-a089-7ae89bfde858_988x302.png 848w, https://substackcdn.com/image/fetch/$s_!WBu2!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc6c1f90-1930-420c-a089-7ae89bfde858_988x302.png 1272w, https://substackcdn.com/image/fetch/$s_!WBu2!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc6c1f90-1930-420c-a089-7ae89bfde858_988x302.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!WBu2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc6c1f90-1930-420c-a089-7ae89bfde858_988x302.png" width="520" height="158.94736842105263" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/cc6c1f90-1930-420c-a089-7ae89bfde858_988x302.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:302,&quot;width&quot;:988,&quot;resizeWidth&quot;:520,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!WBu2!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc6c1f90-1930-420c-a089-7ae89bfde858_988x302.png 424w, https://substackcdn.com/image/fetch/$s_!WBu2!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc6c1f90-1930-420c-a089-7ae89bfde858_988x302.png 848w, https://substackcdn.com/image/fetch/$s_!WBu2!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc6c1f90-1930-420c-a089-7ae89bfde858_988x302.png 1272w, https://substackcdn.com/image/fetch/$s_!WBu2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc6c1f90-1930-420c-a089-7ae89bfde858_988x302.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>If each source has a minimum required count m~s, source starvation is:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ygb5!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a7ce686-5d8f-4950-8732-a16a1f084de0_602x250.png 424w, https://substackcdn.com/image/fetch/$s_!ygb5!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a7ce686-5d8f-4950-8732-a16a1f084de0_602x250.png 848w, https://substackcdn.com/image/fetch/$s_!ygb5!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a7ce686-5d8f-4950-8732-a16a1f084de0_602x250.png 1272w, https://substackcdn.com/image/fetch/$s_!ygb5!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a7ce686-5d8f-4950-8732-a16a1f084de0_602x250.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!ygb5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a7ce686-5d8f-4950-8732-a16a1f084de0_602x250.png" width="420" height="174.41860465116278" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7a7ce686-5d8f-4950-8732-a16a1f084de0_602x250.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:250,&quot;width&quot;:602,&quot;resizeWidth&quot;:420,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ygb5!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a7ce686-5d8f-4950-8732-a16a1f084de0_602x250.png 424w, https://substackcdn.com/image/fetch/$s_!ygb5!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a7ce686-5d8f-4950-8732-a16a1f084de0_602x250.png 848w, https://substackcdn.com/image/fetch/$s_!ygb5!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a7ce686-5d8f-4950-8732-a16a1f084de0_602x250.png 1272w, https://substackcdn.com/image/fetch/$s_!ygb5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a7ce686-5d8f-4950-8732-a16a1f084de0_602x250.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><h3>Example</h3><p>Suppose the required sources are policy, procedure, and system status. Assume the minimum required count is one chunk per source. The selected context has two policy chunks, one procedure chunk, and zero system-status chunks. Only system status is starved. Therefore:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!JdUv!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc218b3db-c01c-4e46-9fc5-bea8cc9a2ff5_430x174.png 424w, https://substackcdn.com/image/fetch/$s_!JdUv!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc218b3db-c01c-4e46-9fc5-bea8cc9a2ff5_430x174.png 848w, https://substackcdn.com/image/fetch/$s_!JdUv!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc218b3db-c01c-4e46-9fc5-bea8cc9a2ff5_430x174.png 1272w, https://substackcdn.com/image/fetch/$s_!JdUv!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc218b3db-c01c-4e46-9fc5-bea8cc9a2ff5_430x174.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!JdUv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc218b3db-c01c-4e46-9fc5-bea8cc9a2ff5_430x174.png" width="320" height="129.48837209302326" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c218b3db-c01c-4e46-9fc5-bea8cc9a2ff5_430x174.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:174,&quot;width&quot;:430,&quot;resizeWidth&quot;:320,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!JdUv!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc218b3db-c01c-4e46-9fc5-bea8cc9a2ff5_430x174.png 424w, https://substackcdn.com/image/fetch/$s_!JdUv!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc218b3db-c01c-4e46-9fc5-bea8cc9a2ff5_430x174.png 848w, https://substackcdn.com/image/fetch/$s_!JdUv!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc218b3db-c01c-4e46-9fc5-bea8cc9a2ff5_430x174.png 1272w, https://substackcdn.com/image/fetch/$s_!JdUv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc218b3db-c01c-4e46-9fc5-bea8cc9a2ff5_430x174.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>A starvation score of 0.33 is actionable. It tells the team that the retriever or assembler must include system-status evidence before the context is ready for inference.</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">from collections import Counter

def source_starvation(selected_chunks, required_sources, min_chunks_by_source =None):

    min_chunks_by_source = min_chunks_by_source or {

        source: 1 for source in required_sources

    }

    counts = Counter(chunk[&#8221;source&#8221;] for chunk in selected_chunks)

    starved_sources = [

        source

        for source in required_sources

        if counts[source] &lt; min_chunks_by_source.get(source, 1)

    ]

    if not required_sources:

        return 0.0, []

    return len(starved_sources) / len(required_sources), starved_sources</code></pre></div><h2>Freshness: Is the Context Current Enough?</h2><p>Relevance does not guarantee freshness. A document can be semantically relevant but operationally outdated. Freshness is especially important when content changes over time or has explicit effective dates.</p><p>Let a~i be the age of chunk d~i in days:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!-hiI!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F132e69b2-306e-4cc4-85dd-e51abafa372b_364x162.png 424w, https://substackcdn.com/image/fetch/$s_!-hiI!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F132e69b2-306e-4cc4-85dd-e51abafa372b_364x162.png 848w, https://substackcdn.com/image/fetch/$s_!-hiI!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F132e69b2-306e-4cc4-85dd-e51abafa372b_364x162.png 1272w, https://substackcdn.com/image/fetch/$s_!-hiI!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F132e69b2-306e-4cc4-85dd-e51abafa372b_364x162.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!-hiI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F132e69b2-306e-4cc4-85dd-e51abafa372b_364x162.png" width="320" height="142.41758241758242" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/132e69b2-306e-4cc4-85dd-e51abafa372b_364x162.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:162,&quot;width&quot;:364,&quot;resizeWidth&quot;:320,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!-hiI!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F132e69b2-306e-4cc4-85dd-e51abafa372b_364x162.png 424w, https://substackcdn.com/image/fetch/$s_!-hiI!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F132e69b2-306e-4cc4-85dd-e51abafa372b_364x162.png 848w, https://substackcdn.com/image/fetch/$s_!-hiI!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F132e69b2-306e-4cc4-85dd-e51abafa372b_364x162.png 1272w, https://substackcdn.com/image/fetch/$s_!-hiI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F132e69b2-306e-4cc4-85dd-e51abafa372b_364x162.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>A simple freshness score can be modeled with exponential decay:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!K41b!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1f77394-1a27-4a5a-a8b0-925f235eb261_680x246.png 424w, https://substackcdn.com/image/fetch/$s_!K41b!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1f77394-1a27-4a5a-a8b0-925f235eb261_680x246.png 848w, https://substackcdn.com/image/fetch/$s_!K41b!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1f77394-1a27-4a5a-a8b0-925f235eb261_680x246.png 1272w, https://substackcdn.com/image/fetch/$s_!K41b!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1f77394-1a27-4a5a-a8b0-925f235eb261_680x246.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!K41b!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1f77394-1a27-4a5a-a8b0-925f235eb261_680x246.png" width="520" height="188.11764705882354" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c1f77394-1a27-4a5a-a8b0-925f235eb261_680x246.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:246,&quot;width&quot;:680,&quot;resizeWidth&quot;:520,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!K41b!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1f77394-1a27-4a5a-a8b0-925f235eb261_680x246.png 424w, https://substackcdn.com/image/fetch/$s_!K41b!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1f77394-1a27-4a5a-a8b0-925f235eb261_680x246.png 848w, https://substackcdn.com/image/fetch/$s_!K41b!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1f77394-1a27-4a5a-a8b0-925f235eb261_680x246.png 1272w, https://substackcdn.com/image/fetch/$s_!K41b!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1f77394-1a27-4a5a-a8b0-925f235eb261_680x246.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>where &#120582; controls how quickly older content loses value. For the full context, a relevance-weighted freshness score is:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!S1AG!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F29aadd57-3a34-44f2-8f1d-0777d77b2e1f_678x198.png 424w, https://substackcdn.com/image/fetch/$s_!S1AG!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F29aadd57-3a34-44f2-8f1d-0777d77b2e1f_678x198.png 848w, https://substackcdn.com/image/fetch/$s_!S1AG!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F29aadd57-3a34-44f2-8f1d-0777d77b2e1f_678x198.png 1272w, https://substackcdn.com/image/fetch/$s_!S1AG!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F29aadd57-3a34-44f2-8f1d-0777d77b2e1f_678x198.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!S1AG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F29aadd57-3a34-44f2-8f1d-0777d77b2e1f_678x198.png" width="520" height="151.858407079646" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/29aadd57-3a34-44f2-8f1d-0777d77b2e1f_678x198.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:198,&quot;width&quot;:678,&quot;resizeWidth&quot;:520,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!S1AG!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F29aadd57-3a34-44f2-8f1d-0777d77b2e1f_678x198.png 424w, https://substackcdn.com/image/fetch/$s_!S1AG!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F29aadd57-3a34-44f2-8f1d-0777d77b2e1f_678x198.png 848w, https://substackcdn.com/image/fetch/$s_!S1AG!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F29aadd57-3a34-44f2-8f1d-0777d77b2e1f_678x198.png 1272w, https://substackcdn.com/image/fetch/$s_!S1AG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F29aadd57-3a34-44f2-8f1d-0777d77b2e1f_678x198.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>For content with explicit validity windows, let V~i(t) be 1 when chunk d~i is valid at time t and 0 otherwise:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Ak2g!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a2a7eeb-5dbc-494a-8746-6a64d1ab041b_794x248.png 424w, https://substackcdn.com/image/fetch/$s_!Ak2g!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a2a7eeb-5dbc-494a-8746-6a64d1ab041b_794x248.png 848w, https://substackcdn.com/image/fetch/$s_!Ak2g!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a2a7eeb-5dbc-494a-8746-6a64d1ab041b_794x248.png 1272w, https://substackcdn.com/image/fetch/$s_!Ak2g!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a2a7eeb-5dbc-494a-8746-6a64d1ab041b_794x248.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!Ak2g!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a2a7eeb-5dbc-494a-8746-6a64d1ab041b_794x248.png" width="520" height="162.41813602015114" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9a2a7eeb-5dbc-494a-8746-6a64d1ab041b_794x248.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:&quot;normal&quot;,&quot;height&quot;:248,&quot;width&quot;:794,&quot;resizeWidth&quot;:520,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:&quot;center&quot;,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Ak2g!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a2a7eeb-5dbc-494a-8746-6a64d1ab041b_794x248.png 424w, https://substackcdn.com/image/fetch/$s_!Ak2g!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a2a7eeb-5dbc-494a-8746-6a64d1ab041b_794x248.png 848w, https://substackcdn.com/image/fetch/$s_!Ak2g!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a2a7eeb-5dbc-494a-8746-6a64d1ab041b_794x248.png 1272w, https://substackcdn.com/image/fetch/$s_!Ak2g!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a2a7eeb-5dbc-494a-8746-6a64d1ab041b_794x248.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>Then stale-context risk is:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!JxOD!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d56249f-3665-4351-90df-1ec9005fb889_552x430.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!JxOD!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d56249f-3665-4351-90df-1ec9005fb889_552x430.png 424w, https://substackcdn.com/image/fetch/$s_!JxOD!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d56249f-3665-4351-90df-1ec9005fb889_552x430.png 848w, https://substackcdn.com/image/fetch/$s_!JxOD!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d56249f-3665-4351-90df-1ec9005fb889_552x430.png 1272w, https://substackcdn.com/image/fetch/$s_!JxOD!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d56249f-3665-4351-90df-1ec9005fb889_552x430.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!JxOD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d56249f-3665-4351-90df-1ec9005fb889_552x430.png" width="400" height="311.59420289855075" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0d56249f-3665-4351-90df-1ec9005fb889_552x430.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:&quot;normal&quot;,&quot;height&quot;:430,&quot;width&quot;:552,&quot;resizeWidth&quot;:400,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:&quot;center&quot;,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!JxOD!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d56249f-3665-4351-90df-1ec9005fb889_552x430.png 424w, https://substackcdn.com/image/fetch/$s_!JxOD!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d56249f-3665-4351-90df-1ec9005fb889_552x430.png 848w, https://substackcdn.com/image/fetch/$s_!JxOD!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d56249f-3665-4351-90df-1ec9005fb889_552x430.png 1272w, https://substackcdn.com/image/fetch/$s_!JxOD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d56249f-3665-4351-90df-1ec9005fb889_552x430.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><h3>Example</h3><p>Suppose &#120582; = 0.01 and three chunks have ages 10, 60, and 1 days. Their freshness scores are approximately:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!vQfX!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3d12f630-2a16-4c93-bb07-d5d0aa99e96a_1508x408.png 424w, https://substackcdn.com/image/fetch/$s_!vQfX!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3d12f630-2a16-4c93-bb07-d5d0aa99e96a_1508x408.png 848w, https://substackcdn.com/image/fetch/$s_!vQfX!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3d12f630-2a16-4c93-bb07-d5d0aa99e96a_1508x408.png 1272w, https://substackcdn.com/image/fetch/$s_!vQfX!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3d12f630-2a16-4c93-bb07-d5d0aa99e96a_1508x408.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!vQfX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3d12f630-2a16-4c93-bb07-d5d0aa99e96a_1508x408.png" width="620" height="167.77472527472528" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3d12f630-2a16-4c93-bb07-d5d0aa99e96a_1508x408.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:394,&quot;width&quot;:1456,&quot;resizeWidth&quot;:620,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!vQfX!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3d12f630-2a16-4c93-bb07-d5d0aa99e96a_1508x408.png 424w, https://substackcdn.com/image/fetch/$s_!vQfX!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3d12f630-2a16-4c93-bb07-d5d0aa99e96a_1508x408.png 848w, https://substackcdn.com/image/fetch/$s_!vQfX!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3d12f630-2a16-4c93-bb07-d5d0aa99e96a_1508x408.png 1272w, https://substackcdn.com/image/fetch/$s_!vQfX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3d12f630-2a16-4c93-bb07-d5d0aa99e96a_1508x408.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>If their relevance scores are 0.90, 0.80, and 0.70, the context freshness is:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!fLxx!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7497ba9a-3816-4aaf-803d-1bde74e7a266_726x232.png 424w, https://substackcdn.com/image/fetch/$s_!fLxx!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7497ba9a-3816-4aaf-803d-1bde74e7a266_726x232.png 848w, https://substackcdn.com/image/fetch/$s_!fLxx!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7497ba9a-3816-4aaf-803d-1bde74e7a266_726x232.png 1272w, https://substackcdn.com/image/fetch/$s_!fLxx!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7497ba9a-3816-4aaf-803d-1bde74e7a266_726x232.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!fLxx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7497ba9a-3816-4aaf-803d-1bde74e7a266_726x232.png" width="420" height="134.21487603305786" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7497ba9a-3816-4aaf-803d-1bde74e7a266_726x232.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:232,&quot;width&quot;:726,&quot;resizeWidth&quot;:420,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!fLxx!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7497ba9a-3816-4aaf-803d-1bde74e7a266_726x232.png 424w, https://substackcdn.com/image/fetch/$s_!fLxx!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7497ba9a-3816-4aaf-803d-1bde74e7a266_726x232.png 848w, https://substackcdn.com/image/fetch/$s_!fLxx!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7497ba9a-3816-4aaf-803d-1bde74e7a266_726x232.png 1272w, https://substackcdn.com/image/fetch/$s_!fLxx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7497ba9a-3816-4aaf-803d-1bde74e7a266_726x232.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>For validity-window risk, if two out of three chunks are currently valid, then:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ilUm!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F41934379-85fa-40da-af41-b1b416eb8fc6_360x154.png 424w, https://substackcdn.com/image/fetch/$s_!ilUm!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F41934379-85fa-40da-af41-b1b416eb8fc6_360x154.png 848w, https://substackcdn.com/image/fetch/$s_!ilUm!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F41934379-85fa-40da-af41-b1b416eb8fc6_360x154.png 1272w, https://substackcdn.com/image/fetch/$s_!ilUm!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F41934379-85fa-40da-af41-b1b416eb8fc6_360x154.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!ilUm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F41934379-85fa-40da-af41-b1b416eb8fc6_360x154.png" width="320" height="136.88888888888889" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/41934379-85fa-40da-af41-b1b416eb8fc6_360x154.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:154,&quot;width&quot;:360,&quot;resizeWidth&quot;:320,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ilUm!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F41934379-85fa-40da-af41-b1b416eb8fc6_360x154.png 424w, https://substackcdn.com/image/fetch/$s_!ilUm!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F41934379-85fa-40da-af41-b1b416eb8fc6_360x154.png 848w, https://substackcdn.com/image/fetch/$s_!ilUm!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F41934379-85fa-40da-af41-b1b416eb8fc6_360x154.png 1272w, https://substackcdn.com/image/fetch/$s_!ilUm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F41934379-85fa-40da-af41-b1b416eb8fc6_360x154.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>This indicates that one-third of the selected context is stale under the validity policy.</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">from datetime import datetime

from math import exp

def freshness_score(chunk, now=None, decay_lambda=0.01):

    now = now or datetime.utcnow()

    age_days = max((now - chunk[&#8221;timestamp&#8221;]).days, 0)

    return exp(-decay_lambda * age_days)

def context_freshness(selected_chunks):

    if not selected_chunks:

        return 0.0

    weighted_sum = 0.0

    total_weight = 0.0

    for chunk in selected_chunks:

        relevance = chunk.get(&#8221;relevance&#8221;, 1.0)

        weighted_sum += relevance * freshness_score(chunk)

        total_weight += relevance

    return weighted_sum / total_weight if total_weight else 0.0</code></pre></div><h2>Contradiction Density: Does the Context Conflict With Itself?</h2><p>Contradictions are difficult in RAG systems because every retrieved chunk may appear relevant in isolation. The problem emerges when those chunks are placed together. Let x~ij be 1 when chunks d~i and d~j conflict, and 0 otherwise:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!sHp5!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3795e58f-53af-49b5-9a30-3e725a826f91_512x240.png 424w, https://substackcdn.com/image/fetch/$s_!sHp5!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3795e58f-53af-49b5-9a30-3e725a826f91_512x240.png 848w, https://substackcdn.com/image/fetch/$s_!sHp5!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3795e58f-53af-49b5-9a30-3e725a826f91_512x240.png 1272w, https://substackcdn.com/image/fetch/$s_!sHp5!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3795e58f-53af-49b5-9a30-3e725a826f91_512x240.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!sHp5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3795e58f-53af-49b5-9a30-3e725a826f91_512x240.png" width="420" height="196.875" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3795e58f-53af-49b5-9a30-3e725a826f91_512x240.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:240,&quot;width&quot;:512,&quot;resizeWidth&quot;:420,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!sHp5!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3795e58f-53af-49b5-9a30-3e725a826f91_512x240.png 424w, https://substackcdn.com/image/fetch/$s_!sHp5!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3795e58f-53af-49b5-9a30-3e725a826f91_512x240.png 848w, https://substackcdn.com/image/fetch/$s_!sHp5!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3795e58f-53af-49b5-9a30-3e725a826f91_512x240.png 1272w, https://substackcdn.com/image/fetch/$s_!sHp5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3795e58f-53af-49b5-9a30-3e725a826f91_512x240.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>Contradiction density is:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!E9p9!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc62465c-7dba-40a1-adbb-bae428c2cc9f_650x282.png 424w, https://substackcdn.com/image/fetch/$s_!E9p9!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc62465c-7dba-40a1-adbb-bae428c2cc9f_650x282.png 848w, https://substackcdn.com/image/fetch/$s_!E9p9!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc62465c-7dba-40a1-adbb-bae428c2cc9f_650x282.png 1272w, https://substackcdn.com/image/fetch/$s_!E9p9!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc62465c-7dba-40a1-adbb-bae428c2cc9f_650x282.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!E9p9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc62465c-7dba-40a1-adbb-bae428c2cc9f_650x282.png" width="420" height="182.2153846153846" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fc62465c-7dba-40a1-adbb-bae428c2cc9f_650x282.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:282,&quot;width&quot;:650,&quot;resizeWidth&quot;:420,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!E9p9!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc62465c-7dba-40a1-adbb-bae428c2cc9f_650x282.png 424w, https://substackcdn.com/image/fetch/$s_!E9p9!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc62465c-7dba-40a1-adbb-bae428c2cc9f_650x282.png 848w, https://substackcdn.com/image/fetch/$s_!E9p9!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc62465c-7dba-40a1-adbb-bae428c2cc9f_650x282.png 1272w, https://substackcdn.com/image/fetch/$s_!E9p9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc62465c-7dba-40a1-adbb-bae428c2cc9f_650x282.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>A weighted version can incorporate severity &#120590;~ij:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!f80x!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F065cb3e2-b6cd-40a1-b02e-44c503151685_312x236.png 424w, https://substackcdn.com/image/fetch/$s_!f80x!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F065cb3e2-b6cd-40a1-b02e-44c503151685_312x236.png 848w, https://substackcdn.com/image/fetch/$s_!f80x!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F065cb3e2-b6cd-40a1-b02e-44c503151685_312x236.png 1272w, https://substackcdn.com/image/fetch/$s_!f80x!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F065cb3e2-b6cd-40a1-b02e-44c503151685_312x236.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!f80x!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F065cb3e2-b6cd-40a1-b02e-44c503151685_312x236.png" width="320" height="242.05128205128204" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/065cb3e2-b6cd-40a1-b02e-44c503151685_312x236.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:236,&quot;width&quot;:312,&quot;resizeWidth&quot;:320,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!f80x!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F065cb3e2-b6cd-40a1-b02e-44c503151685_312x236.png 424w, https://substackcdn.com/image/fetch/$s_!f80x!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F065cb3e2-b6cd-40a1-b02e-44c503151685_312x236.png 848w, https://substackcdn.com/image/fetch/$s_!f80x!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F065cb3e2-b6cd-40a1-b02e-44c503151685_312x236.png 1272w, https://substackcdn.com/image/fetch/$s_!f80x!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F065cb3e2-b6cd-40a1-b02e-44c503151685_312x236.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><h3>Example</h3><p>Suppose the selected context contains four chunks. There are:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!zCwt!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F266bef37-5c53-45cf-b498-0233f6a6f669_574x222.png 424w, https://substackcdn.com/image/fetch/$s_!zCwt!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F266bef37-5c53-45cf-b498-0233f6a6f669_574x222.png 848w, https://substackcdn.com/image/fetch/$s_!zCwt!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F266bef37-5c53-45cf-b498-0233f6a6f669_574x222.png 1272w, https://substackcdn.com/image/fetch/$s_!zCwt!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F266bef37-5c53-45cf-b498-0233f6a6f669_574x222.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!zCwt!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F266bef37-5c53-45cf-b498-0233f6a6f669_574x222.png" width="420" height="162.4390243902439" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/266bef37-5c53-45cf-b498-0233f6a6f669_574x222.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:222,&quot;width&quot;:574,&quot;resizeWidth&quot;:420,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!zCwt!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F266bef37-5c53-45cf-b498-0233f6a6f669_574x222.png 424w, https://substackcdn.com/image/fetch/$s_!zCwt!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F266bef37-5c53-45cf-b498-0233f6a6f669_574x222.png 848w, https://substackcdn.com/image/fetch/$s_!zCwt!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F266bef37-5c53-45cf-b498-0233f6a6f669_574x222.png 1272w, https://substackcdn.com/image/fetch/$s_!zCwt!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F266bef37-5c53-45cf-b498-0233f6a6f669_574x222.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>possible chunk pairs. If one pair conflicts, then:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!P7r4!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a4eae80-23b2-4232-989f-32c9a7f03bb3_708x224.png 424w, https://substackcdn.com/image/fetch/$s_!P7r4!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a4eae80-23b2-4232-989f-32c9a7f03bb3_708x224.png 848w, https://substackcdn.com/image/fetch/$s_!P7r4!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a4eae80-23b2-4232-989f-32c9a7f03bb3_708x224.png 1272w, https://substackcdn.com/image/fetch/$s_!P7r4!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a4eae80-23b2-4232-989f-32c9a7f03bb3_708x224.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!P7r4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a4eae80-23b2-4232-989f-32c9a7f03bb3_708x224.png" width="520" height="164.51977401129943" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7a4eae80-23b2-4232-989f-32c9a7f03bb3_708x224.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:224,&quot;width&quot;:708,&quot;resizeWidth&quot;:520,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!P7r4!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a4eae80-23b2-4232-989f-32c9a7f03bb3_708x224.png 424w, https://substackcdn.com/image/fetch/$s_!P7r4!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a4eae80-23b2-4232-989f-32c9a7f03bb3_708x224.png 848w, https://substackcdn.com/image/fetch/$s_!P7r4!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a4eae80-23b2-4232-989f-32c9a7f03bb3_708x224.png 1272w, https://substackcdn.com/image/fetch/$s_!P7r4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a4eae80-23b2-4232-989f-32c9a7f03bb3_708x224.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>If the conflicting pair has severity 0.80, weighted contradiction density is:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!OW7H!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ee89641-ef42-4d39-b042-742a1dd1f92c_490x154.png 424w, https://substackcdn.com/image/fetch/$s_!OW7H!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ee89641-ef42-4d39-b042-742a1dd1f92c_490x154.png 848w, https://substackcdn.com/image/fetch/$s_!OW7H!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ee89641-ef42-4d39-b042-742a1dd1f92c_490x154.png 1272w, https://substackcdn.com/image/fetch/$s_!OW7H!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ee89641-ef42-4d39-b042-742a1dd1f92c_490x154.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!OW7H!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ee89641-ef42-4d39-b042-742a1dd1f92c_490x154.png" width="420" height="132" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7ee89641-ef42-4d39-b042-742a1dd1f92c_490x154.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:154,&quot;width&quot;:490,&quot;resizeWidth&quot;:420,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!OW7H!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ee89641-ef42-4d39-b042-742a1dd1f92c_490x154.png 424w, https://substackcdn.com/image/fetch/$s_!OW7H!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ee89641-ef42-4d39-b042-742a1dd1f92c_490x154.png 848w, https://substackcdn.com/image/fetch/$s_!OW7H!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ee89641-ef42-4d39-b042-742a1dd1f92c_490x154.png 1272w, https://substackcdn.com/image/fetch/$s_!OW7H!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ee89641-ef42-4d39-b042-742a1dd1f92c_490x154.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>A contradiction score should be treated as a risk signal, not a final judgment. The system may apply source precedence rules, remove older chunks, retrieve a newer version, or route the case for additional validation.</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">def contradiction_density(selected_chunks, conflict_fields):

    if len(selected_chunks) &lt; 2:

        return 0.0

    conflicts = 0

    total_pairs = 0

    for i in range(len(selected_chunks)):

        for j in range(i + 1, len(selected_chunks)):

            total_pairs += 1

            conflict_found = any(

                selected_chunks[i].get(field) != selected_chunks[j].get(field)

                for field in conflict_fields

                    if field in selected_chunks[i] and field in selected_chunks[j]

            )

        if conflict_found:

            conflicts += 1

    return conflicts / total_pairs if total_pairs else 0.0</code></pre></div><h2>Policy Admissibility: Should This Context Be Used?</h2><p>Context quality is not only about relevance. It also includes whether the selected context is appropriate for the task and permitted under applicable access and governance rules.</p><p>Let P~i(q,u) be 1 when chunk d~i is allowed for query q and role u, and 0 otherwise:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!4H5z!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F624a2a1b-fe35-41b1-b524-5897cf09d1be_784x230.png 424w, https://substackcdn.com/image/fetch/$s_!4H5z!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F624a2a1b-fe35-41b1-b524-5897cf09d1be_784x230.png 848w, https://substackcdn.com/image/fetch/$s_!4H5z!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F624a2a1b-fe35-41b1-b524-5897cf09d1be_784x230.png 1272w, https://substackcdn.com/image/fetch/$s_!4H5z!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F624a2a1b-fe35-41b1-b524-5897cf09d1be_784x230.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!4H5z!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F624a2a1b-fe35-41b1-b524-5897cf09d1be_784x230.png" width="520" height="152.55102040816325" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/624a2a1b-fe35-41b1-b524-5897cf09d1be_784x230.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:230,&quot;width&quot;:784,&quot;resizeWidth&quot;:520,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!4H5z!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F624a2a1b-fe35-41b1-b524-5897cf09d1be_784x230.png 424w, https://substackcdn.com/image/fetch/$s_!4H5z!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F624a2a1b-fe35-41b1-b524-5897cf09d1be_784x230.png 848w, https://substackcdn.com/image/fetch/$s_!4H5z!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F624a2a1b-fe35-41b1-b524-5897cf09d1be_784x230.png 1272w, https://substackcdn.com/image/fetch/$s_!4H5z!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F624a2a1b-fe35-41b1-b524-5897cf09d1be_784x230.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>Policy admissibility is:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!fAMZ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e1ea448-7ae5-4d5e-ae4d-5f30faee39b7_468x162.png 424w, https://substackcdn.com/image/fetch/$s_!fAMZ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e1ea448-7ae5-4d5e-ae4d-5f30faee39b7_468x162.png 848w, https://substackcdn.com/image/fetch/$s_!fAMZ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e1ea448-7ae5-4d5e-ae4d-5f30faee39b7_468x162.png 1272w, https://substackcdn.com/image/fetch/$s_!fAMZ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e1ea448-7ae5-4d5e-ae4d-5f30faee39b7_468x162.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!fAMZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e1ea448-7ae5-4d5e-ae4d-5f30faee39b7_468x162.png" width="420" height="145.3846153846154" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9e1ea448-7ae5-4d5e-ae4d-5f30faee39b7_468x162.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:162,&quot;width&quot;:468,&quot;resizeWidth&quot;:420,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!fAMZ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e1ea448-7ae5-4d5e-ae4d-5f30faee39b7_468x162.png 424w, https://substackcdn.com/image/fetch/$s_!fAMZ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e1ea448-7ae5-4d5e-ae4d-5f30faee39b7_468x162.png 848w, https://substackcdn.com/image/fetch/$s_!fAMZ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e1ea448-7ae5-4d5e-ae4d-5f30faee39b7_468x162.png 1272w, https://substackcdn.com/image/fetch/$s_!fAMZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e1ea448-7ae5-4d5e-ae4d-5f30faee39b7_468x162.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>For stricter workflows, every chunk must be admissible before inference:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!MfOE!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F731114ba-e93c-441c-8310-449cce2de40a_682x228.png 424w, https://substackcdn.com/image/fetch/$s_!MfOE!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F731114ba-e93c-441c-8310-449cce2de40a_682x228.png 848w, https://substackcdn.com/image/fetch/$s_!MfOE!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F731114ba-e93c-441c-8310-449cce2de40a_682x228.png 1272w, https://substackcdn.com/image/fetch/$s_!MfOE!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F731114ba-e93c-441c-8310-449cce2de40a_682x228.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!MfOE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F731114ba-e93c-441c-8310-449cce2de40a_682x228.png" width="520" height="173.841642228739" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/731114ba-e93c-441c-8310-449cce2de40a_682x228.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:228,&quot;width&quot;:682,&quot;resizeWidth&quot;:520,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!MfOE!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F731114ba-e93c-441c-8310-449cce2de40a_682x228.png 424w, https://substackcdn.com/image/fetch/$s_!MfOE!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F731114ba-e93c-441c-8310-449cce2de40a_682x228.png 848w, https://substackcdn.com/image/fetch/$s_!MfOE!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F731114ba-e93c-441c-8310-449cce2de40a_682x228.png 1272w, https://substackcdn.com/image/fetch/$s_!MfOE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F731114ba-e93c-441c-8310-449cce2de40a_682x228.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><h3>Example</h3><p>Suppose a context package has five chunks and four are admissible for the current task and role. Then:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!S3gu!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3cce02a-2180-4a47-a7f1-bba9010cdd0a_1972x184.png 424w, https://substackcdn.com/image/fetch/$s_!S3gu!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3cce02a-2180-4a47-a7f1-bba9010cdd0a_1972x184.png 848w, https://substackcdn.com/image/fetch/$s_!S3gu!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3cce02a-2180-4a47-a7f1-bba9010cdd0a_1972x184.png 1272w, https://substackcdn.com/image/fetch/$s_!S3gu!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3cce02a-2180-4a47-a7f1-bba9010cdd0a_1972x184.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!S3gu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3cce02a-2180-4a47-a7f1-bba9010cdd0a_1972x184.png" width="1456" height="136" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d3cce02a-2180-4a47-a7f1-bba9010cdd0a_1972x184.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:136,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!S3gu!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3cce02a-2180-4a47-a7f1-bba9010cdd0a_1972x184.png 424w, https://substackcdn.com/image/fetch/$s_!S3gu!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3cce02a-2180-4a47-a7f1-bba9010cdd0a_1972x184.png 848w, https://substackcdn.com/image/fetch/$s_!S3gu!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3cce02a-2180-4a47-a7f1-bba9010cdd0a_1972x184.png 1272w, https://substackcdn.com/image/fetch/$s_!S3gu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3cce02a-2180-4a47-a7f1-bba9010cdd0a_1972x184.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>If the configured policy requires &#120587;(C,q,u) = 1, the context fails the pre-inference gate even though 80% of the chunks are allowed. This strict behavior is intentional in workflows where inappropriate context should not enter the prompt.</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">def policy_admissibility(selected_chunks, allowed_scopes):

    if not selected_chunks:

        return 0.0

    allowed_count = 0

    for chunk in selected_chunks:

        if chunk.get(&#8221;scope&#8221;) in allowed_scopes:

            allowed_count += 1

return allowed_count / len(selected_chunks)</code></pre></div><h2>Combining Signals into a Pre-Inference Gate</h2><p>The individual signals can be combined into a pre-inference quality gate:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!eZeI!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28b86f92-d0ad-4f3a-9784-05e316447ddb_1996x134.png 424w, https://substackcdn.com/image/fetch/$s_!eZeI!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28b86f92-d0ad-4f3a-9784-05e316447ddb_1996x134.png 848w, https://substackcdn.com/image/fetch/$s_!eZeI!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28b86f92-d0ad-4f3a-9784-05e316447ddb_1996x134.png 1272w, https://substackcdn.com/image/fetch/$s_!eZeI!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28b86f92-d0ad-4f3a-9784-05e316447ddb_1996x134.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!eZeI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28b86f92-d0ad-4f3a-9784-05e316447ddb_1996x134.png" width="1456" height="98" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/28b86f92-d0ad-4f3a-9784-05e316447ddb_1996x134.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:98,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!eZeI!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28b86f92-d0ad-4f3a-9784-05e316447ddb_1996x134.png 424w, https://substackcdn.com/image/fetch/$s_!eZeI!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28b86f92-d0ad-4f3a-9784-05e316447ddb_1996x134.png 848w, https://substackcdn.com/image/fetch/$s_!eZeI!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28b86f92-d0ad-4f3a-9784-05e316447ddb_1996x134.png 1272w, https://substackcdn.com/image/fetch/$s_!eZeI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28b86f92-d0ad-4f3a-9784-05e316447ddb_1996x134.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><h3>Example</h3><p>Suppose the thresholds are:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!471C!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff2b3d8af-4e36-489b-a552-e156667b7798_1492x132.png 424w, https://substackcdn.com/image/fetch/$s_!471C!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff2b3d8af-4e36-489b-a552-e156667b7798_1492x132.png 848w, https://substackcdn.com/image/fetch/$s_!471C!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff2b3d8af-4e36-489b-a552-e156667b7798_1492x132.png 1272w, https://substackcdn.com/image/fetch/$s_!471C!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff2b3d8af-4e36-489b-a552-e156667b7798_1492x132.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!471C!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff2b3d8af-4e36-489b-a552-e156667b7798_1492x132.png" width="700" height="62.01923076923077" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f2b3d8af-4e36-489b-a552-e156667b7798_1492x132.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:129,&quot;width&quot;:1456,&quot;resizeWidth&quot;:700,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!471C!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff2b3d8af-4e36-489b-a552-e156667b7798_1492x132.png 424w, https://substackcdn.com/image/fetch/$s_!471C!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff2b3d8af-4e36-489b-a552-e156667b7798_1492x132.png 848w, https://substackcdn.com/image/fetch/$s_!471C!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff2b3d8af-4e36-489b-a552-e156667b7798_1492x132.png 1272w, https://substackcdn.com/image/fetch/$s_!471C!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff2b3d8af-4e36-489b-a552-e156667b7798_1492x132.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>For a context package with:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!bxc6!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdafa071d-e200-4050-a635-bcd56659c8e2_320x132.png 424w, https://substackcdn.com/image/fetch/$s_!bxc6!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdafa071d-e200-4050-a635-bcd56659c8e2_320x132.png 848w, https://substackcdn.com/image/fetch/$s_!bxc6!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdafa071d-e200-4050-a635-bcd56659c8e2_320x132.png 1272w, https://substackcdn.com/image/fetch/$s_!bxc6!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdafa071d-e200-4050-a635-bcd56659c8e2_320x132.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!bxc6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdafa071d-e200-4050-a635-bcd56659c8e2_320x132.png" width="300" height="123.75" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/dafa071d-e200-4050-a635-bcd56659c8e2_320x132.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:132,&quot;width&quot;:320,&quot;resizeWidth&quot;:300,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!bxc6!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdafa071d-e200-4050-a635-bcd56659c8e2_320x132.png 424w, https://substackcdn.com/image/fetch/$s_!bxc6!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdafa071d-e200-4050-a635-bcd56659c8e2_320x132.png 848w, https://substackcdn.com/image/fetch/$s_!bxc6!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdafa071d-e200-4050-a635-bcd56659c8e2_320x132.png 1272w, https://substackcdn.com/image/fetch/$s_!bxc6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdafa071d-e200-4050-a635-bcd56659c8e2_320x132.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>all conditions pass, so:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!8cf2!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa61349a2-63d0-43e8-b543-5e6425cd5890_324x108.png 424w, https://substackcdn.com/image/fetch/$s_!8cf2!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa61349a2-63d0-43e8-b543-5e6425cd5890_324x108.png 848w, https://substackcdn.com/image/fetch/$s_!8cf2!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa61349a2-63d0-43e8-b543-5e6425cd5890_324x108.png 1272w, https://substackcdn.com/image/fetch/$s_!8cf2!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa61349a2-63d0-43e8-b543-5e6425cd5890_324x108.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!8cf2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa61349a2-63d0-43e8-b543-5e6425cd5890_324x108.png" width="300" height="100" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a61349a2-63d0-43e8-b543-5e6425cd5890_324x108.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:108,&quot;width&quot;:324,&quot;resizeWidth&quot;:300,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!8cf2!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa61349a2-63d0-43e8-b543-5e6425cd5890_324x108.png 424w, https://substackcdn.com/image/fetch/$s_!8cf2!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa61349a2-63d0-43e8-b543-5e6425cd5890_324x108.png 848w, https://substackcdn.com/image/fetch/$s_!8cf2!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa61349a2-63d0-43e8-b543-5e6425cd5890_324x108.png 1272w, https://substackcdn.com/image/fetch/$s_!8cf2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa61349a2-63d0-43e8-b543-5e6425cd5890_324x108.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>For a different context with the same values except &#120575; = 0.33, the gate fails because source starvation exceeds the threshold:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ItV3!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc3f0e3c8-b4c9-4799-a69e-eed258afa88a_1874x150.png 424w, https://substackcdn.com/image/fetch/$s_!ItV3!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc3f0e3c8-b4c9-4799-a69e-eed258afa88a_1874x150.png 848w, https://substackcdn.com/image/fetch/$s_!ItV3!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc3f0e3c8-b4c9-4799-a69e-eed258afa88a_1874x150.png 1272w, https://substackcdn.com/image/fetch/$s_!ItV3!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc3f0e3c8-b4c9-4799-a69e-eed258afa88a_1874x150.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!ItV3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc3f0e3c8-b4c9-4799-a69e-eed258afa88a_1874x150.png" width="1456" height="117" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c3f0e3c8-b4c9-4799-a69e-eed258afa88a_1874x150.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:117,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ItV3!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc3f0e3c8-b4c9-4799-a69e-eed258afa88a_1874x150.png 424w, https://substackcdn.com/image/fetch/$s_!ItV3!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc3f0e3c8-b4c9-4799-a69e-eed258afa88a_1874x150.png 848w, https://substackcdn.com/image/fetch/$s_!ItV3!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc3f0e3c8-b4c9-4799-a69e-eed258afa88a_1874x150.png 1272w, https://substackcdn.com/image/fetch/$s_!ItV3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc3f0e3c8-b4c9-4799-a69e-eed258afa88a_1874x150.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">def context_quality_report(selected_chunks, config):

    rho = coverage_score(selected_chunks, set(config[&#8221;required_aspects&#8221;]))

    tau = token_utilization(selected_chunks, config[&#8221;token_budget&#8221;])

    delta, starved_sources = source_starvation(

        selected_chunks,

        set(config[&#8221;required_sources&#8221;]),

        config.get(&#8221;min_chunks_by_source&#8221;)

    )

    kappa = contradiction_density(

        selected_chunks,

        config.get(&#8221;conflict_fields&#8221;, [])

    )

    phi = context_freshness(selected_chunks)

    pi = policy_admissibility(selected_chunks, set(config[&#8221;allowed_scopes&#8221;]))

    passed = (

        rho &gt;= config.get(&#8221;min_coverage&#8221;, 0.80)

        and config.get(&#8221;min_token_utilization&#8221;, 0.10)

            &lt;= tau

            &lt;= config.get(&#8221;max_token_utilization&#8221;, 0.90)

        and delta &lt;= config.get(&#8221;max_source_starvation&#8221;, 0.0)

        and kappa &lt;= config.get(&#8221;max_contradiction_density&#8221;, 0.0)

        and phi &gt;= config.get(&#8221;min_freshness&#8221;, 0.70)

        and pi == 1.0

    )

    return {

        &#8220;passed&#8221;: passed,

        &#8220;metrics&#8221;: {

            &#8220;coverage&#8221;: rho,

            &#8220;token_utilization&#8221;: tau,

            &#8220;source_starvation&#8221;: delta,

            &#8220;contradiction_density&#8221;: kappa,

            &#8220;freshness&#8221;: phi,

            &#8220;policy_admissibility&#8221;: pi,

        },

        &#8220;diagnostics&#8221;: {

        &#8220;starved_sources&#8221;: starved_sources,

    },

}</code></pre></div><h2>Why This Becomes an Optimization Challenge</h2><p>Pre-inference context quality is not only a measurement problem. Given a large candidate set D, the system must select a subset C that maximizes usefulness while satisfying token budget, source coverage, freshness, policy, and contradiction constraints.</p><p>A simplified objective can be written as:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!_D8w!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac7a3e3e-75d7-456d-926d-515a137eeaea_414x450.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!_D8w!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac7a3e3e-75d7-456d-926d-515a137eeaea_414x450.png 424w, https://substackcdn.com/image/fetch/$s_!_D8w!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac7a3e3e-75d7-456d-926d-515a137eeaea_414x450.png 848w, https://substackcdn.com/image/fetch/$s_!_D8w!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac7a3e3e-75d7-456d-926d-515a137eeaea_414x450.png 1272w, https://substackcdn.com/image/fetch/$s_!_D8w!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac7a3e3e-75d7-456d-926d-515a137eeaea_414x450.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!_D8w!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac7a3e3e-75d7-456d-926d-515a137eeaea_414x450.png" width="230" height="250" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ac7a3e3e-75d7-456d-926d-515a137eeaea_414x450.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:450,&quot;width&quot;:414,&quot;resizeWidth&quot;:230,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!_D8w!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac7a3e3e-75d7-456d-926d-515a137eeaea_414x450.png 424w, https://substackcdn.com/image/fetch/$s_!_D8w!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac7a3e3e-75d7-456d-926d-515a137eeaea_414x450.png 848w, https://substackcdn.com/image/fetch/$s_!_D8w!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac7a3e3e-75d7-456d-926d-515a137eeaea_414x450.png 1272w, https://substackcdn.com/image/fetch/$s_!_D8w!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac7a3e3e-75d7-456d-926d-515a137eeaea_414x450.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>This type of constrained selection problem can become hard in general, especially when the system must balance relevance, coverage, diversity, freshness, and token cost simultaneously. Context Inspector does not attempt to prove that every selected context is globally optimal. Instead, it provides practical, interpretable signals that help teams identify when the context is clearly not good enough.</p><h3>Example</h3><p>Suppose the scoring weights are:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!GxsJ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6dcdea5b-6bec-4887-b875-867d31c95934_1820x110.png 424w, https://substackcdn.com/image/fetch/$s_!GxsJ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6dcdea5b-6bec-4887-b875-867d31c95934_1820x110.png 848w, https://substackcdn.com/image/fetch/$s_!GxsJ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6dcdea5b-6bec-4887-b875-867d31c95934_1820x110.png 1272w, https://substackcdn.com/image/fetch/$s_!GxsJ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6dcdea5b-6bec-4887-b875-867d31c95934_1820x110.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!GxsJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6dcdea5b-6bec-4887-b875-867d31c95934_1820x110.png" width="1456" height="88" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6dcdea5b-6bec-4887-b875-867d31c95934_1820x110.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:88,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!GxsJ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6dcdea5b-6bec-4887-b875-867d31c95934_1820x110.png 424w, https://substackcdn.com/image/fetch/$s_!GxsJ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6dcdea5b-6bec-4887-b875-867d31c95934_1820x110.png 848w, https://substackcdn.com/image/fetch/$s_!GxsJ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6dcdea5b-6bec-4887-b875-867d31c95934_1820x110.png 1272w, https://substackcdn.com/image/fetch/$s_!GxsJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6dcdea5b-6bec-4887-b875-867d31c95934_1820x110.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>For candidate context C~1:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!mKap!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe4e1ee6-cc9a-4123-b176-de47f10489fd_1560x106.png 424w, https://substackcdn.com/image/fetch/$s_!mKap!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe4e1ee6-cc9a-4123-b176-de47f10489fd_1560x106.png 848w, https://substackcdn.com/image/fetch/$s_!mKap!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe4e1ee6-cc9a-4123-b176-de47f10489fd_1560x106.png 1272w, https://substackcdn.com/image/fetch/$s_!mKap!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe4e1ee6-cc9a-4123-b176-de47f10489fd_1560x106.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!mKap!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe4e1ee6-cc9a-4123-b176-de47f10489fd_1560x106.png" width="700" height="47.59615384615385" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/be4e1ee6-cc9a-4123-b176-de47f10489fd_1560x106.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:99,&quot;width&quot;:1456,&quot;resizeWidth&quot;:700,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!mKap!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe4e1ee6-cc9a-4123-b176-de47f10489fd_1560x106.png 424w, https://substackcdn.com/image/fetch/$s_!mKap!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe4e1ee6-cc9a-4123-b176-de47f10489fd_1560x106.png 848w, https://substackcdn.com/image/fetch/$s_!mKap!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe4e1ee6-cc9a-4123-b176-de47f10489fd_1560x106.png 1272w, https://substackcdn.com/image/fetch/$s_!mKap!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe4e1ee6-cc9a-4123-b176-de47f10489fd_1560x106.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>The score is:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!1Ykd!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4cd5a645-3296-465f-9bf4-45e0c648a7d3_1912x108.png 424w, https://substackcdn.com/image/fetch/$s_!1Ykd!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4cd5a645-3296-465f-9bf4-45e0c648a7d3_1912x108.png 848w, https://substackcdn.com/image/fetch/$s_!1Ykd!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4cd5a645-3296-465f-9bf4-45e0c648a7d3_1912x108.png 1272w, https://substackcdn.com/image/fetch/$s_!1Ykd!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4cd5a645-3296-465f-9bf4-45e0c648a7d3_1912x108.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!1Ykd!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4cd5a645-3296-465f-9bf4-45e0c648a7d3_1912x108.png" width="1456" height="82" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4cd5a645-3296-465f-9bf4-45e0c648a7d3_1912x108.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:82,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!1Ykd!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4cd5a645-3296-465f-9bf4-45e0c648a7d3_1912x108.png 424w, https://substackcdn.com/image/fetch/$s_!1Ykd!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4cd5a645-3296-465f-9bf4-45e0c648a7d3_1912x108.png 848w, https://substackcdn.com/image/fetch/$s_!1Ykd!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4cd5a645-3296-465f-9bf4-45e0c648a7d3_1912x108.png 1272w, https://substackcdn.com/image/fetch/$s_!1Ykd!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4cd5a645-3296-465f-9bf4-45e0c648a7d3_1912x108.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>For candidate context C~2:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!HahK!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c83c43c-f6ea-4360-9a3c-4735e58e1251_1578x106.png 424w, https://substackcdn.com/image/fetch/$s_!HahK!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c83c43c-f6ea-4360-9a3c-4735e58e1251_1578x106.png 848w, https://substackcdn.com/image/fetch/$s_!HahK!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c83c43c-f6ea-4360-9a3c-4735e58e1251_1578x106.png 1272w, https://substackcdn.com/image/fetch/$s_!HahK!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c83c43c-f6ea-4360-9a3c-4735e58e1251_1578x106.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!HahK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c83c43c-f6ea-4360-9a3c-4735e58e1251_1578x106.png" width="700" height="47.11538461538461" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2c83c43c-f6ea-4360-9a3c-4735e58e1251_1578x106.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:98,&quot;width&quot;:1456,&quot;resizeWidth&quot;:700,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!HahK!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c83c43c-f6ea-4360-9a3c-4735e58e1251_1578x106.png 424w, https://substackcdn.com/image/fetch/$s_!HahK!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c83c43c-f6ea-4360-9a3c-4735e58e1251_1578x106.png 848w, https://substackcdn.com/image/fetch/$s_!HahK!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c83c43c-f6ea-4360-9a3c-4735e58e1251_1578x106.png 1272w, https://substackcdn.com/image/fetch/$s_!HahK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c83c43c-f6ea-4360-9a3c-4735e58e1251_1578x106.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>The score is:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!hTi5!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02770214-66db-4794-9e18-bf91ee040416_1892x116.png 424w, https://substackcdn.com/image/fetch/$s_!hTi5!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02770214-66db-4794-9e18-bf91ee040416_1892x116.png 848w, https://substackcdn.com/image/fetch/$s_!hTi5!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02770214-66db-4794-9e18-bf91ee040416_1892x116.png 1272w, https://substackcdn.com/image/fetch/$s_!hTi5!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02770214-66db-4794-9e18-bf91ee040416_1892x116.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!hTi5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02770214-66db-4794-9e18-bf91ee040416_1892x116.png" width="1456" height="89" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/02770214-66db-4794-9e18-bf91ee040416_1892x116.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:89,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!hTi5!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02770214-66db-4794-9e18-bf91ee040416_1892x116.png 424w, https://substackcdn.com/image/fetch/$s_!hTi5!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02770214-66db-4794-9e18-bf91ee040416_1892x116.png 848w, https://substackcdn.com/image/fetch/$s_!hTi5!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02770214-66db-4794-9e18-bf91ee040416_1892x116.png 1272w, https://substackcdn.com/image/fetch/$s_!hTi5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02770214-66db-4794-9e18-bf91ee040416_1892x116.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>Even though C~2 has higher raw coverage, C~1 receives the better score because it has stronger utilization, stronger freshness, and no source starvation. This illustrates why context quality must be evaluated across multiple dimensions rather than by relevance or coverage alone.</p><h2>Using Context Inspector in Development and CI</h2><p>One practical benefit of pre-inference inspection is that it can be moved into the development lifecycle. Teams can define representative queries, expected source requirements, minimum coverage thresholds, and policy gates. Those checks can run when retrieval logic, chunking strategy, metadata extraction, or ranking configuration changes.</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">def test_context_quality_for_process_query():

    selected_chunks = retrieve_context(

        query=&#8221;What steps apply for the current process?&#8221;

    )

    report = context_quality_report(selected_chunks, config)

    assert report[&#8221;passed&#8221;], report

    assert report[&#8221;metrics&#8221;][&#8221;coverage&#8221;] &gt;= 0.90

    assert report[&#8221;metrics&#8221;][&#8221;source_starvation&#8221;] == 0.0

    assert report[&#8221;metrics&#8221;][&#8221;contradiction_density&#8221;] == 0.0

    assert report[&#8221;metrics&#8221;][&#8221;policy_admissibility&#8221;] == 1.0</code></pre></div><p>This is not a replacement for response-level evaluation. It is a complementary guardrail. Response-level evaluation remains important, but context-quality checks can catch a class of failures earlier, when they are easier to diagnose and less expensive to correct.</p><h2>Design Principles</h2><ol><li><p>Context quality should be inspectable. A score is useful only if developers can understand the reason behind it. Metrics such as coverage, starvation, freshness, and contradiction density provide actionable signals rather than opaque judgments.</p></li><li><p>Context quality should be measured before inference. Once the LLM has generated an answer, teams are debugging both model behavior and context assembly behavior at the same time. Pre-inference inspection separates those concerns.</p></li><li><p>Privacy and governance should be built into the design. A context inspector should operate within approved access patterns and should use metadata or minimized signals where possible. Its purpose is to reduce risk by preventing inappropriate or low-quality context from entering the prompt.</p></li><li><p>Context inspection should be configurable. Different applications have different risk profiles. A low-risk summarization workflow may tolerate broader context and softer thresholds. A policy-sensitive workflow may require stricter source coverage, version controls, and admissibility checks.</p></li></ol><h2>Conclusion</h2><p>RAG systems are often judged by their final answers, but the quality of those answers begins earlier. It begins with the context.</p><p>Post-inference evaluation remains essential, but it is not sufficient on its own. It can tell us that an answer failed, but it may not immediately tell us whether the failure was caused by the model, the prompt, the retriever, the ranking strategy, stale content, missing sources, or conflicting evidence.</p><p>Context Inspector brings attention to the pre-inference layer. It evaluates whether the assembled context is complete, current, balanced, consistent, and admissible before the LLM call is made.</p><p>By inspecting context quality earlier, teams can reduce avoidable inference calls, improve debugging, strengthen observability, and build more reliable GenAI systems. The broader lesson is straightforward: better answers require better context, and better systems inspect that context before generation begins.<br></p><p><em>&#8216;Till next time!</em><br><a href="https://americanexpress.io/u/thangavelsubramaniam/">Thangavel</a> | <a href="https://americanexpress.io/u/saurabhgupta/">Saurabh</a></p><div><hr></div><p><em>Enjoyed the article? The most sincere compliment is to restack this for your readers.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://www.decodingai.com/p/pre-inference-rag-evaluation-metrics?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;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://www.decodingai.com/p/pre-inference-rag-evaluation-metrics?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p><div><hr></div><div class="callout-block" data-callout="true"><h4>Whenever you&#8217;re ready, here is how I can help you</h4><p><em>Go from agent user to agent builder.</em> Master the foundations of AI agents and turn fragile demo code into reliable, production-ready systems with my course, <strong><a href="https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering">Agent Engineering: Building Multi-Agent Systems</a></strong> (made with Towards AI).</p><p>35 lessons. Pure foundations from scratch. 4 mini-projects. 2 production systems. A certificate and direct access to me &amp; industry experts in our Discord.</p><p>Built for software and data professionals transitioning into AI engineering. <em>Rated 5/5 with 300+ students. The first 7 lessons are free:</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering&quot;,&quot;text&quot;:&quot;Start here&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering"><span>Start here</span></a></p><p><em>Not ready to commit?</em> Start with our <strong><a href="https://email-course.towardsai.net/?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering">free Agent AI Engineering Guide</a></strong>, a 6-day email course on the mistakes that silently break AI agents in production.</p></div><div><hr></div><h2>Images &amp; videos</h2><p>If not otherwise stated, all images and videos are created by the author.</p><div><hr></div><h2>Copyrights</h2><p>This article originally appeared on <a href="https://americanexpress.io/context-inspector-measuring-context-quality-before-the-llm-call/">American Express Technology</a> and is republished here with the authors&#8217; permission.</p>]]></content:encoded></item><item><title><![CDATA[The Future of AI Coding: Multi-Agent]]></title><description><![CDATA[Using orchestration to get the best results]]></description><link>https://www.decodingai.com/p/the-future-of-ai-coding-is-multi-agent</link><guid isPermaLink="false">https://www.decodingai.com/p/the-future-of-ai-coding-is-multi-agent</guid><dc:creator><![CDATA[Johannes Millan]]></dc:creator><pubDate>Tue, 13 Oct 2026 11:03:04 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/c1cb6ef8-e685-42bb-90ff-11dd1206576e_1376x768.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><strong>Paul:</strong>&nbsp;Joining us is Johannes, an open-source developer and the creator of Super Productivity and Plainspace. His latest project,&nbsp;<em>Parallel Code,&nbsp;</em>is an<em>&nbsp;</em>MIT-licensed desktop app for coordinating CLI coding agents in isolated Git worktrees.</p><p>Passing the mic &#127897;&#65039;</p><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_!O3b9!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F157b9299-520c-408c-b69f-0ba938560c7d_1376x768.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!O3b9!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F157b9299-520c-408c-b69f-0ba938560c7d_1376x768.png 424w, https://substackcdn.com/image/fetch/$s_!O3b9!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F157b9299-520c-408c-b69f-0ba938560c7d_1376x768.png 848w, https://substackcdn.com/image/fetch/$s_!O3b9!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F157b9299-520c-408c-b69f-0ba938560c7d_1376x768.png 1272w, https://substackcdn.com/image/fetch/$s_!O3b9!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F157b9299-520c-408c-b69f-0ba938560c7d_1376x768.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!O3b9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F157b9299-520c-408c-b69f-0ba938560c7d_1376x768.png" width="1376" height="768" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/157b9299-520c-408c-b69f-0ba938560c7d_1376x768.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:768,&quot;width&quot;:1376,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1264450,&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://www.decodingai.com/i/218927122?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F157b9299-520c-408c-b69f-0ba938560c7d_1376x768.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_!O3b9!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F157b9299-520c-408c-b69f-0ba938560c7d_1376x768.png 424w, https://substackcdn.com/image/fetch/$s_!O3b9!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F157b9299-520c-408c-b69f-0ba938560c7d_1376x768.png 848w, https://substackcdn.com/image/fetch/$s_!O3b9!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F157b9299-520c-408c-b69f-0ba938560c7d_1376x768.png 1272w, https://substackcdn.com/image/fetch/$s_!O3b9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F157b9299-520c-408c-b69f-0ba938560c7d_1376x768.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>Ask one AI agent to fix a bug, and you get one guess, delivered with total confidence. A better model makes that guess better. It is still one interpretation of the problem, one proposed solution, and one set of blind spots.</p><p>You have probably seen this play out. You hand an agent a bug report, and ten minutes later it returns a clean, passing, 400-line diff. Only during review do you notice that it patched the symptom in the wrong layer, duplicated a helper that already existed, and quietly changed behavior nobody asked about. The obvious workaround, running several agents on the same task and picking the best result, only moves the pain: now you review three 400-line diffs instead of one. Either way, the bottleneck is the same. Generating code is cheap. Your attention, spent working out whether the code is right, is not.</p><p>For important engineering problems, a stronger workflow is:</p><blockquote><p><strong>Explore in parallel. Implement once. Review in parallel. Refine and review until the result is trustworthy.</strong></p></blockquote><p>This uses more inference, but less programmer attention. The aim is not to generate more code. It is to reach a strong solution quickly without forcing the developer to compare several complete implementations.</p><h2>Explore the problem in parallel</h2><p>Before writing code, several different models inspect the task and repository independently. Think of it as the first half of planning: it gathers the evidence the plan will be built on.</p><p>This is where multi-model usage provides the most value. Different model families are more likely to inspect different execution paths, favor different architectural patterns, and challenge one another&#8217;s assumptions.</p><p>Each model should return:</p><ul><li><p>its understanding of the problem;</p></li><li><p>evidence from relevant files and symbols;</p></li><li><p>the proposed solution;</p></li><li><p>alternatives considered;</p></li><li><p>affected components;</p></li><li><p>risks and possible regressions;</p></li><li><p>and tests that should prove the result.</p></li></ul><p>They should not edit the repository yet.</p><p>A useful prompt is:</p><p>Investigate the task independently. Do not modify the repository.</p><p>Identify:</p><ol><li><p>the likely cause or core design problem,</p></li><li><p>evidence from specific files and symbols,</p></li><li><p>the smallest viable solution,</p></li><li><p>alternatives considered,</p></li><li><p>expected risks,</p></li><li><p>tests that should fail before and pass afterward.</p></li></ol><p>Comparing several short proposals is much cheaper than comparing several finished implementations.</p><p>One model may propose changing persistence logic. Another may find that the actual defect is in derived UI state. A third may discover an existing abstraction that makes both changes unnecessary.</p><p>The developer or a lead agent then selects one approach, possibly combining compatible parts of several proposals.</p><p>The decision should be based on evidence:</p><ul><li><p>Does it address the cause rather than the symptom?</p></li><li><p>Is the change made in the correct layer?</p></li><li><p>Is there a smaller solution?</p></li><li><p>Does the codebase already contain a suitable pattern?</p></li><li><p>Can the result be tested clearly?</p></li><li><p>What could regress?</p></li></ul><p>Only create competing implementations when analysis cannot resolve an important uncertainty, such as two algorithms that need benchmarking or two architectures with genuinely different trade-offs.</p><h2>Turn the selection into a plan</h2><p>Exploration answers &#8220;what is actually wrong, and what are the options?&#8221; Planning answers &#8220;what exactly will we change?&#8221; Before any code is touched, the selected approach is written down as a short plan:</p><ul><li><p>the root cause, and the evidence for it;</p></li><li><p>the files and symbols to change, and those to leave alone;</p></li><li><p>the ordered steps;</p></li><li><p>the tests that should fail now and pass afterward;</p></li><li><p>and explicit non-goals.</p></li></ul><p>The plan becomes the contract for the implementation agent, and later the reviewers check the diff against it. Rejected proposals still contribute: their risks and edge cases go into the plan as things to guard against.</p><h2>Implement once</h2><p>One agent implements the selected approach in an isolated Git worktree.</p><p>It receives the requirements, chosen plan, relevant insights from the other proposals, repository guidelines, and expected tests.</p><p>This keeps the implementation coherent. There is one branch to understand, one diff to review, and one result to merge.</p><p>If the implementation agent discovers evidence that contradicts the plan, it should update the approach rather than follow the plan blindly.</p><h2>Review in parallel</h2><p>After implementation, several independent agents review the same change.</p><p>Generic review prompts produce repeated comments and noise. Each reviewer should have a defined responsibility.</p><p>A thorough review team might include:</p><ul><li><p><strong>Correctness:</strong> bugs, invalid assumptions, races, missing error handling, and edge cases.</p></li><li><p><strong>Security:</strong> authorization, injection, sensitive data, unsafe input handling, and configuration risks.</p></li><li><p><strong>Architecture:</strong> consistency with existing patterns, coupling, abstractions, and separation of concerns.</p></li><li><p><strong>Alternatives:</strong> simpler algorithms, framework features, standard-library replacements, and more idiomatic solutions.</p></li><li><p><strong>Performance:</strong> unnecessary work, memory use, rendering cost, network behavior, and blocking operations.</p></li><li><p><strong>Simplicity:</strong> unnecessary files, layers, abstractions, and speculative generality.</p></li><li><p><strong>Independent model review:</strong> a broad review from another model family.</p></li></ul><p>Every reviewer receives:</p><ul><li><p>the original requirements;</p></li><li><p>the complete diff;</p></li><li><p>the changed-file list;</p></li><li><p>repository guidelines;</p></li><li><p>and access to the surrounding source code.</p></li></ul><p>Reviewers must inspect the repository before reporting a problem. A patch alone often lacks the context needed to distinguish a real defect from an intentional project pattern.</p><p>Each finding should include:</p><ul><li><p>severity;</p></li><li><p>exact location;</p></li><li><p>a concrete failure or maintenance scenario;</p></li><li><p>supporting evidence;</p></li><li><p>the smallest reasonable fix;</p></li><li><p>and confidence.</p></li></ul><p>The reviewers work independently so that one review does not anchor the others.</p><h2>Synthesize the findings</h2><p>The programmer should not have to read seven raw reports.</p><p>A synthesis step should:</p><ol><li><p>verify every claim against the code;</p></li><li><p>remove false positives;</p></li><li><p>merge duplicate findings;</p></li><li><p>correct inflated severity;</p></li><li><p>identify disagreements;</p></li><li><p>and produce one final verdict.</p></li></ol><p>The result should contain only verified critical issues, relevant warnings, useful suggestions, unresolved disagreements, and a clear approval decision.</p><p>Reviewer agreement is useful, but it is not proof. Several agents may share the same misunderstanding, especially when they use the same underlying model.</p><blockquote><p>Agreement determines what to investigate first. Evidence determines what to accept.</p></blockquote><p>Human judgment remains necessary for trade-offs. One reviewer may recommend an abstraction to remove duplication, while another may argue that the abstraction hides meaningful differences. The correct choice depends on the project, not on vote count.</p><h2>Refine and review again</h2><p>Accepted findings are passed back to an implementation agent. It refines the existing branch, and the change is reviewed again.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!d5mv!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1de15693-8bda-40df-9b38-eeb1e5af5b6b_2048x768.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!d5mv!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1de15693-8bda-40df-9b38-eeb1e5af5b6b_2048x768.png 424w, https://substackcdn.com/image/fetch/$s_!d5mv!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1de15693-8bda-40df-9b38-eeb1e5af5b6b_2048x768.png 848w, https://substackcdn.com/image/fetch/$s_!d5mv!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1de15693-8bda-40df-9b38-eeb1e5af5b6b_2048x768.png 1272w, https://substackcdn.com/image/fetch/$s_!d5mv!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1de15693-8bda-40df-9b38-eeb1e5af5b6b_2048x768.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!d5mv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1de15693-8bda-40df-9b38-eeb1e5af5b6b_2048x768.png" width="1456" height="546" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1de15693-8bda-40df-9b38-eeb1e5af5b6b_2048x768.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:546,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!d5mv!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1de15693-8bda-40df-9b38-eeb1e5af5b6b_2048x768.png 424w, https://substackcdn.com/image/fetch/$s_!d5mv!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1de15693-8bda-40df-9b38-eeb1e5af5b6b_2048x768.png 848w, https://substackcdn.com/image/fetch/$s_!d5mv!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1de15693-8bda-40df-9b38-eeb1e5af5b6b_2048x768.png 1272w, https://substackcdn.com/image/fetch/$s_!d5mv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1de15693-8bda-40df-9b38-eeb1e5af5b6b_2048x768.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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 second review matters because fixes can introduce new defects or unnecessary complexity.</p><p>The loop should stop when:</p><ul><li><p>no verified critical issues remain;</p></li><li><p>remaining warnings are resolved or explicitly accepted;</p></li><li><p>tests cover the important behavior;</p></li><li><p>the result still matches the original requirements;</p></li><li><p>and another review pass produces little new information.</p></li></ul><p>The goal is confidence, not endless iteration.</p><h2>A worked example</h2><p>A task manager receives a bug report: &#8220;Tasks I complete on my phone show up as undone on my laptop after sync.&#8221;</p><p><strong>Explore.</strong> Three models investigate in read-only mode. Model A traces the sync code and concludes that conflict resolution drops the completed flag when both devices edited the task. Model B blames the UI: the laptop recomputes its &#8220;done&#8221; filter from stale cached state. Model C finds that the app already has a per-field merge utility, used for projects but not for tasks. Each proposal cites files and names a test that should fail.</p><p><strong>Decide and plan.</strong> Reading three one-page proposals takes five minutes. A reproduction test confirms the conflict path, so the UI theory is rejected, but its stale-cache observation goes into the plan as a risk. The plan: reuse the existing merge utility for tasks, add a regression test for concurrent edits, and leave the UI layer alone.</p><p><strong>Implement once.</strong> One agent executes the plan in its own worktree: about 60 lines of code plus tests.</p><p><strong>Review in parallel.</strong> The correctness reviewer flags an uncovered case: a task deleted on one device while it is completed on another. The architecture reviewer approves the reuse. The simplicity reviewer notes that an old helper is now dead code. The security reviewer finds nothing.</p><p><strong>Synthesize.</strong> A new test confirms that the delete-and-complete case fails, so it is accepted as critical. Removing the dead helper is accepted as a warning. Two duplicate comments are merged, and one reported race is dropped because sync runs serially.</p><p><strong>Refine and review again.</strong> The agent handles the edge case and removes the helper. The second review adds nothing of consequence, and the change is merged.</p><p>The developer made three decisions: which cause was real, whether the edge case mattered, and whether to merge. Everything else was agent time.</p><h2>Why this saves programmer time</h2><p>This workflow consumes more agent computation than asking one model to solve the entire task. But computation is not usually the bottleneck.</p><p>Programmer attention is.</p><p>The developer does not need to investigate every approach personally, compare several complete implementations, or read every unfiltered review comment.</p><p>Instead, the developer receives a compressed sequence of decisions:</p><ol><li><p>These are the strongest approaches.</p></li><li><p>This is the selected implementation.</p></li><li><p>These are the verified problems.</p></li><li><p>These refinements were made.</p></li><li><p>This is the evidence that the result is ready.</p></li></ol><h2>When to use it</h2><p>This workflow is not a fit for the smallest tasks. Use it when the cost of a wrong solution outweighs the additional orchestration, for example:</p><ul><li><p>bugs whose cause is unclear or spans several layers;</p></li><li><p>changes to core code such as sync, persistence, or data models;</p></li><li><p>security-sensitive changes;</p></li><li><p>and cross-cutting refactors or architectural decisions.</p></li></ul><p>For typo fixes, renames, dependency bumps, or small changes you already know how to make, a single agent is faster. A useful middle ground is to skip parallel exploration and keep only the parallel review.</p><h2>Using it with Claude Code, Codex, and other agents</h2><p>You do not need a new platform to try this. The building blocks already exist in the CLI agents most developers use:</p><ul><li><p><strong>Explore:</strong> run the investigation prompt non-interactively in several agents at once, for example: claude -p, codex exec, and gemini -p, each restricted to read-only access, and save each proposal to a file.</p></li><li><p><strong>Plan:</strong> commit a short PLAN.md to the branch, or use Claude Code&#8217;s plan mode, so the implementation agent has an explicit contract.</p></li><li><p><strong>Implement:</strong> git worktree add gives the implementer an isolated checkout that no other agent touches.</p></li><li><p><strong>Review:</strong> define each reviewer role once, for example as a Claude Code subagent in .claude/agents/ or as a reusable prompt file, so every run uses the same responsibilities and finding format. Keep project conventions in CLAUDE.md or AGENTS.md so every agent sees them.</p></li><li><p><strong>Synthesize:</strong> one more agent call that receives the diff, all review files, and the verification instructions.</p></li></ul><p>Wrap these steps in a custom slash command or a small script, and the whole loop runs from a single command. I built Parallel Code, an open-source desktop app, partly for this: it runs Claude Code, Codex, and Gemini CLI side by side, each in its own worktree, so the parallel phases stay easy to follow.</p><h2>Conclusion</h2><p>The future of AI coding is not simply one increasingly capable model working alone.</p><p>For important problems, the more effective workflow is:</p><blockquote><p><strong>Use multiple models to explore the problem, implement one coherent solution, review it from several perspectives, and repeat until the evidence is convincing.</strong></p></blockquote><p>Better models improve each role. Multi-agent workflows turn those roles into an engineering process.<br></p><p>&#8216;Till next time!<br><a href="https://substack.com/@johannes420067?utm_source=global-search">Johannes</a></p><div><hr></div><p><em>Enjoyed the article? The most sincere compliment is to restack this for your readers.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://www.decodingai.com/p/the-future-of-ai-coding-is-multi-agent?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;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://www.decodingai.com/p/the-future-of-ai-coding-is-multi-agent?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p><div><hr></div><div class="callout-block" data-callout="true"><h4>Whenever you&#8217;re ready, here is how I can help you</h4><p><em>Go from agent user to agent builder.</em> Master the foundations of AI agents and turn fragile demo code into reliable, production-ready systems with my course, <strong><a href="https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering">Agent Engineering: Building Multi-Agent Systems</a></strong> (made with Towards AI).</p><p>35 lessons. Pure foundations from scratch. 4 mini-projects. 2 production systems. A certificate and direct access to me &amp; industry experts in our Discord.</p><p>Built for software and data professionals transitioning into AI engineering. <em>Rated 5/5 with 300+ students. The first 7 lessons are free:</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering&quot;,&quot;text&quot;:&quot;Start here&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering"><span>Start here</span></a></p><p><em>Not ready to commit?</em> Start with our <strong><a href="https://email-course.towardsai.net/?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering">free Agent AI Engineering Guide</a></strong>, a 6-day email course on the mistakes that silently break AI agents in production.</p></div><div><hr></div><h2>Images &amp; videos</h2><p>If not otherwise stated, all images and videos are created by the author.</p>]]></content:encoded></item><item><title><![CDATA[Learning Harness Engineering by Building a Coding Agent From Scratch]]></title><description><![CDATA[A complete guide to harness engineering, starting from first principles.]]></description><link>https://www.decodingai.com/p/learning-harness-engineering-by-building</link><guid isPermaLink="false">https://www.decodingai.com/p/learning-harness-engineering-by-building</guid><dc:creator><![CDATA[Paul Iusztin]]></dc:creator><pubDate>Sat, 10 Oct 2026 12:27:17 GMT</pubDate><enclosure url="https://api.substack.com/feed/podcast/219448314/d5e0fff8cf1631833b1aaccf87c4e6c6.mp3" length="0" type="audio/mpeg"/><content:encoded><![CDATA[<p><em>Webinar distilling the 8 articles and 6 videos of the <a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course">How to Build a Coding Agent From Scratch</a> open-source course into 90 minutes of hardcore harness engineering from first principles.</em></p><p><em>Made by busy people for busy people! </em>A good intro to see if the course is a good fit before you commit to the full version. </p><blockquote><p>&#128218; Find all the lessons and the code <a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course">here</a>. </p></blockquote><p>Othe&#8230;</p>
      <p>
          <a href="https://www.decodingai.com/p/learning-harness-engineering-by-building">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[The Agentic Software Factory Hierarchy of Needs]]></title><description><![CDATA[How to build software with agents that keep working while you&#8217;re away]]></description><link>https://www.decodingai.com/p/the-agentic-software-factory-hierarchy</link><guid isPermaLink="false">https://www.decodingai.com/p/the-agentic-software-factory-hierarchy</guid><dc:creator><![CDATA[Hugo Bowne-Anderson]]></dc:creator><pubDate>Fri, 09 Oct 2026 11:01:42 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/ca6368af-b87b-477f-a641-00c30f446ffa_1376x768.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="callout-block" data-callout="true"><p><em>This article originally appeared in Hugo&#8217;s newsletter, <a href="https://hugobowne.substack.com/p/the-agentic-software-factory-hierarchy">Vanishing Gradients</a>, and is republished here with the authors&#8217; permission.</em></p></div><p><strong>Paul:</strong> Today, two of&nbsp;the industry&#8217;s brilliant minds own the scene.</p><p>You&#8217;ll learn from Hugo, who teaches LLM systems to engineers at Netflix and Meta, and Eleanor, a former principal engineer at Microsoft and Google who&#8217;s now building evidence-based, production-ready AI at Jimini Health and Agentic Ventures. </p><p>They&#8217;ve created this dope course on&nbsp;<a href="https://maven.com/agentic-ventures/agent-factory?promoCode=FRIENDSOFPAUL&amp;utm_source=paul_substack&amp;utm_medium=newsletter&amp;utm_campaign=agent_factory&amp;utm_content=paul_hierarchy_essay_2026_10_08">building an agentic software factory.</a><em>&nbsp;Decoding AI community members get 25% off via the link or code FRIENDSOFPAUL at checkout,&nbsp;</em>plus&nbsp;<em>$500 in Modal credits.</em>&nbsp;</p><p><em>P.S.</em> <em>Take notes on this one.</em> &#9997;&#127996;</p><div><hr></div><h2>Agentic software factories are here</h2><p><em><a href="https://stripe.dev/blog/minions-stripes-one-shot-end-to-end-coding-agents">Stripe&#8217;s Minions</a> turn engineering requests into candidate pull requests. <a href="https://engineering.ramp.com/post/why-we-built-our-background-agent">Ramp&#8217;s Inspect</a> puts coding agents to work in the background, with tools to check their changes. <a href="https://docs.warp.dev/factories/">Warp Factories</a> takes work from tickets and chat through agents, checks, and human review. <strong>Agentic software factories are here.</strong></em></p><p>Are you sick and tired of babysitting Codex, Claude Code, or OpenClaw?</p><p>Do you have agents that can build features, but still leave you responsible for remembering where they stopped, explaining how each feature fits the project and deciding what happens next? You make progress in each conversation, then development waits for you to return.</p><p>It doesn&#8217;t have to be this way. A software factory lets you delegate more of that process!</p><p>You agree on an outcome, give the system the context and authority it needs, and let it work while you do something else. When you return, there should be</p><ol><li><p>a result you can inspect, with evidence of what was checked; or</p></li><li><p>a specific reason the work could not continue.</p></li></ol><p>Your next conversation can then focus on the result and the decisions that remain.</p><p>As we&#8217;ll show you, your first software factory doesn&#8217;t need to be that complex at all: it can begin with a single agent and an automation.</p><h2>What makes it a factory</h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!sKpW!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffab84faf-d6eb-4a8e-b121-2cf275006728_1456x819.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!sKpW!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffab84faf-d6eb-4a8e-b121-2cf275006728_1456x819.png 424w, https://substackcdn.com/image/fetch/$s_!sKpW!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffab84faf-d6eb-4a8e-b121-2cf275006728_1456x819.png 848w, https://substackcdn.com/image/fetch/$s_!sKpW!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffab84faf-d6eb-4a8e-b121-2cf275006728_1456x819.png 1272w, https://substackcdn.com/image/fetch/$s_!sKpW!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffab84faf-d6eb-4a8e-b121-2cf275006728_1456x819.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!sKpW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffab84faf-d6eb-4a8e-b121-2cf275006728_1456x819.png" width="1456" height="819" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fab84faf-d6eb-4a8e-b121-2cf275006728_1456x819.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:819,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!sKpW!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffab84faf-d6eb-4a8e-b121-2cf275006728_1456x819.png 424w, https://substackcdn.com/image/fetch/$s_!sKpW!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffab84faf-d6eb-4a8e-b121-2cf275006728_1456x819.png 848w, https://substackcdn.com/image/fetch/$s_!sKpW!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffab84faf-d6eb-4a8e-b121-2cf275006728_1456x819.png 1272w, https://substackcdn.com/image/fetch/$s_!sKpW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffab84faf-d6eb-4a8e-b121-2cf275006728_1456x819.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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 defining combination is <strong>autonomous and asynchronous execution</strong>.</p><ul><li><p><strong>Autonomous:</strong> the agent chooses and carries out steps towards an agreed goal. It can inspect what happened, adjust its approach and continue within its authority.</p></li><li><p><strong>Asynchronous:</strong> that work can proceed without your ongoing attention. You can leave and return to its result.</p></li></ul><p>A scheduled job can run without you. A coding agent can choose and revise an approach during an interactive session. A factory combines those capabilities, with enough context, tools and feedback to carry out the delegated work.</p><p>Software factories have been hypothesized for decades. Now that we have agents, we&#8217;re actually able to operate them. The principles apply to software work traditionally carried out by teams of humans, from bespoke tools for teams and individuals to large and complex software systems.</p><p>To illustrate these principles, we&#8217;ll use an invoice tracker throughout this article, an application we&#8217;ve needed for our own businesses. The same approach applies to research tools, publishing systems and software for teams. Suppose you run a small business and want an invoice tracker that fits how you work:</p><p><em>Build an app that creates invoices from my template and tracks which are unpaid, paid or overdue. Keep it local for now. Preserve the records when it restarts, and show me checks that the totals and payment statuses are correct.</em></p><p>You can agree on this brief with the agent, leave it to work while you do something else, and return to the app and evidence of what was checked. If a check fails, it can investigate and adjust within its agreed scope. If it encounters a product decision it cannot make, it should bring that question back to you.</p><p>You might imagine a clean separation: the factory builds the invoice tracker, then the finished app does its job. That&#8217;s one way to run it. But agents can also help operate the software they build, and that combination is useful.</p><p>The tracker can store invoices and calculate outstanding balances. An agent can use those records alongside customer correspondence to prepare follow-ups: one customer has promised to pay on Friday; another is disputing a charge. You don&#8217;t need to turn every situation into a new software feature before the agent can help. You give it the relevant context, authority and a way to check its work.</p><p>This changes what you need to build! Some behaviour belongs in code, such as calculating balances consistently. Other work can be delegated to an agent that responds to the circumstances. If a recurring need emerges, you can ask the factory to build it into the software. The factory builds tools that agents can use, and experience using those tools helps you decide what to build next.</p><p>You still decide what is worth building, who it should serve and which trade-offs matter. Agents can help you make those decisions too. The practical change is that implementation can proceed between your conversations, including running checks and responding to failures.</p><p><em>This makes factories relevant to people with product, business or creative expertise as well as engineers. You might know exactly how you invoice clients, record payments and chase overdue bills while having little interest in writing software. That knowledge lets you direct the factory towards software that fits your business, including the exceptions and connections that general-purpose tools handle poorly.</em></p><h2>The software factory hierarchy of needs</h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!MkDl!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb78ceaf8-8d9a-44ba-bc91-96cff3635a3b_1254x1254.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!MkDl!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb78ceaf8-8d9a-44ba-bc91-96cff3635a3b_1254x1254.png 424w, https://substackcdn.com/image/fetch/$s_!MkDl!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb78ceaf8-8d9a-44ba-bc91-96cff3635a3b_1254x1254.png 848w, https://substackcdn.com/image/fetch/$s_!MkDl!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb78ceaf8-8d9a-44ba-bc91-96cff3635a3b_1254x1254.png 1272w, https://substackcdn.com/image/fetch/$s_!MkDl!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb78ceaf8-8d9a-44ba-bc91-96cff3635a3b_1254x1254.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!MkDl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb78ceaf8-8d9a-44ba-bc91-96cff3635a3b_1254x1254.png" width="1254" height="1254" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b78ceaf8-8d9a-44ba-bc91-96cff3635a3b_1254x1254.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1254,&quot;width&quot;:1254,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!MkDl!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb78ceaf8-8d9a-44ba-bc91-96cff3635a3b_1254x1254.png 424w, https://substackcdn.com/image/fetch/$s_!MkDl!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb78ceaf8-8d9a-44ba-bc91-96cff3635a3b_1254x1254.png 848w, https://substackcdn.com/image/fetch/$s_!MkDl!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb78ceaf8-8d9a-44ba-bc91-96cff3635a3b_1254x1254.png 1272w, https://substackcdn.com/image/fetch/$s_!MkDl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb78ceaf8-8d9a-44ba-bc91-96cff3635a3b_1254x1254.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>At every layer: specify what you want and how success will be checked, then verify the result.</em></figcaption></figure></div><p><a href="https://hackernoon.com/the-ai-hierarchy-of-needs-18f111fcc007">Monica Rogati&#8217;s original AI hierarchy of needs</a> described the foundations beneath successful AI work. We find that dependency framing helpful for factories too, with four different layers.</p><ol><li><p><strong>Harness.</strong> The environment around the model: tools, a workspace for project files, execution and feedback. It lets an agent read files, change software and run it. If a check fails, the harness must give the agent enough information to investigate what happened.</p></li><li><p><strong>Personalisation.</strong> The context and capabilities for your work: project direction, rules, reference material, skills and connections to other systems. The agent needs to know what you are trying to accomplish and which existing decisions it should preserve. Permissions limit access to tools and systems; sandboxing restricts the environment where actions can run.</p></li><li><p><strong>Automation.</strong> A way to start and continue work without a fresh instruction from you each time. A schedule or event can trigger a task or the pickup of ready work. It also needs direction about what qualifies as ready and where to leave the result.</p></li><li><p><strong>Continual learning.</strong> A process for learning from completed and failed runs, improving the factory and carrying those changes into later work. That might change an instruction, a checking procedure or a tool the agent uses.</p></li></ol><p><strong>Automation</strong> needs a harness able to do the work, plus direction about what to do. <strong>Continual learning</strong> needs runs to inspect and a way to put improvements into use. These capabilities can develop together: a familiar harness, a short brief and a basic automation are enough to start. You can personalise further as work reveals what is missing.</p><p>Two practices run through every layer: <strong>specification </strong>and<strong> verification</strong>:</p><ul><li><p>Specification makes the intended outcome, constraints and criteria for success explicit. In our invoice brief, that includes preserving records after a restart and calculating payment statuses correctly.</p></li><li><p>Verification checks the software and the work agents perform against those requirements.</p></li></ul><p>Agents can help you refine the specification and perform the checks. Your role is to decide whether the requirements capture what you need and whether the evidence supports accepting the result. As the factory takes on more work, these practices give you a way to direct it and assess what comes back.</p><p>Let&#8217;s now see what&#8217;s up in each layer.</p><h2>1. Agent harness</h2><p>First, you&#8217;ll need an agent harness. If you&#8217;re using Codex, Claude Code, Hermes, or OpenClaw, you already have one. It gives the model tools to read and edit files, run your software and see what happened.</p><p>For our invoice tracker, the agent can build the app, create an invoice, record a payment and restart it to check that the invoice and payment records survived. If a paid invoice still shows as overdue, it can investigate, fix the problem and try again. You shouldn&#8217;t have to narrate every step. But if it needs a decision about how your business handles partial payments, that&#8217;s a question for you. If it lacks access or authority, the agent should stop and name the blocker.</p><p>You&#8217;ll also need somewhere for the harness to run. A cloud machine lets the agent keep working while your laptop is closed or disconnected. You can also run it on your own computer, but the machine needs to stay awake and connected for the work to continue.</p><h2>2. Personalisation</h2><p>Next, give the agent the context it needs to work your way. For our invoice tracker, that means your template, payment terms and conventions for recording payments. You don&#8217;t want to explain all of that again every time you start a new task.</p><p>Keep it somewhere future workers can find it:</p><ul><li><p><strong>Rules:</strong> preserve existing invoice records; ask before changing payment-status calculations.</p></li><li><p><strong>References:</strong> your template, payment terms and example invoices.</p></li><li><p><strong>Skills:</strong> repeatable procedures for testing invoice creation, payment updates and persistence.</p></li></ul><p>An instruction file such as AGENTS.md can point to this material. <a href="https://openai.com/index/harness-engineering/">OpenAI&#8217;s harness-engineering account</a> describes using a short guide that points into maintained project documentation. Give a new or scheduled worker a small task and check that it actually follows the guidance.</p><p>Be specific about when instructions apply. Eleanor once told an agent to write tests, and it wrote tests for a README. Enthusiasm wasn&#8217;t the problem &#128514;</p><p>You&#8217;ll also need to set permissions and sandboxing to control what the agent can access and execute. Written instructions alone don&#8217;t enforce those boundaries!</p><h2>3. Automation</h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!BKrc!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6bde02d2-6dd2-4ea6-bdf6-8f854af19971_1672x941.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!BKrc!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6bde02d2-6dd2-4ea6-bdf6-8f854af19971_1672x941.png 424w, https://substackcdn.com/image/fetch/$s_!BKrc!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6bde02d2-6dd2-4ea6-bdf6-8f854af19971_1672x941.png 848w, https://substackcdn.com/image/fetch/$s_!BKrc!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6bde02d2-6dd2-4ea6-bdf6-8f854af19971_1672x941.png 1272w, https://substackcdn.com/image/fetch/$s_!BKrc!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6bde02d2-6dd2-4ea6-bdf6-8f854af19971_1672x941.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!BKrc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6bde02d2-6dd2-4ea6-bdf6-8f854af19971_1672x941.png" width="1456" height="819" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6bde02d2-6dd2-4ea6-bdf6-8f854af19971_1672x941.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:819,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!BKrc!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6bde02d2-6dd2-4ea6-bdf6-8f854af19971_1672x941.png 424w, https://substackcdn.com/image/fetch/$s_!BKrc!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6bde02d2-6dd2-4ea6-bdf6-8f854af19971_1672x941.png 848w, https://substackcdn.com/image/fetch/$s_!BKrc!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6bde02d2-6dd2-4ea6-bdf6-8f854af19971_1672x941.png 1272w, https://substackcdn.com/image/fetch/$s_!BKrc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6bde02d2-6dd2-4ea6-bdf6-8f854af19971_1672x941.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>One agent works in the background; you assess what comes back.</em></figcaption></figure></div><p>Now let&#8217;s give the factory a way to get started without waiting for you. A schedule or event can launch an agent with its brief, project guidance and tools. You come back to a result, evidence of what was checked or a specific blocker that needs your attention.</p><h3>One agent working in the background</h3><p>For our invoice tracker, a morning automation could check a saved task list and pick up the next agreed task, such as adding partial payments. You&#8217;ve decided what you want and how success will be checked. The agent gets on with it while you do something else.</p><p>There are a few practical details to get right. Don&#8217;t start the same task twice, leave an empty queue alone, and set limits on time and spending. Save progress so a later session can continue without you having to reconstruct the whole conversation.</p><p>One worker may be plenty. But perhaps you have independent tasks that could run in parallel, or you&#8217;d like another agent to review a change. That&#8217;s where coordination comes in.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!0i3U!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd3b8f59-7f55-401a-a835-dd9e90484b77_1672x941.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!0i3U!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd3b8f59-7f55-401a-a835-dd9e90484b77_1672x941.png 424w, https://substackcdn.com/image/fetch/$s_!0i3U!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd3b8f59-7f55-401a-a835-dd9e90484b77_1672x941.png 848w, https://substackcdn.com/image/fetch/$s_!0i3U!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd3b8f59-7f55-401a-a835-dd9e90484b77_1672x941.png 1272w, https://substackcdn.com/image/fetch/$s_!0i3U!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd3b8f59-7f55-401a-a835-dd9e90484b77_1672x941.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!0i3U!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd3b8f59-7f55-401a-a835-dd9e90484b77_1672x941.png" width="1456" height="819" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/dd3b8f59-7f55-401a-a835-dd9e90484b77_1672x941.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:819,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!0i3U!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd3b8f59-7f55-401a-a835-dd9e90484b77_1672x941.png 424w, https://substackcdn.com/image/fetch/$s_!0i3U!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd3b8f59-7f55-401a-a835-dd9e90484b77_1672x941.png 848w, https://substackcdn.com/image/fetch/$s_!0i3U!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd3b8f59-7f55-401a-a835-dd9e90484b77_1672x941.png 1272w, https://substackcdn.com/image/fetch/$s_!0i3U!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd3b8f59-7f55-401a-a835-dd9e90484b77_1672x941.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Coordinate ready work, then check the combined result.</em></figcaption></figure></div><h3>Coordinated work</h3><p>With several agents, everyone needs somewhere to see what&#8217;s ready, what&#8217;s underway and what&#8217;s waiting on something else. A shared task list or issue tracker can hold that information. You agree which tasks are ready; a coordinating agent or automation assigns them, supplies the relevant context and records what happens.</p><p>Suppose one task adds partial payments, another overdue follow-up emails, and a third PDF exports. Follow-ups need the correct outstanding balance, so they wait for the payment behaviour to be checked. PDF exports might proceed independently if the changes don&#8217;t overlap.</p><p>You can also split the roles. One agent builds the feature while another prepares payment scenarios to test it. A third might review the completed change.</p><p>Assign responsibility for combining the changes and verifying the whole application. Different questions call for different checks. Deterministic tests can establish whether balances are calculated correctly and payments survive a restart. Agent verification can help identify missed requirements or inconsistencies across the changes. Human judgment can assess whether the workflow fits how you actually work. You&#8217;ll often want a combination, with more than one kind of check on the same result. <a href="https://www.anthropic.com/engineering/demystifying-evals-for-ai-agents">Anthropic&#8217;s evaluation guide</a> describes these complementary approaches: code-based checks, model-based checks and human evaluation.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!TYgA!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6880dd6-0c10-4a61-a40f-144219ab57e1_1536x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!TYgA!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6880dd6-0c10-4a61-a40f-144219ab57e1_1536x1024.png 424w, https://substackcdn.com/image/fetch/$s_!TYgA!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6880dd6-0c10-4a61-a40f-144219ab57e1_1536x1024.png 848w, https://substackcdn.com/image/fetch/$s_!TYgA!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6880dd6-0c10-4a61-a40f-144219ab57e1_1536x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!TYgA!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6880dd6-0c10-4a61-a40f-144219ab57e1_1536x1024.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!TYgA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6880dd6-0c10-4a61-a40f-144219ab57e1_1536x1024.png" width="1456" height="971" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a6880dd6-0c10-4a61-a40f-144219ab57e1_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;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!TYgA!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6880dd6-0c10-4a61-a40f-144219ab57e1_1536x1024.png 424w, https://substackcdn.com/image/fetch/$s_!TYgA!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6880dd6-0c10-4a61-a40f-144219ab57e1_1536x1024.png 848w, https://substackcdn.com/image/fetch/$s_!TYgA!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6880dd6-0c10-4a61-a40f-144219ab57e1_1536x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!TYgA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6880dd6-0c10-4a61-a40f-144219ab57e1_1536x1024.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Combine deterministic checks, agent verification and human judgment according to what you need to establish.</em></figcaption></figure></div><p>Once you&#8217;ve checked that the combined features work together, you might task your factory with building a phone-friendly interface so you can check invoices and record payments on the move.</p><p>The factory can also help run the invoicing workflow as well as improve its software. A scheduled agent could review overdue invoices, consult customer correspondence and prepare follow-ups for your approval. If that work repeatedly requires information the tracker doesn&#8217;t record, you can give the factory a task to add it. Building and operating feed into one another: agents use the software, and what happens in use informs its next improvement. This brings us to continual learning.</p><h2>4. Continual learning</h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!YwBc!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F29d3305d-f61e-4f83-971f-87c306064cb8_1672x941.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!YwBc!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F29d3305d-f61e-4f83-971f-87c306064cb8_1672x941.png 424w, https://substackcdn.com/image/fetch/$s_!YwBc!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F29d3305d-f61e-4f83-971f-87c306064cb8_1672x941.png 848w, https://substackcdn.com/image/fetch/$s_!YwBc!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F29d3305d-f61e-4f83-971f-87c306064cb8_1672x941.png 1272w, https://substackcdn.com/image/fetch/$s_!YwBc!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F29d3305d-f61e-4f83-971f-87c306064cb8_1672x941.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!YwBc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F29d3305d-f61e-4f83-971f-87c306064cb8_1672x941.png" width="1456" height="819" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/29d3305d-f61e-4f83-971f-87c306064cb8_1672x941.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:819,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!YwBc!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F29d3305d-f61e-4f83-971f-87c306064cb8_1672x941.png 424w, https://substackcdn.com/image/fetch/$s_!YwBc!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F29d3305d-f61e-4f83-971f-87c306064cb8_1672x941.png 848w, https://substackcdn.com/image/fetch/$s_!YwBc!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F29d3305d-f61e-4f83-971f-87c306064cb8_1672x941.png 1272w, https://substackcdn.com/image/fetch/$s_!YwBc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F29d3305d-f61e-4f83-971f-87c306064cb8_1672x941.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Use run evidence to test and adopt improvements to future work.</em></figcaption></figure></div><p>Your factory can also get better at how it works. Suppose payments disappear after restarting the invoice tracker, even though the agent reported that its checks passed. You&#8217;ll want it to fix the bug, of course. But why did its checks miss the problem?</p><p>Keep a record of assignments, checks and difficulties so a review agent can identify recurring problems and propose improvements. Did the worker lack a way to restart the app, or did it simply skip that check?</p><p>If it skipped the check, the agent could propose a skill that saves a payment, restarts the app and verifies the remaining balance whenever a change affects stored records. Test it against the original failure, then on further tasks. Does it catch problems with stored customer details too? Does it avoid unnecessary checks when a task only changes a heading?</p><p>The results help you decide whether to adopt, revise or reject the method. Apply changes within the authority you&#8217;ve agreed and keep them reversible. <a href="https://docs.warp.dev/factories/measure-and-improve/self-improvement/">Warp&#8217;s self-improving factories</a> illustrate this approach: failed checks can lead to proposed changes to prompts, skills or configuration, submitted for human review with evidence from the runs behind them.</p><p>Reassess methods as the project and model change. <a href="https://www.anthropic.com/engineering/harness-design-long-running-apps">Anthropic&#8217;s work on long-running application development</a> describes removing procedures as model capabilities improved and checking the effect.</p><p>A saved lesson needs to reach later workers and improve their results. This learning happens through changes to the instructions, tools and methods around the model, without requiring the model itself to be retrained.</p><h2>What would you build?</h2><p>Your factory could build a research tool that collects sources and lets you assemble briefings, a family intranet for shared plans and documents, or a private community space. Start with something useful to you, then give the factory further work as you discover what&#8217;s missing. Agents can also help operate what you build, from preparing a research briefing to organising incoming material.</p><p>Hugo uses this combination to run Vanishing Gradients, his media and education business. After a guest prep call, an automation retrieves the transcript and prepares interview topics, questions, titles and thumbnail options for review. After a livestream, agents can propose clips, cut video, add captions and prepare upload drafts. Saved editorial guidance and skills shape the work; Hugo chooses what to publish.</p><p>He also maintains the system, improving checks when agents miss instructions and updating skills based on results. More autonomous continual learning remains something he&#8217;s exploring. He describes the setup in <a href="https://maven.com/p/5ee8b7">How I Built a Media Empire With an Agentic Software Factory</a>.</p><p><em><strong>What&#8217;s one simple task you do repeatedly for your community, audience or business that you could start automating?</strong></em></p><h2>Decide what your factory needs next</h2><p>Look at what keeps bringing you back to the work. If the agent cannot run the app or inspect a failure, improve the harness. If you keep repeating project context and decisions, personalise it. If development waits for you to start each task or manage every handover, add automation. If the same failures recur across runs, build a learning loop that changes how later work is done.</p><p>Start with work you care about and inspect what comes back. One agent can use all four layers. Add capabilities where they help you delegate more useful work, while keeping specification and verification part of the process throughout.</p><h3>Build your own software factory</h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!tCox!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbd6e57f-3a69-44ff-8b19-f892af249c35_1730x905.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!tCox!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbd6e57f-3a69-44ff-8b19-f892af249c35_1730x905.png 424w, https://substackcdn.com/image/fetch/$s_!tCox!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbd6e57f-3a69-44ff-8b19-f892af249c35_1730x905.png 848w, https://substackcdn.com/image/fetch/$s_!tCox!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbd6e57f-3a69-44ff-8b19-f892af249c35_1730x905.png 1272w, https://substackcdn.com/image/fetch/$s_!tCox!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbd6e57f-3a69-44ff-8b19-f892af249c35_1730x905.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!tCox!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbd6e57f-3a69-44ff-8b19-f892af249c35_1730x905.png" width="1456" height="762" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/bbd6e57f-3a69-44ff-8b19-f892af249c35_1730x905.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:762,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!tCox!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbd6e57f-3a69-44ff-8b19-f892af249c35_1730x905.png 424w, https://substackcdn.com/image/fetch/$s_!tCox!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbd6e57f-3a69-44ff-8b19-f892af249c35_1730x905.png 848w, https://substackcdn.com/image/fetch/$s_!tCox!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbd6e57f-3a69-44ff-8b19-f892af249c35_1730x905.png 1272w, https://substackcdn.com/image/fetch/$s_!tCox!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbd6e57f-3a69-44ff-8b19-f892af249c35_1730x905.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>Ready to put these ideas to work? Hugo and Eleanor teach <strong><a href="https://vanishinggradients.short.gy/friends-of-paul">Build Your Agentic Software Factory</a></strong>, a two-week course where you&#8217;ll build a factory around something you want to create.</p><p>You&#8217;ll put the practices in this essay to use: give agents direction, set them working in the background, and learn to inspect and verify what comes back. <strong>You&#8217;ll leave with software of your own and a process you can keep using to build for yourself, your team or your business.</strong></p><p>Bring an idea you&#8217;re excited about, or choose a provided starter project. <strong>No coding experience is required.</strong> The course runs <strong>October 13&#8211;22, 2026</strong>, with two live workshops, office hours for help with your setup and project, and a community of fellow builders.</p><p><strong>Every student also gets $500 in Modal credits</strong> to run agent jobs in the cloud, experiment with open-weight models, or host something they&#8217;ve built. Your factory can keep working while your laptop is off.</p><p>Hugo and Eleanor are kindly offering my community <strong>25% off</strong>, bringing the price from <strong>$950 to $712.50 USD</strong>. The link below applies the discount automatically, or you can enter <strong>FRIENDSOFPAUL</strong> at checkout.</p><p><strong><a href="https://vanishinggradients.short.gy/friends-of-paul">Join Hugo and Eleanor and build your factory.</a></strong></p><div><hr></div><p><em>Enjoyed the article? The most sincere compliment is to restack this for your readers.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://www.decodingai.com/p/the-agentic-software-factory-hierarchy?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;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://www.decodingai.com/p/the-agentic-software-factory-hierarchy?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p><div><hr></div><h2>Images &amp; videos</h2><p>If not otherwise stated, all images and videos are created by the author.</p>]]></content:encoded></item><item><title><![CDATA[Stop Guessing. Evaluate Your RAG App.]]></title><description><![CDATA[From vibe checks to a 61-case score you ship on, in 5 steps]]></description><link>https://www.decodingai.com/p/rag-evals-change-prompts</link><guid isPermaLink="false">https://www.decodingai.com/p/rag-evals-change-prompts</guid><dc:creator><![CDATA[Paul Iusztin]]></dc:creator><pubDate>Tue, 06 Oct 2026 05:00:52 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!B6x4!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbfa11215-7f38-44ea-8bfa-a3f02f4c9d88_1376x768.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_!B6x4!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbfa11215-7f38-44ea-8bfa-a3f02f4c9d88_1376x768.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!B6x4!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbfa11215-7f38-44ea-8bfa-a3f02f4c9d88_1376x768.png 424w, https://substackcdn.com/image/fetch/$s_!B6x4!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbfa11215-7f38-44ea-8bfa-a3f02f4c9d88_1376x768.png 848w, https://substackcdn.com/image/fetch/$s_!B6x4!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbfa11215-7f38-44ea-8bfa-a3f02f4c9d88_1376x768.png 1272w, https://substackcdn.com/image/fetch/$s_!B6x4!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbfa11215-7f38-44ea-8bfa-a3f02f4c9d88_1376x768.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!B6x4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbfa11215-7f38-44ea-8bfa-a3f02f4c9d88_1376x768.png" width="1376" height="768" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/bfa11215-7f38-44ea-8bfa-a3f02f4c9d88_1376x768.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:768,&quot;width&quot;:1376,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Nothing leaves the line until it passes the test.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Nothing leaves the line until it passes the test." title="Nothing leaves the line until it passes the test." srcset="https://substackcdn.com/image/fetch/$s_!B6x4!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbfa11215-7f38-44ea-8bfa-a3f02f4c9d88_1376x768.png 424w, https://substackcdn.com/image/fetch/$s_!B6x4!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbfa11215-7f38-44ea-8bfa-a3f02f4c9d88_1376x768.png 848w, https://substackcdn.com/image/fetch/$s_!B6x4!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbfa11215-7f38-44ea-8bfa-a3f02f4c9d88_1376x768.png 1272w, https://substackcdn.com/image/fetch/$s_!B6x4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbfa11215-7f38-44ea-8bfa-a3f02f4c9d88_1376x768.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><em><span data-color="#c02f26" style="color: rgb(192, 47, 38);">&#8220;When I change it, what if something else breaks?&#8221;</span></em>  That&#8217;s what Alexey Grigorev told me about the long system prompt behind his RAG app. If you&#8217;ve ever hesitated before editing a prompt that works, you know the feeling.</p><div class="callout-block" data-callout="true"><p>&#128227;<em> This article is based on an interview with the legend </em><span class="mention-wrap" data-attrs="{&quot;name&quot;:&quot;Alexey Grigorev&quot;,&quot;id&quot;:2259961,&quot;type&quot;:&quot;user&quot;,&quot;url&quot;:null,&quot;photo_url&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/54a0ec21-251b-49e2-aba6-93c13f3cd8cb_800x800.jpeg&quot;,&quot;uuid&quot;:&quot;b2ef2380-807f-4a7a-b588-bd15ee767cd5&quot;}" data-component-name="MentionToDOM"></span><em>. He spent 15 years as a software and AI engineer and founded DataTalks.Club, one of the world&#8217;s largest data communities. There&#8217;s a good chance you know him from there.</em></p></div><p>Here is the thing&#8230; His first AI app version shipped and works fine. Then corrections pile up, and every fix grows the prompt into a huge monolith that rigidly handles each use case. Alexey wanted to clean it up, since it clearly adds a lot of noise, but without a way to measure the impact of trimming parts of it, he was too afraid to do it.</p><p>That&#8217;s why he had to add evals to his RAG app. Otherwise, you find out something broke only when a user tells you. As Alexey puts it: <em>&#8220;without evals you are blind.&#8221;</em></p><p><em>But now we have another problem...</em></p><p>When you finally want evals, you discover you never recorded the interactions you&#8217;d need. Most people don&#8217;t add observability like <a href="https://www.comet.com/site/?utm_source=newsletter&amp;utm_medium=partner&amp;utm_campaign=paul">Opik</a> on day zero, so <em>&#8220;build a gold dataset first&#8221;</em> becomes a dream that never happens.</p><p>We will walk you through Alexey&#8217;s end-to-end eval workflow for his RAG app, built from proxy data when he had no traces. His RAG app is a FAQ chatbot integrated into his Slack DataTalks.Club community, which runs <a href="https://aishippingblog.com/p/rebuilding-a-faq-system-for-datatalksclub">free courses (the Zoomcamps) for 100k+ learners</a>. A perfect scenario for real-world RAG evals.</p><p>First, we will quickly look at the RAG app we will work with. Then we will focus entirely on <strong>the 5 steps you need to evaluate</strong> it: collect the data, build the eval set, build the evaluators, run them, and close the loop.</p><h2>The RAG app: a FAQ system built on GitHub issues</h2><p>DataTalks.Club courses are free, so thousands of people ask questions in their Slack. Some are unique, but <em>&#8220;this is not the case for 99% of the questions.&#8221;</em> At the top of the list is <em>&#8220;I just discovered the course, can I still join?&#8221;</em></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!j9oS!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ef2d75a-1efa-466b-a111-01fa50ae1098_2004x1084.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!j9oS!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ef2d75a-1efa-466b-a111-01fa50ae1098_2004x1084.png 424w, https://substackcdn.com/image/fetch/$s_!j9oS!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ef2d75a-1efa-466b-a111-01fa50ae1098_2004x1084.png 848w, https://substackcdn.com/image/fetch/$s_!j9oS!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ef2d75a-1efa-466b-a111-01fa50ae1098_2004x1084.png 1272w, https://substackcdn.com/image/fetch/$s_!j9oS!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ef2d75a-1efa-466b-a111-01fa50ae1098_2004x1084.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!j9oS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ef2d75a-1efa-466b-a111-01fa50ae1098_2004x1084.png" width="1456" height="788" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7ef2d75a-1efa-466b-a111-01fa50ae1098_2004x1084.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:788,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Repeat questions in the LLM Zoomcamp Slack, the problem the FAQ system exists to absorb.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Repeat questions in the LLM Zoomcamp Slack, the problem the FAQ system exists to absorb." title="Repeat questions in the LLM Zoomcamp Slack, the problem the FAQ system exists to absorb." srcset="https://substackcdn.com/image/fetch/$s_!j9oS!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ef2d75a-1efa-466b-a111-01fa50ae1098_2004x1084.png 424w, https://substackcdn.com/image/fetch/$s_!j9oS!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ef2d75a-1efa-466b-a111-01fa50ae1098_2004x1084.png 848w, https://substackcdn.com/image/fetch/$s_!j9oS!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ef2d75a-1efa-466b-a111-01fa50ae1098_2004x1084.png 1272w, https://substackcdn.com/image/fetch/$s_!j9oS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ef2d75a-1efa-466b-a111-01fa50ae1098_2004x1084.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Repeat questions in the LLM Zoomcamp Slack, the problem the FAQ system exists to absorb. <a href="https://aishippingblog.com/p/rebuilding-a-faq-system-for-datatalksclub">Source</a></em></figcaption></figure></div><p>From an AI engineering perspective, their FAQ system is a RAG app that indexes all student questions into a light on-disk index that can be queried from Slack via the <code>:faq:</code> tag. A student asks a question; Alexey marks it with the tag; then a webhook triggers an AWS Lambda function that retrieves the top-k FAQs from the questions index, passes them to an LLM that compiles the answer, and posts the answer back in Slack.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!-iR-!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac0e918b-8a39-401c-923e-9aa608096bfa_1080x1498.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!-iR-!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac0e918b-8a39-401c-923e-9aa608096bfa_1080x1498.jpeg 424w, https://substackcdn.com/image/fetch/$s_!-iR-!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac0e918b-8a39-401c-923e-9aa608096bfa_1080x1498.jpeg 848w, https://substackcdn.com/image/fetch/$s_!-iR-!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac0e918b-8a39-401c-923e-9aa608096bfa_1080x1498.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!-iR-!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac0e918b-8a39-401c-923e-9aa608096bfa_1080x1498.jpeg 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!-iR-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac0e918b-8a39-401c-923e-9aa608096bfa_1080x1498.jpeg" width="1080" height="1498" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ac0e918b-8a39-401c-923e-9aa608096bfa_1080x1498.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1498,&quot;width&quot;:1080,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!-iR-!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac0e918b-8a39-401c-923e-9aa608096bfa_1080x1498.jpeg 424w, https://substackcdn.com/image/fetch/$s_!-iR-!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac0e918b-8a39-401c-923e-9aa608096bfa_1080x1498.jpeg 848w, https://substackcdn.com/image/fetch/$s_!-iR-!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac0e918b-8a39-401c-923e-9aa608096bfa_1080x1498.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!-iR-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac0e918b-8a39-401c-923e-9aa608096bfa_1080x1498.jpeg 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><a href="https://aishippingblog.com/p/rebuilding-a-faq-system-for-datatalksclub">Source</a> </figcaption></figure></div><blockquote><p>The system is available in the DataTalksClub <a href="https://github.com/DataTalksClub/faq">GitHub repository</a>, along with the FAQ dataset, where we have one Markdown file per question.</p></blockquote><p>During ingestion, a &#8220;FAQ proposal&#8221; issue triggers a GitHub Action that retrieves similar questions with <strong>minsearch</strong>, Alexey&#8217;s lightweight text-search library. It then <a href="https://aishippingblog.com/p/rebuilding-a-faq-system-for-datatalksclub">asks an LLM with structured output for one decision</a>: <code>NEW</code>, <code>UPDATE</code>, <code>DUPLICATE</code>, or <code>WRONG_COURSE</code>. <code>NEW</code> and <code>UPDATE</code> open a pull request Alexey reviews, while <code>DUPLICATE</code> and <code>WRONG_COURSE</code> close the issue. When looking for similar questions, it searches using both the question and the full record, merging all records via Reciprocal Rank Fusion (RRF).</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!jQ9k!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc88ed173-e6f8-4653-9df0-425c374db2fe_1200x515.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!jQ9k!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc88ed173-e6f8-4653-9df0-425c374db2fe_1200x515.png 424w, https://substackcdn.com/image/fetch/$s_!jQ9k!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc88ed173-e6f8-4653-9df0-425c374db2fe_1200x515.png 848w, https://substackcdn.com/image/fetch/$s_!jQ9k!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc88ed173-e6f8-4653-9df0-425c374db2fe_1200x515.png 1272w, https://substackcdn.com/image/fetch/$s_!jQ9k!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc88ed173-e6f8-4653-9df0-425c374db2fe_1200x515.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!jQ9k!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc88ed173-e6f8-4653-9df0-425c374db2fe_1200x515.png" width="1200" height="515" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c88ed173-e6f8-4653-9df0-425c374db2fe_1200x515.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:515,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;How the FAQ automation classifies a contributed question: two searches fused with RRF, one LLM decision, and only two of the four outcomes ever reach a human.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="How the FAQ automation classifies a contributed question: two searches fused with RRF, one LLM decision, and only two of the four outcomes ever reach a human." title="How the FAQ automation classifies a contributed question: two searches fused with RRF, one LLM decision, and only two of the four outcomes ever reach a human." srcset="https://substackcdn.com/image/fetch/$s_!jQ9k!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc88ed173-e6f8-4653-9df0-425c374db2fe_1200x515.png 424w, https://substackcdn.com/image/fetch/$s_!jQ9k!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc88ed173-e6f8-4653-9df0-425c374db2fe_1200x515.png 848w, https://substackcdn.com/image/fetch/$s_!jQ9k!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc88ed173-e6f8-4653-9df0-425c374db2fe_1200x515.png 1272w, https://substackcdn.com/image/fetch/$s_!jQ9k!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc88ed173-e6f8-4653-9df0-425c374db2fe_1200x515.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>How the FAQ automation classifies a contributed question: 2 searches fused with RRF, one LLM decision, and only 2 of the 4 outcomes ever reach a human.</em></figcaption></figure></div><p>We are not here to see how this RAG app works (if interested, full breakdown <a href="https://aishippingblog.com/p/rebuilding-a-faq-system-for-datatalksclub">here</a>), but to see how we can evaluate it, starting with the most important part: building the AI evals dataset.</p><h2>Step 1: Collect the data, even if you never traced it</h2><p>Alexey is &#8220;totally for vibe checks&#8221; early on. But from the very beginning, while you&#8217;re still vibe coding, ask your AI assistant to record every interaction, and your future eval set collects itself.</p><p>Alexey didn&#8217;t: <em>&#8220;My goal was to just get this out and test how it works.&#8221;</em> It worked. Then corrections piled up, but the system prompt got too big and noisy, and he was too afraid to touch it for fear of breaking something.</p><p>Today it&#8217;s stored in Opik&#8217;s prompt library:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!CAZN!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F996bb65e-e3b3-4d7a-a5b5-2c9ba06daa3c_3114x1620.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!CAZN!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F996bb65e-e3b3-4d7a-a5b5-2c9ba06daa3c_3114x1620.png 424w, https://substackcdn.com/image/fetch/$s_!CAZN!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F996bb65e-e3b3-4d7a-a5b5-2c9ba06daa3c_3114x1620.png 848w, https://substackcdn.com/image/fetch/$s_!CAZN!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F996bb65e-e3b3-4d7a-a5b5-2c9ba06daa3c_3114x1620.png 1272w, https://substackcdn.com/image/fetch/$s_!CAZN!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F996bb65e-e3b3-4d7a-a5b5-2c9ba06daa3c_3114x1620.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!CAZN!,w_2400,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F996bb65e-e3b3-4d7a-a5b5-2c9ba06daa3c_3114x1620.png" width="1200" height="623.9010989010989" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/996bb65e-e3b3-4d7a-a5b5-2c9ba06daa3c_3114x1620.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:&quot;large&quot;,&quot;height&quot;:757,&quot;width&quot;:1456,&quot;resizeWidth&quot;:1200,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;The FAQ curation prompt in Opik's prompt library.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:&quot;center&quot;,&quot;offset&quot;:false}" class="sizing-large" alt="The FAQ curation prompt in Opik's prompt library." title="The FAQ curation prompt in Opik's prompt library." srcset="https://substackcdn.com/image/fetch/$s_!CAZN!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F996bb65e-e3b3-4d7a-a5b5-2c9ba06daa3c_3114x1620.png 424w, https://substackcdn.com/image/fetch/$s_!CAZN!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F996bb65e-e3b3-4d7a-a5b5-2c9ba06daa3c_3114x1620.png 848w, https://substackcdn.com/image/fetch/$s_!CAZN!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F996bb65e-e3b3-4d7a-a5b5-2c9ba06daa3c_3114x1620.png 1272w, https://substackcdn.com/image/fetch/$s_!CAZN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F996bb65e-e3b3-4d7a-a5b5-2c9ba06daa3c_3114x1620.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>&#128680; <strong>His core problem was that he had no traces to build the evals dataset from!</strong></p><p>So he used proxy data. Every FAQ contribution was a GitHub issue, and every correction was a commit on a PR. Issues give the inputs, and his corrections tell him what the output should have been. This meant he had access to the input, generated output, and expected output triplets he needed for evals.</p><p>How about reading the data yourself or being lazy (or optimal!) and using an LLM to do so? Alexey does &#8220;Both.&#8221; He lets PRs pile up for a few weeks, then clears them in one session with his AI coding assistant and a custom <code>clear-backlog</code><a href="https://github.com/DataTalksClub/faq/blob/main/.agents/skills/clear-backlog/SKILL.md"> skill</a>. The assistant proposes &#8220;merge,&#8221; &#8220;fix this first,&#8221; or &#8220;this case is interesting, let&#8217;s add it to our evals.&#8221; His job: &#8220;I just need to agree or disagree.&#8221;</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!j7QK!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d5ac881-42e2-475b-b294-3f5bc05c0a27_1946x594.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!j7QK!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d5ac881-42e2-475b-b294-3f5bc05c0a27_1946x594.png 424w, https://substackcdn.com/image/fetch/$s_!j7QK!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d5ac881-42e2-475b-b294-3f5bc05c0a27_1946x594.png 848w, https://substackcdn.com/image/fetch/$s_!j7QK!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d5ac881-42e2-475b-b294-3f5bc05c0a27_1946x594.png 1272w, https://substackcdn.com/image/fetch/$s_!j7QK!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d5ac881-42e2-475b-b294-3f5bc05c0a27_1946x594.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!j7QK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d5ac881-42e2-475b-b294-3f5bc05c0a27_1946x594.png" width="1456" height="444" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6d5ac881-42e2-475b-b294-3f5bc05c0a27_1946x594.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:444,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Clearing the PR backlog in one session: \&quot;let's go through the backlog\&quot; loads the clear-backlog skill.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Clearing the PR backlog in one session: &quot;let's go through the backlog&quot; loads the clear-backlog skill." title="Clearing the PR backlog in one session: &quot;let's go through the backlog&quot; loads the clear-backlog skill." srcset="https://substackcdn.com/image/fetch/$s_!j7QK!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d5ac881-42e2-475b-b294-3f5bc05c0a27_1946x594.png 424w, https://substackcdn.com/image/fetch/$s_!j7QK!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d5ac881-42e2-475b-b294-3f5bc05c0a27_1946x594.png 848w, https://substackcdn.com/image/fetch/$s_!j7QK!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d5ac881-42e2-475b-b294-3f5bc05c0a27_1946x594.png 1272w, https://substackcdn.com/image/fetch/$s_!j7QK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d5ac881-42e2-475b-b294-3f5bc05c0a27_1946x594.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption">Clearing the PR backlog in one session: &#8220;let&#8217;s go through the backlog&#8221; loads the <code>clear-backlog</code> skill. <a href="https://aishippingblog.com/p/rebuilding-a-faq-system-for-datatalksclub">Source</a></figcaption></figure></div><p>Using the proxy data to fix his cold-start problem was only a temporary solution. Today, both the curation automation and the Slack assistant send traces to Opik: inputs, retrieved documents, outputs.</p><p>Here is how the Slack assistant traces look in <a href="https://www.comet.com/site/?utm_source=newsletter&amp;utm_medium=partner&amp;utm_campaign=paul">Opik</a>:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!HjKA!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ce287a1-8ab1-4026-8173-0de4ed4d8a47_3110x1638.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!HjKA!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ce287a1-8ab1-4026-8173-0de4ed4d8a47_3110x1638.png 424w, https://substackcdn.com/image/fetch/$s_!HjKA!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ce287a1-8ab1-4026-8173-0de4ed4d8a47_3110x1638.png 848w, https://substackcdn.com/image/fetch/$s_!HjKA!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ce287a1-8ab1-4026-8173-0de4ed4d8a47_3110x1638.png 1272w, https://substackcdn.com/image/fetch/$s_!HjKA!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ce287a1-8ab1-4026-8173-0de4ed4d8a47_3110x1638.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!HjKA!,w_2400,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ce287a1-8ab1-4026-8173-0de4ed4d8a47_3110x1638.png" width="1200" height="632.1428571428571" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6ce287a1-8ab1-4026-8173-0de4ed4d8a47_3110x1638.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:&quot;large&quot;,&quot;height&quot;:767,&quot;width&quot;:1456,&quot;resizeWidth&quot;:1200,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Slack assistant traces in Opik.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:&quot;center&quot;,&quot;offset&quot;:false}" class="sizing-large" alt="Slack assistant traces in Opik." title="Slack assistant traces in Opik." srcset="https://substackcdn.com/image/fetch/$s_!HjKA!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ce287a1-8ab1-4026-8173-0de4ed4d8a47_3110x1638.png 424w, https://substackcdn.com/image/fetch/$s_!HjKA!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ce287a1-8ab1-4026-8173-0de4ed4d8a47_3110x1638.png 848w, https://substackcdn.com/image/fetch/$s_!HjKA!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ce287a1-8ab1-4026-8173-0de4ed4d8a47_3110x1638.png 1272w, https://substackcdn.com/image/fetch/$s_!HjKA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ce287a1-8ab1-4026-8173-0de4ed4d8a47_3110x1638.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>We have similar traces for the FAQ curation ingestion automation, but in a different Opik project. It works for both queries and ingestion.</p><p><strong>For your RAG app</strong>, look for any place a human already judged your output (edited PRs, support tickets, corrected answers, thumbs-down). Then trace everything from now on, so you won&#8217;t need proxies again.</p><h2>Step 2: Build the eval set</h2><p>When building your dataset, the hardest part is labeling it with pass/fail scores, plus a critique. In Alexey&#8217;s scenario, every past decision told him what the right answer was, in 2 main ways:</p><ul><li><p>A PR he accepted unchanged is a &#8220;pass&#8221; sample.</p></li><li><p>A PR where he had to alter it in any way becomes a &#8220;fail&#8221;, adding a one-sentence critique about why the review wasn&#8217;t accepted.</p></li></ul><p>A false <code>DUPLICATE</code> (or <code>WRONG_COURSE</code>) is the dangerous error. The issue closes automatically, and no PR is opened, <em>&#8220;so I would never discover it.&#8221;</em></p><p>The second biggest issue is replicating the context your RAG app used when ingesting/retrieving an item.</p><p>In our FAQ app, a question that was new when the issue arrived is now merged. Replay it as-is and the system correctly says <code>DUPLICATE</code>, so the eval case fails for the wrong reason. As I said during the interview, you have to <em>&#8220;install your data,&#8221;</em> not just your dependencies.</p><p>His answer is <a href="https://aishippingblog.com/p/rebuilding-a-faq-system-for-datatalksclub">leave-one-out</a>, shown in the image below. With 200 records within the dataset, where record D came from the issue under test, he removes D, replays the issue against the other 199, and expects <code>NEW</code>.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!9KH8!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd9c03721-6e27-413b-9833-d854b27b06b7_1200x403.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!9KH8!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd9c03721-6e27-413b-9833-d854b27b06b7_1200x403.png 424w, https://substackcdn.com/image/fetch/$s_!9KH8!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd9c03721-6e27-413b-9833-d854b27b06b7_1200x403.png 848w, https://substackcdn.com/image/fetch/$s_!9KH8!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd9c03721-6e27-413b-9833-d854b27b06b7_1200x403.png 1272w, https://substackcdn.com/image/fetch/$s_!9KH8!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd9c03721-6e27-413b-9833-d854b27b06b7_1200x403.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!9KH8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd9c03721-6e27-413b-9833-d854b27b06b7_1200x403.png" width="1200" height="403" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d9c03721-6e27-413b-9833-d854b27b06b7_1200x403.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:403,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Leave-one-out: remove the record the issue created, then replay the issue against the rest.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Leave-one-out: remove the record the issue created, then replay the issue against the rest." title="Leave-one-out: remove the record the issue created, then replay the issue against the rest." srcset="https://substackcdn.com/image/fetch/$s_!9KH8!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd9c03721-6e27-413b-9833-d854b27b06b7_1200x403.png 424w, https://substackcdn.com/image/fetch/$s_!9KH8!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd9c03721-6e27-413b-9833-d854b27b06b7_1200x403.png 848w, https://substackcdn.com/image/fetch/$s_!9KH8!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd9c03721-6e27-413b-9833-d854b27b06b7_1200x403.png 1272w, https://substackcdn.com/image/fetch/$s_!9KH8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd9c03721-6e27-413b-9833-d854b27b06b7_1200x403.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Leave-one-out: remove the record the issue created, then replay the issue against the rest.</em></figcaption></figure></div><p>Each eval case is a few lines of Python code in Git: case ID, question, answer, expected action, and the ID of the doc to remove. The case ID is the GitHub issue number, so every case traces back to its issue or PR. <a href="https://github.com/DataTalksClub/faq/blob/main/faq_automation/evals/cases.py#L212">See all here</a>.</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">EvalCase(
    course="llm-zoomcamp",
    case_id=274,
    question="OpenRouter: Error code 402 when calling responses.create (max_output_tokens)",
    answer="""OpenRouter can return APIStatusError with code 402 when responses.create() 
is called without a max_output_tokens limit. Pass a lower limit: max_output_tokens=1024.""",
    expected_action="NEW",
    expected_section="module-1-homework",
    description="OpenRouter 402 error &#8212; valid NEW for module-1-homework",
    checks=[action_is("NEW"), section_is("module-1-homework")],
    tags=["correct-new"],
    relevant_doc_id="cfb07a27d5",
)</code></pre></div><p>Every run costs money, so he trimmed the eval dataset to a small core set: 61 cases, with 38 <code>NEW</code>, 10 <code>DUPLICATE</code>, 7 <code>WRONG_COURSE</code>, 4 not <code>WRONG_COURSE</code>, and 2 <code>UPDATE</code>.</p><p>All the cases are imported into Opik as a versioned dataset for running the experiments:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!U3FN!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F600ea3a3-08eb-4af1-8778-ff66ef2bfd40_3038x1306.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!U3FN!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F600ea3a3-08eb-4af1-8778-ff66ef2bfd40_3038x1306.png 424w, https://substackcdn.com/image/fetch/$s_!U3FN!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F600ea3a3-08eb-4af1-8778-ff66ef2bfd40_3038x1306.png 848w, https://substackcdn.com/image/fetch/$s_!U3FN!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F600ea3a3-08eb-4af1-8778-ff66ef2bfd40_3038x1306.png 1272w, https://substackcdn.com/image/fetch/$s_!U3FN!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F600ea3a3-08eb-4af1-8778-ff66ef2bfd40_3038x1306.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!U3FN!,w_2400,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F600ea3a3-08eb-4af1-8778-ff66ef2bfd40_3038x1306.png" width="1200" height="515.934065934066" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/600ea3a3-08eb-4af1-8778-ff66ef2bfd40_3038x1306.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:&quot;large&quot;,&quot;height&quot;:626,&quot;width&quot;:1456,&quot;resizeWidth&quot;:1200,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:&quot;center&quot;,&quot;offset&quot;:false}" class="sizing-large" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!U3FN!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F600ea3a3-08eb-4af1-8778-ff66ef2bfd40_3038x1306.png 424w, https://substackcdn.com/image/fetch/$s_!U3FN!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F600ea3a3-08eb-4af1-8778-ff66ef2bfd40_3038x1306.png 848w, https://substackcdn.com/image/fetch/$s_!U3FN!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F600ea3a3-08eb-4af1-8778-ff66ef2bfd40_3038x1306.png 1272w, https://substackcdn.com/image/fetch/$s_!U3FN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F600ea3a3-08eb-4af1-8778-ff66ef2bfd40_3038x1306.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><strong>For your RAG app</strong>, an eval set is inputs plus expected outcomes, weighted towards the errors that cost you most, and replayed against the knowledge base as it was when each input arrived.</p><h2>Step 3: Build the evaluators</h2><p>I asked Alexey, <em>&#8220;How did you decide what metrics actually to measure?&#8221;</em> His answer was per case type. Cases are grouped <em>&#8220;based on the outcome I want&#8221;:</em> correctly new, true duplicate, not a duplicate, wrong course. Each type <em>&#8220;has its stack and then different logic for checking.&#8221;</em> A &#8220;correct new&#8221; case checks both that the question is flagged as <code>NEW</code> by the LLM and that it is ingested in the right section.</p><p>His curation automation returns a structured decision, so the evaluators are deterministic: <strong>action match</strong> (right decision) and <strong>placement match</strong> (right section), plus the <strong>cost</strong> of each case. When he analyzed all his traces, the most common error turned out to be incorrect section placement. Instead of placing a record about projects in the &#8220;Project&#8221; section, it would place it in &#8220;General&#8221;.</p><p>One curation trace flagged as DUPLICATE with its structured decision, model, and cost:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Wc-K!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9534722-186c-4bee-bcf4-1dc5949fb2bb_2970x1976.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Wc-K!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9534722-186c-4bee-bcf4-1dc5949fb2bb_2970x1976.png 424w, https://substackcdn.com/image/fetch/$s_!Wc-K!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9534722-186c-4bee-bcf4-1dc5949fb2bb_2970x1976.png 848w, https://substackcdn.com/image/fetch/$s_!Wc-K!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9534722-186c-4bee-bcf4-1dc5949fb2bb_2970x1976.png 1272w, https://substackcdn.com/image/fetch/$s_!Wc-K!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9534722-186c-4bee-bcf4-1dc5949fb2bb_2970x1976.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!Wc-K!,w_2400,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9534722-186c-4bee-bcf4-1dc5949fb2bb_2970x1976.png" width="1200" height="798.6263736263736" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e9534722-186c-4bee-bcf4-1dc5949fb2bb_2970x1976.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:&quot;large&quot;,&quot;height&quot;:969,&quot;width&quot;:1456,&quot;resizeWidth&quot;:1200,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;One curation trace: structured decision, model, and cost.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:&quot;center&quot;,&quot;offset&quot;:false}" class="sizing-large" alt="One curation trace: structured decision, model, and cost." title="One curation trace: structured decision, model, and cost." srcset="https://substackcdn.com/image/fetch/$s_!Wc-K!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9534722-186c-4bee-bcf4-1dc5949fb2bb_2970x1976.png 424w, https://substackcdn.com/image/fetch/$s_!Wc-K!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9534722-186c-4bee-bcf4-1dc5949fb2bb_2970x1976.png 848w, https://substackcdn.com/image/fetch/$s_!Wc-K!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9534722-186c-4bee-bcf4-1dc5949fb2bb_2970x1976.png 1272w, https://substackcdn.com/image/fetch/$s_!Wc-K!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9534722-186c-4bee-bcf4-1dc5949fb2bb_2970x1976.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>These evaluators need no LLM, are cheap to run, and are never ambiguous. Retrieval is checked separately: for a given query, it verifies that it retrieves the expected chunks. A 25-case suite scored by recall@5 runs in about 2 seconds, while the 61-case generation suite takes about 2 minutes.</p><p>The Slack assistant&#8217;s answers have no single right string. There, you need an LLM judge aligned with your own labels. Label 10 to 15 examples as good or bad yourself, write the rules down, and iterate until the judge agrees with you, <a href="https://aishippingblog.com/p/how-to-do-evals-in-2026">as Alexey lays out in his evals guide</a>.</p><p><strong>For your RAG app</strong>, use code checks wherever the right answer is known (a decision, a label, a retrieved document), check retrieval separately from generation, and save LLM judges for free-text answers.</p><p>Next, I asked him how he decides whether an eval experiment passed.</p><h2>Step 4: Run the evaluators in your eval harness</h2><p>First, let&#8217;s see how the eval harness that runs the experiments works.</p><p>Alexey keeps the eval cases in Git as the source of truth, and uses Opik as the eval harness: he uploads that dataset version and attaches it to each experiment, so every result shows what it ran on.</p><p>His runner is plain code in Git that runs all cases, or just one, and logs each run to Opik as an experiment with per-case action match, placement match, and cost. He admits it&#8217;s &#8220;not very scientific&#8221; yet and wants to track runs historically in Opik.</p><p>Here is one eval run, as an Opik experiment, where we can see the aggregated and per-item scores:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!nOzk!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4c7343bd-b31a-431a-87c7-a3670747d550_3114x1488.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!nOzk!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4c7343bd-b31a-431a-87c7-a3670747d550_3114x1488.png 424w, https://substackcdn.com/image/fetch/$s_!nOzk!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4c7343bd-b31a-431a-87c7-a3670747d550_3114x1488.png 848w, https://substackcdn.com/image/fetch/$s_!nOzk!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4c7343bd-b31a-431a-87c7-a3670747d550_3114x1488.png 1272w, https://substackcdn.com/image/fetch/$s_!nOzk!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4c7343bd-b31a-431a-87c7-a3670747d550_3114x1488.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!nOzk!,w_2400,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4c7343bd-b31a-431a-87c7-a3670747d550_3114x1488.png" width="1200" height="573.6263736263736" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4c7343bd-b31a-431a-87c7-a3670747d550_3114x1488.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:&quot;large&quot;,&quot;height&quot;:696,&quot;width&quot;:1456,&quot;resizeWidth&quot;:1200,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;One eval run as an Opik experiment.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:&quot;center&quot;,&quot;offset&quot;:false}" class="sizing-large" alt="One eval run as an Opik experiment." title="One eval run as an Opik experiment." srcset="https://substackcdn.com/image/fetch/$s_!nOzk!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4c7343bd-b31a-431a-87c7-a3670747d550_3114x1488.png 424w, https://substackcdn.com/image/fetch/$s_!nOzk!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4c7343bd-b31a-431a-87c7-a3670747d550_3114x1488.png 848w, https://substackcdn.com/image/fetch/$s_!nOzk!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4c7343bd-b31a-431a-87c7-a3670747d550_3114x1488.png 1272w, https://substackcdn.com/image/fetch/$s_!nOzk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4c7343bd-b31a-431a-87c7-a3670747d550_3114x1488.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>&#8220;I never needed 100 percent,&#8221; Alexey says, because his AI assistant still reviews every PR. The number is a benchmark that must not go down. Today the generation eval set passes <a href="https://aishippingblog.com/p/rebuilding-a-faq-system-for-datatalksclub">42 of 61 cases</a> on GPT-5.4 nano. When new cases make it dip, he changes nothing else and takes it as the new baseline. Hard cases can sit in FAIL: he doesn&#8217;t want the system prompt to grow to handle every corner case, but he does want to know those cases exist.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!LzGh!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6f03428-6c23-4840-8725-014ee96e10ed_1832x779.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!LzGh!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6f03428-6c23-4840-8725-014ee96e10ed_1832x779.png 424w, https://substackcdn.com/image/fetch/$s_!LzGh!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6f03428-6c23-4840-8725-014ee96e10ed_1832x779.png 848w, https://substackcdn.com/image/fetch/$s_!LzGh!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6f03428-6c23-4840-8725-014ee96e10ed_1832x779.png 1272w, https://substackcdn.com/image/fetch/$s_!LzGh!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6f03428-6c23-4840-8725-014ee96e10ed_1832x779.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!LzGh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6f03428-6c23-4840-8725-014ee96e10ed_1832x779.png" width="1456" height="619" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d6f03428-6c23-4840-8725-014ee96e10ed_1832x779.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:619,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Alexey's two eval suites: retrieval (25 cases, recall@5) and generation (61 cases, 42 passing on GPT-5.4 nano).&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Alexey's two eval suites: retrieval (25 cases, recall@5) and generation (61 cases, 42 passing on GPT-5.4 nano)." title="Alexey's two eval suites: retrieval (25 cases, recall@5) and generation (61 cases, 42 passing on GPT-5.4 nano)." srcset="https://substackcdn.com/image/fetch/$s_!LzGh!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6f03428-6c23-4840-8725-014ee96e10ed_1832x779.png 424w, https://substackcdn.com/image/fetch/$s_!LzGh!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6f03428-6c23-4840-8725-014ee96e10ed_1832x779.png 848w, https://substackcdn.com/image/fetch/$s_!LzGh!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6f03428-6c23-4840-8725-014ee96e10ed_1832x779.png 1272w, https://substackcdn.com/image/fetch/$s_!LzGh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6f03428-6c23-4840-8725-014ee96e10ed_1832x779.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Alexey&#8217;s 2 eval suites: retrieval (25 cases, recall@5) and generation (61 cases, 42 passing on GPT-5.4 nano). <a href="https://aishippingblog.com/p/rebuilding-a-faq-system-for-datatalksclub">Source</a></em></figcaption></figure></div><p>He pays for this community project out of his own pocket and wants <em>&#8220;the cheapest possible way that is performant enough to be useful.&#8221;</em></p><p>With evals, he compared models: GPT-4o mini is <em>&#8220;very cheap but stupid&#8221;</em> for this decision, so he chose <strong>GPT-5.4 nano</strong>, the cheapest that still delivers good quality. He keeps $5 in his OpenAI account and forgets about it &#8220;for half a year or even more,&#8221; because &#8220;each query costs on average less than one cent,&#8221; as the metrics from Opik show.</p><p>When the automation misbehaves, he first captures the failure as an eval case. He runs the new prompt on that case until it passes, then on the whole set to check nothing else broke. <em>&#8220;It&#8217;s kind of test-driven development, but like eval-driven development.&#8221;</em></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!uSHt!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F197a0874-89d6-423f-942f-65008b2b2ace_1203x1197.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!uSHt!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F197a0874-89d6-423f-942f-65008b2b2ace_1203x1197.png 424w, https://substackcdn.com/image/fetch/$s_!uSHt!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F197a0874-89d6-423f-942f-65008b2b2ace_1203x1197.png 848w, https://substackcdn.com/image/fetch/$s_!uSHt!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F197a0874-89d6-423f-942f-65008b2b2ace_1203x1197.png 1272w, https://substackcdn.com/image/fetch/$s_!uSHt!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F197a0874-89d6-423f-942f-65008b2b2ace_1203x1197.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!uSHt!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F197a0874-89d6-423f-942f-65008b2b2ace_1203x1197.png" width="1203" height="1197" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/197a0874-89d6-423f-942f-65008b2b2ace_1203x1197.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1197,&quot;width&quot;:1203,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Eval-driven development: capture the failure first, fix it, then prove nothing else broke.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Eval-driven development: capture the failure first, fix it, then prove nothing else broke." title="Eval-driven development: capture the failure first, fix it, then prove nothing else broke." srcset="https://substackcdn.com/image/fetch/$s_!uSHt!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F197a0874-89d6-423f-942f-65008b2b2ace_1203x1197.png 424w, https://substackcdn.com/image/fetch/$s_!uSHt!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F197a0874-89d6-423f-942f-65008b2b2ace_1203x1197.png 848w, https://substackcdn.com/image/fetch/$s_!uSHt!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F197a0874-89d6-423f-942f-65008b2b2ace_1203x1197.png 1272w, https://substackcdn.com/image/fetch/$s_!uSHt!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F197a0874-89d6-423f-942f-65008b2b2ace_1203x1197.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Eval-driven development: capture the failure first, fix it, then prove nothing else broke.</em></figcaption></figure></div><p>By tracking each run as an Opik experiment, we can clearly see the difference in scores in the before, after, and verify runs tracked over time:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!CTDh!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71977474-bd58-4a71-b9ed-153d9df50694_3114x1282.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!CTDh!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71977474-bd58-4a71-b9ed-153d9df50694_3114x1282.png 424w, https://substackcdn.com/image/fetch/$s_!CTDh!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71977474-bd58-4a71-b9ed-153d9df50694_3114x1282.png 848w, https://substackcdn.com/image/fetch/$s_!CTDh!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71977474-bd58-4a71-b9ed-153d9df50694_3114x1282.png 1272w, https://substackcdn.com/image/fetch/$s_!CTDh!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71977474-bd58-4a71-b9ed-153d9df50694_3114x1282.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!CTDh!,w_2400,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71977474-bd58-4a71-b9ed-153d9df50694_3114x1282.png" width="1200" height="493.68131868131866" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/71977474-bd58-4a71-b9ed-153d9df50694_3114x1282.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:&quot;large&quot;,&quot;height&quot;:599,&quot;width&quot;:1456,&quot;resizeWidth&quot;:1200,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Before, after, and verify runs as Opik experiments.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:&quot;center&quot;,&quot;offset&quot;:false}" class="sizing-large" alt="Before, after, and verify runs as Opik experiments." title="Before, after, and verify runs as Opik experiments." srcset="https://substackcdn.com/image/fetch/$s_!CTDh!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71977474-bd58-4a71-b9ed-153d9df50694_3114x1282.png 424w, https://substackcdn.com/image/fetch/$s_!CTDh!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71977474-bd58-4a71-b9ed-153d9df50694_3114x1282.png 848w, https://substackcdn.com/image/fetch/$s_!CTDh!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71977474-bd58-4a71-b9ed-153d9df50694_3114x1282.png 1272w, https://substackcdn.com/image/fetch/$s_!CTDh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71977474-bd58-4a71-b9ed-153d9df50694_3114x1282.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><strong>For your RAG app</strong>, keep the cases in version control, run each experiment against a versioned dataset in your eval harness, always keep one baseline number as reference, and turn every failure into a case before you fix it.</p><h2>Step 5: Close the loop in Opik</h2><p>Mining Git history worked once, but &#8220;<em>it&#8217;s not the exercise I want to perform every time.&#8221;</em> Now, when he sees a bad Slack reply or someone corrects the bot, <a href="https://aishippingblog.com/p/rebuilding-a-faq-system-for-datatalksclub">that question becomes an eval case</a>. He uses his coding agent to pull the trace from Opik into his eval set.</p><p>Below is Alexey&#8217;s Slack assistant correction dataset:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!BjrT!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47caddec-4fe8-429b-8959-cd50ae74e05e_3120x1484.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!BjrT!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47caddec-4fe8-429b-8959-cd50ae74e05e_3120x1484.png 424w, https://substackcdn.com/image/fetch/$s_!BjrT!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47caddec-4fe8-429b-8959-cd50ae74e05e_3120x1484.png 848w, https://substackcdn.com/image/fetch/$s_!BjrT!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47caddec-4fe8-429b-8959-cd50ae74e05e_3120x1484.png 1272w, https://substackcdn.com/image/fetch/$s_!BjrT!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47caddec-4fe8-429b-8959-cd50ae74e05e_3120x1484.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!BjrT!,w_2400,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47caddec-4fe8-429b-8959-cd50ae74e05e_3120x1484.png" width="1200" height="571.1538461538462" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/47caddec-4fe8-429b-8959-cd50ae74e05e_3120x1484.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:&quot;large&quot;,&quot;height&quot;:693,&quot;width&quot;:1456,&quot;resizeWidth&quot;:1200,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Slack assistant corrections as an Opik eval dataset.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:&quot;center&quot;,&quot;offset&quot;:false}" class="sizing-large" alt="Slack assistant corrections as an Opik eval dataset." title="Slack assistant corrections as an Opik eval dataset." srcset="https://substackcdn.com/image/fetch/$s_!BjrT!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47caddec-4fe8-429b-8959-cd50ae74e05e_3120x1484.png 424w, https://substackcdn.com/image/fetch/$s_!BjrT!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47caddec-4fe8-429b-8959-cd50ae74e05e_3120x1484.png 848w, https://substackcdn.com/image/fetch/$s_!BjrT!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47caddec-4fe8-429b-8959-cd50ae74e05e_3120x1484.png 1272w, https://substackcdn.com/image/fetch/$s_!BjrT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47caddec-4fe8-429b-8959-cd50ae74e05e_3120x1484.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><em>&#8220;Because I have evals &#8230; I can see where it&#8217;s failing,&#8221;</em> and he usually fixes it by improving the FAQ, the docs, or the course repository, not with a fancier model. Then he re-runs the evals.</p><p>Alexey calls evals <strong>&#8220;basic hygiene&#8221;</strong> that you know is good for you, but you still skip it from time to time. Everyone knows you should go to bed at the same time, and sometimes you still go at 2 a.m. instead of 10 p.m.</p><p><strong>For your RAG app</strong>, route every user correction straight from your traces into the eval set instead of reconstructing it from history.</p><p>In my experience, integrating Opik takes about 5 minutes, and the free tier covers 25k spans a month, which, for this project, Alexey <em>&#8220;can use free forever&#8221;</em> (a serious production app might burn that in a day). He tried the <a href="https://github.com/comet-ml/opik">open-source version</a> first, but with his lean infra, self-hosting would have been more expensive.</p><p>Opik didn&#8217;t fit in 2 places. His evals remove records from the dataset per case, and he found no straightforward way to run that inside Opik, though <em>&#8220;maybe it&#8217;s just I should spend more time on understanding.&#8221;</em> And his zero-dependency Lambda couldn&#8217;t easily take Opik&#8217;s default Python client, so his AI assistant switched to plain <a href="https://www.comet.com/docs/opik/reference/rest-api/overview?utm_source=newsletter&amp;utm_medium=partner&amp;utm_campaign=paul">HTTP requests</a>, which <em>&#8220;was so simple at the end.&#8221;</em></p><h2>Final Thoughts</h2><blockquote><p><em>&#8220;I have so many applications with zero evals and a bunch of vibe-coded test cases I don&#8217;t even know test the right thing. Is that wrong?&#8221;</em><br>&#8212; Paul</p></blockquote><p>Alexey&#8217;s answer: there&#8217;s nothing wrong with it, as long as you know how to build an eval set when you need one. First figure out how the app should work and what the UX is. If you pour time into evals and then learn the UX is wrong, you throw the evals away with it.</p><blockquote><p><em>&#8220;Many engineers who don&#8217;t know the domain look blindly at the logs and can&#8217;t decide: is this good, is this bad, what am I looking at?&#8221;</em><br>&#8212; Paul</p></blockquote><p>His advice: sit down with the domain experts. Even when he was a data scientist, long before AI automation, the most useful thing he did in every job was learn from the people his models were built for, because their input decides what &#8220;good&#8221; means.</p><p>That&#8217;s why I think humans still sit in evals. A coding agent can build the app, but it won&#8217;t tell you what it costs to run, how slow it is, or whether it&#8217;s actually good. Start with Alexey&#8217;s <em><a href="https://aishippingblog.com/p/how-to-do-evals-in-2026">How to Do Evals in 2026</a>, </em>then Eugene Yan on <a href="https://eugeneyan.com/writing/aligneval/">aligning LLM evaluators</a> and Hamel Husain on <a href="https://hamel.dev/blog/posts/evals/">why AI products need evals</a>. </p><div class="callout-block" data-callout="true"><p>And if you&#8217;re starting a RAG app today, trace it on <strong><a href="https://www.comet.com/signup?utm_source=newsletter&amp;utm_medium=partner&amp;utm_campaign=paul">Opik&#8217;s free tier</a> (25k spans/month, enough for any MVP)</strong> to make your transition from your first vibe check to evals smoother.</p></div><p><em>But here is what I&#8217;m wondering:</em></p><blockquote><p><em><strong>How are you evaluating your RAG workflow or agent?</strong></em></p></blockquote><p><em>Click the button below and tell me. I read every response.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://www.decodingai.com/p/rag-evals-change-prompts/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://www.decodingai.com/p/rag-evals-change-prompts/comments"><span>Leave a comment</span></a></p><div><hr></div><p><em>Enjoyed the article? The most sincere compliment is to restack this for your readers.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://www.decodingai.com/p/rag-evals-change-prompts?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://www.decodingai.com/p/rag-evals-change-prompts?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p><div><hr></div><div class="callout-block" data-callout="true"><h4>Whenever you&#8217;re ready, here is how I can help you</h4><p><em>Go from agent user to agent builder.</em> Master the foundations of AI agents and turn fragile demo code into reliable, production-ready systems with my course, <strong><a href="https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering">Agent Engineering: Building Multi-Agent Systems</a></strong> (made with Towards AI).</p><p>35 lessons. Pure foundations from scratch. 4 mini-projects. 2 production systems. A certificate and direct access to me &amp; industry experts in our Discord.</p><p>Built for software and data professionals transitioning into AI engineering. <em>Rated 5/5 with 300+ students. The first 7 lessons are free:</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering&quot;,&quot;text&quot;:&quot;Start here&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering"><span>Start here</span></a></p><p><em>Not ready to commit?</em> Start with our <strong><a href="https://email-course.towardsai.net/?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering">free Agent AI Engineering Guide</a></strong>, a 6-day email course on the mistakes that silently break AI agents in production.</p></div><div><hr></div><p><em>Thanks again to <a href="https://www.comet.com/site/?utm_source=newsletter&amp;utm_medium=partner&amp;utm_campaign=paul">Opik</a> for sponsoring this case study and keeping it free!</em></p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!oSDm!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26c21863-4ee6-4026-91c7-74650eb16dac_3168x792.png 424w, https://substackcdn.com/image/fetch/$s_!oSDm!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26c21863-4ee6-4026-91c7-74650eb16dac_3168x792.png 848w, https://substackcdn.com/image/fetch/$s_!oSDm!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26c21863-4ee6-4026-91c7-74650eb16dac_3168x792.png 1272w, https://substackcdn.com/image/fetch/$s_!oSDm!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26c21863-4ee6-4026-91c7-74650eb16dac_3168x792.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!oSDm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26c21863-4ee6-4026-91c7-74650eb16dac_3168x792.png" width="1456" height="364" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/26c21863-4ee6-4026-91c7-74650eb16dac_3168x792.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:364,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Opik Banner&quot;,&quot;title&quot;:&quot;Opik Banner&quot;,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Opik Banner" title="Opik Banner" srcset="https://substackcdn.com/image/fetch/$s_!oSDm!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26c21863-4ee6-4026-91c7-74650eb16dac_3168x792.png 424w, https://substackcdn.com/image/fetch/$s_!oSDm!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26c21863-4ee6-4026-91c7-74650eb16dac_3168x792.png 848w, https://substackcdn.com/image/fetch/$s_!oSDm!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26c21863-4ee6-4026-91c7-74650eb16dac_3168x792.png 1272w, https://substackcdn.com/image/fetch/$s_!oSDm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26c21863-4ee6-4026-91c7-74650eb16dac_3168x792.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div><figcaption class="image-caption"><a href="https://www.comet.com/site/?utm_source=newsletter&amp;utm_medium=partner&amp;utm_campaign=paul">Try Opik for free here</a> (25k spans/month free)</figcaption></figure></div><p><strong>If you want to monitor, evaluate, and optimize your AI workflows and agents:</strong></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://www.comet.com/site/?utm_source=newsletter&amp;utm_medium=partner&amp;utm_campaign=paul&quot;,&quot;text&quot;:&quot;Try Opik for free&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://www.comet.com/site/?utm_source=newsletter&amp;utm_medium=partner&amp;utm_campaign=paul"><span>Try Opik for free</span></a></p><div><hr></div><h2>Images</h2><p>If not otherwise stated, all images are created by the author.</p>]]></content:encoded></item><item><title><![CDATA[Will Your Next Change Break Your Agent?]]></title><description><![CDATA[Error analysis and replays that reproduce agent bugs in their original context]]></description><link>https://www.decodingai.com/p/transform-agent-traces-into-regression-cases</link><guid isPermaLink="false">https://www.decodingai.com/p/transform-agent-traces-into-regression-cases</guid><dc:creator><![CDATA[Paul Iusztin]]></dc:creator><pubDate>Tue, 29 Sep 2026 05:02:19 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!IOyu!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc67f45e1-4702-4a10-903e-80e4aa1ba00e_1376x768.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="callout-block" data-callout="true"><p><em><strong><span data-color="#c02f26" style="color: rgb(192, 47, 38);">Every AI application that wraps an agent is a harness!</span></strong><span data-color="#c02f26" style="color: rgb(192, 47, 38);"> </span></em></p><p>In LangChain&#8217;s Terminal-Bench experiment, changing only the harness (with the same model) moved a coding agent from ~30th place into the top 5: the harness, not the model, is what makes a coding agent good.</p><p>In the&nbsp;<strong>open-source course</strong>&nbsp;<strong><a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course">Building a Coding Agent From Scratch</a></strong>, you&#8217;ll build that harness from scratch in Python:&nbsp;<strong>Decode</strong>, a complete coding agent that grows lesson by lesson from a bare agent loop into a swarm of remote agents running in parallel in the cloud.</p><p><strong>Why?</strong>&nbsp;You&#8217;ll be able to engineer custom harnesses for your own AI products (the skill behind that leaderboard jump), and you&#8217;ll understand what Claude Code and Codex actually do under the hood, turning you into a power user.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ge05!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ge05!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 424w, https://substackcdn.com/image/fetch/$s_!ge05!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 848w, https://substackcdn.com/image/fetch/$s_!ge05!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 1272w, https://substackcdn.com/image/fetch/$s_!ge05!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ge05!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif" width="1200" height="630" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:630,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1446989,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/gif&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://www.decodingai.com/i/207400663?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ge05!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 424w, https://substackcdn.com/image/fetch/$s_!ge05!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 848w, https://substackcdn.com/image/fetch/$s_!ge05!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 1272w, https://substackcdn.com/image/fetch/$s_!ge05!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><strong>Lessons:</strong></p><ol><li><p><a href="https://www.decodingai.com/p/building-a-coding-agent-from-scratch-system-design">Building a Coding Agent From Scratch</a></p></li><li><p><a href="https://www.decodingai.com/p/the-coding-agent-loop">The Bare-Bones Coding Agent Loop</a></p></li><li><p><a href="https://www.decodingai.com/p/run-coding-agents-safely">From a Raw Shell to a Sandboxed Coding Agent</a></p></li><li><p><a href="https://www.decodingai.com/p/context-engineering-for-coding-agents">Context Engineering for Coding Agents</a></p></li><li><p><a href="https://www.decodingai.com/p/subagents-are-context-engineering">Subagents Are Context Engineering</a></p></li><li><p><a href="https://www.decodingai.com/p/coding-agents-in-remote-headless">Swarm of Remote Agents</a></p></li><li><p><a href="https://www.decodingai.com/p/evaluate-ai-agents-benchmarks-regression-tests">Agent Evals 101</a></p></li><li><p><strong>Turn Your Agent&#8217;s Failures Into a Regression Suite</strong> <strong>&#8592; </strong><em><strong>you are here</strong></em></p></li></ol><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course&quot;,&quot;text&quot;:&quot;Full open-source course&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course"><span>Full open-source course</span></a></p><p><em>Special thanks to <strong><a href="https://modal.com/?source=decodingai&amp;campaign=harnesseng">Modal</a></strong>, <strong><a href="https://www.comet.com/site/?utm_source=workshop&amp;utm_medium=partner&amp;utm_campaign=paul&amp;utm_content=coding_agent_course">Opik (by Comet)</a></strong>, and <strong><a href="https://www.zenml.io/product/kitaru?utm_source=decodingai&amp;utm_medium=referral&amp;utm_campaign=coding-agent-course&amp;utm_content=brand">Kitaru (by ZenML)</a></strong> for sponsoring this open-source course and keeping it free!</em></p></div><h1>Lesson 8: Turn Your Agent&#8217;s Failures Into a Regression Suite</h1><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!J0HL!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd25c8015-5f2b-4ee6-acef-62f1f2b3290e_1376x768.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!J0HL!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd25c8015-5f2b-4ee6-acef-62f1f2b3290e_1376x768.png 424w, https://substackcdn.com/image/fetch/$s_!J0HL!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd25c8015-5f2b-4ee6-acef-62f1f2b3290e_1376x768.png 848w, https://substackcdn.com/image/fetch/$s_!J0HL!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd25c8015-5f2b-4ee6-acef-62f1f2b3290e_1376x768.png 1272w, https://substackcdn.com/image/fetch/$s_!J0HL!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd25c8015-5f2b-4ee6-acef-62f1f2b3290e_1376x768.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!J0HL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd25c8015-5f2b-4ee6-acef-62f1f2b3290e_1376x768.png" width="1376" height="768" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d25c8015-5f2b-4ee6-acef-62f1f2b3290e_1376x768.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:768,&quot;width&quot;:1376,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;The same recording, played again: listen for what changed.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="The same recording, played again: listen for what changed." title="The same recording, played again: listen for what changed." srcset="https://substackcdn.com/image/fetch/$s_!J0HL!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd25c8015-5f2b-4ee6-acef-62f1f2b3290e_1376x768.png 424w, https://substackcdn.com/image/fetch/$s_!J0HL!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd25c8015-5f2b-4ee6-acef-62f1f2b3290e_1376x768.png 848w, https://substackcdn.com/image/fetch/$s_!J0HL!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd25c8015-5f2b-4ee6-acef-62f1f2b3290e_1376x768.png 1272w, https://substackcdn.com/image/fetch/$s_!J0HL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd25c8015-5f2b-4ee6-acef-62f1f2b3290e_1376x768.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>Here I am, at 10 p.m., creating my implementation plan for my software factory. Tired, I vibe-planned more than usual, using Claude Code to implement Decode&#8217;s evals layer via my Modal serverless endpoint so I could access all the necessary LLMs. The endpoint returned a 503 before it finished warming up, and instead of stopping, the coding agent found a Gemini API key in memory and decided to use it to achieve its goal no matter what. The result: $40 <em>of</em> <em>tokens</em> <em>burned</em> <em>on</em> 20 <em>benchmark</em> <em>tests</em> <em>by</em> <em>the</em> <em>next</em> <em>morning</em>, <em>compared</em> <em>to </em>$4 to $5 on Modal. Ouch.</p><p>The fix was extremely simple, just 2 lines: wait for the warm-up and properly guard my credentials from the env vars. The hard part is guaranteeing that the same error never happens again after the next prompt, tool, or model change.</p><p>Without that guarantee, you&#8217;re afraid to change your prompts, because the chance of breaking what worked last week without noticing is too high. That slows development down, especially in larger teams where you have to touch other people&#8217;s code.</p><div class="callout-block" data-callout="true"><p>&#128161; The answer to all our problems is <strong>regression tests</strong> (the suite you re-run after every change to prove earlier behavior still holds), which are the most important part of AI evals for a custom AI app, more than benchmarks or online monitoring. They let you ship more features while being sure nothing else broke, just like the unit, integration, and regression tests of traditional software.</p></div><p>For an agent, the best way to organically grow your regression tests without spending too much time guessing them or money on testing useless errors is the <strong>error analysis</strong> framework.</p><p>To apply the error analysis framework to your production or synthetic traces, you need to build an eval harness that runs your agents in parallel in isolated containers, emulates the right context for each test, and collects the outputs from all your tests.</p><p>For that, there is a new family of tools in town, such as <strong><a href="https://www.zenml.io/product/kitaru?utm_source=decodingai&amp;utm_medium=referral&amp;utm_campaign=coding-agent-course&amp;utm_content=brand">Kitaru</a> by ZenML Labs</strong>, focused on capturing your agent runs and replaying them with the same context so you can easily reproduce bugs, fix your code, and grow and manage your regression tests.</p><p>First, you&#8217;ll get a strong intuition for how the error analysis framework works, then you&#8217;ll apply it to fix and build regression tests on top of Decode, the Claude Code clone we&#8217;ve built during this series. This article will make sense even if you haven&#8217;t read previous lessons. Still, reading Lesson 7 on <a href="https://www.decodingai.com/p/evaluate-ai-agents-benchmarks-regression-tests">Agent Evals 101</a> would definitely help you get the foundations of evals.</p><h2>Regression tests via the error analysis framework</h2><p>Every change to a coding agent mixes plain English (prompts, tool descriptions, skills) and code: tool implementations, harness components, <strong>the sandbox</strong> layer (the container its bash and file tools run in), and compaction. So implementing unit/integration tests as we know them won&#8217;t work for three reasons: it&#8217;s impossible to write unit tests for prompts, writing integration tests for too many scenarios is too costly, and you can&#8217;t assert unstructured data via code.</p><p>What works is the error analysis framework, popularized by Hamel Husain and Andrew Ng.</p><p><strong>Here is how error analysis works, step-by-step.</strong></p><p>You record real runs, read a sample by hand, and give each a pass/fail label with a short critique, never a 1-to-5 score, because a &#8220;fail&#8221; (instead of a &#8220;pass&#8221;) is actionable, while a &#8220;3&#8221; (instead of a &#8220;2&#8221; or &#8220;4&#8221;) is not. You fix the obvious right away, cluster the rest by failure type, rank by frequency &#215; severity, and run a <strong>root cause analysis</strong> (tracing one failing run back to the step that broke it) on each high-priority cluster. Then you write one cheap evaluator per cluster and re-run it after every change.</p><p>Hamel Husain calls it <a href="https://hamel.dev/blog/posts/evals-faq/">&#8220;the most important activity in evals&#8221;</a> because it decides which evals to write at all, and Anthropic&#8217;s field guide sets the entry bar low: <a href="https://www.anthropic.com/engineering/demystifying-evals-for-ai-agents">&#8220;20-50 simple tasks drawn from real failures is a great start&#8221;</a>.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!QBWK!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16769af1-b345-43ae-939e-51df00663ada_1178x1140.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!QBWK!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16769af1-b345-43ae-939e-51df00663ada_1178x1140.png 424w, https://substackcdn.com/image/fetch/$s_!QBWK!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16769af1-b345-43ae-939e-51df00663ada_1178x1140.png 848w, https://substackcdn.com/image/fetch/$s_!QBWK!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16769af1-b345-43ae-939e-51df00663ada_1178x1140.png 1272w, https://substackcdn.com/image/fetch/$s_!QBWK!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16769af1-b345-43ae-939e-51df00663ada_1178x1140.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!QBWK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16769af1-b345-43ae-939e-51df00663ada_1178x1140.png" width="1178" height="1140" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/16769af1-b345-43ae-939e-51df00663ada_1178x1140.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1140,&quot;width&quot;:1178,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;The error analysis loop in Kitaru's vocabulary &#8212; sessions in, an investigation of verdicts, cohorts per failure class, one evaluator each, and an experiment that gates every later change&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="The error analysis loop in Kitaru's vocabulary &#8212; sessions in, an investigation of verdicts, cohorts per failure class, one evaluator each, and an experiment that gates every later change" title="The error analysis loop in Kitaru's vocabulary &#8212; sessions in, an investigation of verdicts, cohorts per failure class, one evaluator each, and an experiment that gates every later change" srcset="https://substackcdn.com/image/fetch/$s_!QBWK!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16769af1-b345-43ae-939e-51df00663ada_1178x1140.png 424w, https://substackcdn.com/image/fetch/$s_!QBWK!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16769af1-b345-43ae-939e-51df00663ada_1178x1140.png 848w, https://substackcdn.com/image/fetch/$s_!QBWK!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16769af1-b345-43ae-939e-51df00663ada_1178x1140.png 1272w, https://substackcdn.com/image/fetch/$s_!QBWK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16769af1-b345-43ae-939e-51df00663ada_1178x1140.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>The error analysis loop in Kitaru&#8217;s vocabulary: record sessions, label the sessions in an investigation, fix the obvious, cluster the rest into cohorts, write one evaluator per cohort, and replay the cohort as an experiment after every change to see if you actually fixed the bug.</em></figcaption></figure></div><p>Error analysis sounds powerful, but how do we do it in practice? How do we look at our data, cluster it and run evaluators?</p><p>That&#8217;s what we will show you in this lesson, using <strong><a href="https://www.zenml.io/product/kitaru?utm_source=decodingai&amp;utm_medium=referral&amp;utm_campaign=coding-agent-course&amp;utm_content=brand">Kitaru</a></strong>.</p><p>When evaluating Decode, you record isolated <code>decode run</code> executions (Decode&#8217;s headless command) as <strong>sessions</strong>, with every LLM and tool call included. One Kitaru session maps to one Decode session, similar to threads or a collection of traces from other tools. Or, in plain English, your end-to-end conversation with an agent is a session. <a href="https://docs.zenml.io/kitaru/core-concepts/agents-and-sessions?utm_source=decodingai&amp;utm_medium=referral&amp;utm_campaign=coding-agent-course&amp;utm_content=docs">More here</a>.</p><p>Ideally, you already have Kitaru plugged in while running your AI app in production. Otherwise, you can easily import all your data from observability tools like Opik, Braintrust, or Langfuse.</p><p>Next, you sample ~20-30 sessions into an investigation, label each session as pass/fail, and add a short critique message. For errors, the message should contain the first failure reason.</p><p>After that, because Kitaru connects to your coding agent through its MCP server and skills, the agent knows how to cluster the problematic ones by error type into <strong>cohorts</strong>. For each cohort, you will implement one <strong>evaluator</strong>, a few lines of Python that read a session and say pass or fail. You fix the code, then start an <strong>experiment</strong> that replays every session of the cohort with the fix in place.</p><p><strong>The power of Kitaru is in its replay mechanism.</strong> Why? When implementing the eval harness, one of the hardest parts is recreating the same context for each task you want to evaluate. Via replays, you inject that context automatically by caching the tool outputs of the session you want to replay. This means that if a tool gets the same input, it returns the same output. Tool calls with different arguments, or tools changed during your fix, run from scratch.</p><p>Now let&#8217;s plug Kitaru into Decode&#8217;s harness to record, review and replay its agent loop.</p><h2>Integrating Kitaru into the agent harness</h2><p>Sessions can get into Kitaru in three different ways:</p><ol><li><p>Kitaru is already plugged into your harness</p></li><li><p>You import sessions from an observability tool like <a href="https://www.comet.com/site/?utm_source=workshop&amp;utm_medium=partner&amp;utm_campaign=paul&amp;utm_content=coding_agent_course">Opik</a></p></li><li><p>You run experiments via Kitaru after fixing a bug or implementing a feature</p></li></ol><p>In all three methods, everything is ingested into Kitaru&#8217;s <strong>control plane</strong>. Your coding agent talks to that control plane to do the error analysis, and experiments replay sessions on <strong>workers</strong> that you host yourself.</p><p>From an architectural perspective, 4 components talk to each other:</p><ul><li><p><strong>Decode</strong> is the agent under test, available in <a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course">the series repo</a>.</p></li><li><p><strong>The Kitaru control plane</strong> stores sessions and tracks the error analysis: local <a href="https://github.com/zenml-io/kitaru">open-source</a> via Docker Compose, managed, or self-hosted.</p></li><li><p><strong>The Kitaru workers</strong> run Decode in isolated containers: via Docker when running locally, as <a href="https://modal.com?source=decodingai&amp;campaign=harnesseng.">Modal</a> serverless apps when deployed, or any other method you prefer. The idea is that everything runs on your infra, and Kitaru doesn&#8217;t manage it.</p></li><li><p><strong>Your coding agent</strong> (Claude Code, Pi, Codex) does the error analysis through the Kitaru MCP server (the repo&#8217;s <code>.mcp.json</code>), guided by 3 <a href="https://github.com/zenml-io/kitaru-skills">Kitaru skills</a>: <code>kitaru-investigation</code>, <code>kitaru-validate-evaluator</code>, <code>kitaru-replay-experiment</code>.</p></li></ul><p>A worker, when executing an experiment or a replay, pulls each job on your infra and spawns one isolated Decode per session.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!15Q3!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F761b7a0d-93c8-4c0c-99b7-fc104a8c2dbf_1200x786.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!15Q3!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F761b7a0d-93c8-4c0c-99b7-fc104a8c2dbf_1200x786.png 424w, https://substackcdn.com/image/fetch/$s_!15Q3!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F761b7a0d-93c8-4c0c-99b7-fc104a8c2dbf_1200x786.png 848w, https://substackcdn.com/image/fetch/$s_!15Q3!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F761b7a0d-93c8-4c0c-99b7-fc104a8c2dbf_1200x786.png 1272w, https://substackcdn.com/image/fetch/$s_!15Q3!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F761b7a0d-93c8-4c0c-99b7-fc104a8c2dbf_1200x786.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!15Q3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F761b7a0d-93c8-4c0c-99b7-fc104a8c2dbf_1200x786.png" width="1200" height="786" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/761b7a0d-93c8-4c0c-99b7-fc104a8c2dbf_1200x786.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:786,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Kitaru inside Decode's system &#8212; error analysis on the left feeds the control plane, Workers run the agent and send sessions back, your coding agent analyzes sessions through the skills and MCP server, and every cohort goes through one experiment on the right&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Kitaru inside Decode's system &#8212; error analysis on the left feeds the control plane, Workers run the agent and send sessions back, your coding agent analyzes sessions through the skills and MCP server, and every cohort goes through one experiment on the right" title="Kitaru inside Decode's system &#8212; error analysis on the left feeds the control plane, Workers run the agent and send sessions back, your coding agent analyzes sessions through the skills and MCP server, and every cohort goes through one experiment on the right" srcset="https://substackcdn.com/image/fetch/$s_!15Q3!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F761b7a0d-93c8-4c0c-99b7-fc104a8c2dbf_1200x786.png 424w, https://substackcdn.com/image/fetch/$s_!15Q3!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F761b7a0d-93c8-4c0c-99b7-fc104a8c2dbf_1200x786.png 848w, https://substackcdn.com/image/fetch/$s_!15Q3!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F761b7a0d-93c8-4c0c-99b7-fc104a8c2dbf_1200x786.png 1272w, https://substackcdn.com/image/fetch/$s_!15Q3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F761b7a0d-93c8-4c0c-99b7-fc104a8c2dbf_1200x786.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Kitaru inside Decode&#8217;s system: error analysis feeds the control plane; workers run the agent and send sessions back; your coding agent analyzes sessions through the Kitaru skills and MCP server; and every cohort is used to grow the eval dataset and evaluators.</em></figcaption></figure></div><p>In the code snippet below, we can see how Decode plugs into our Pydantic AI agent using the <code>wrap_for_recording</code> function, which wraps the agent using <code>KitaruAgent</code> only when recording is configured, with no Kitaru import on the bare path.</p><p>It probes the workspace once, so an unreachable Kitaru server degrades to an unrecorded run with one warning line. The one exception the block leaves out is a replay spawned by a Kitaru worker, where the same failure is fatal because an unrecorded replay would waste tokens.</p><p><em>From <a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course/blob/main/src/decode/runtime/recording.py">src/decode/runtime/recording.py</a>:</em></p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">async def wrap_for_recording[DepsT, OutputT](
    agent: AbstractAgent[DepsT, OutputT], *, session_name: str | None = None
) -&gt; tuple[AbstractAgent[DepsT, OutputT], str | None]:
    if not recording_is_configured():          
    # KITARU_AGENT_ID + KITARU_API_URL, else the bare agent
        return agent, None

    export_kitaru_api_url()
    try:
        agent_id = _configured_agent_id()
        ...
        await _probe_workspace(agent_id)       
        # Ping the workspace ONCE, before the run burns tokens
        from kitaru_pydantic_ai import KitaruAgent

        wrapped = KitaruAgent(agent, agent_id=agent_id, session_name=session_name)
    except Exception as error:  
    # Broad on purpose: ANY setup failure degrades to the bare agent
        ...
        notice = (
            f"[kitaru] not recording this run: {_workspace_label()} is unavailable "
            f"({one_line(error)}); continuing on the bare agent"
        )
        logger.warning("%s", notice)
        return agent, notice

    ...
    return wrapped, None</code></pre></div><p>And this is how we call it, <em>from <a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course/blob/main/src/decode/runtime/headless.py">src/decode/runtime/headless.py</a></em>:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">agent, recording_notice = await wrap_for_recording(
    _build_headless_agent(model), session_name=session_id
)</code></pre></div><p><code>session_name</code> is Decode&#8217;s own session id, so a Kitaru session and its Opik trace thread share one id, which is what makes the Opik import in the next section a one-to-one mapping.</p><p>With everything in place, let&#8217;s run the framework end to end.</p><h2>From 30 runs to a regression suite</h2><p>You need a mix of at least 20 to 30 sessions to see the agent loop in action. Either run <code>decode run "&lt;goal&gt;"</code> yourself, or let <code>make kitaru-seed</code> record 30 runs in ~10 minutes. You get 14 good sessions and 2 intentionally introduced error clusters: 8 cut off by <code>--max-requests 1</code>, and 8 crashed on a bogus model or a broken provider. The seed emulates 2 common errors we hit while developing Decode and stores all the threads in <a href="https://www.comet.com/site/?utm_source=workshop&amp;utm_medium=partner&amp;utm_campaign=paul&amp;utm_content=coding_agent_course">Opik</a>.</p><blockquote><p>You can find all the commands on how to replicate our experiment in our <a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course/blob/main/running_the_code/06_evals_replays.md">GitHub runbook</a>.</p></blockquote><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!2pZu!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9c91c88b-b642-47ec-85d0-d69f793d644c_3374x1942.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!2pZu!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9c91c88b-b642-47ec-85d0-d69f793d644c_3374x1942.png 424w, https://substackcdn.com/image/fetch/$s_!2pZu!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9c91c88b-b642-47ec-85d0-d69f793d644c_3374x1942.png 848w, https://substackcdn.com/image/fetch/$s_!2pZu!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9c91c88b-b642-47ec-85d0-d69f793d644c_3374x1942.png 1272w, https://substackcdn.com/image/fetch/$s_!2pZu!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9c91c88b-b642-47ec-85d0-d69f793d644c_3374x1942.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!2pZu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9c91c88b-b642-47ec-85d0-d69f793d644c_3374x1942.png" width="1456" height="838" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9c91c88b-b642-47ec-85d0-d69f793d644c_3374x1942.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:838,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!2pZu!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9c91c88b-b642-47ec-85d0-d69f793d644c_3374x1942.png 424w, https://substackcdn.com/image/fetch/$s_!2pZu!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9c91c88b-b642-47ec-85d0-d69f793d644c_3374x1942.png 848w, https://substackcdn.com/image/fetch/$s_!2pZu!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9c91c88b-b642-47ec-85d0-d69f793d644c_3374x1942.png 1272w, https://substackcdn.com/image/fetch/$s_!2pZu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9c91c88b-b642-47ec-85d0-d69f793d644c_3374x1942.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>You sample 20 of the newest 30 sessions into an investigation. For each one, you ask, &#8220;What do you notice? Did it match what should have happened?&#8221; and label it in the UI as <code>acceptable</code>, <code>problematic</code>, or <code>uncertain</code>, plus an optional critique.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!fci4!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69247435-c6c9-46d1-8ec7-29af4141578e_3360x1914.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!fci4!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69247435-c6c9-46d1-8ec7-29af4141578e_3360x1914.png 424w, https://substackcdn.com/image/fetch/$s_!fci4!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69247435-c6c9-46d1-8ec7-29af4141578e_3360x1914.png 848w, https://substackcdn.com/image/fetch/$s_!fci4!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69247435-c6c9-46d1-8ec7-29af4141578e_3360x1914.png 1272w, https://substackcdn.com/image/fetch/$s_!fci4!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69247435-c6c9-46d1-8ec7-29af4141578e_3360x1914.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!fci4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69247435-c6c9-46d1-8ec7-29af4141578e_3360x1914.png" width="1456" height="829" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/69247435-c6c9-46d1-8ec7-29af4141578e_3360x1914.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:829,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!fci4!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69247435-c6c9-46d1-8ec7-29af4141578e_3360x1914.png 424w, https://substackcdn.com/image/fetch/$s_!fci4!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69247435-c6c9-46d1-8ec7-29af4141578e_3360x1914.png 848w, https://substackcdn.com/image/fetch/$s_!fci4!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69247435-c6c9-46d1-8ec7-29af4141578e_3360x1914.png 1272w, https://substackcdn.com/image/fetch/$s_!fci4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69247435-c6c9-46d1-8ec7-29af4141578e_3360x1914.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>I had 6 acceptable, 14 problematic, and 0 uncertain, which the investigations tab sums up in one row:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Oo5G!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61579021-8294-420e-be6a-924c8e732959_3304x1192.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Oo5G!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61579021-8294-420e-be6a-924c8e732959_3304x1192.png 424w, https://substackcdn.com/image/fetch/$s_!Oo5G!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61579021-8294-420e-be6a-924c8e732959_3304x1192.png 848w, https://substackcdn.com/image/fetch/$s_!Oo5G!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61579021-8294-420e-be6a-924c8e732959_3304x1192.png 1272w, https://substackcdn.com/image/fetch/$s_!Oo5G!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61579021-8294-420e-be6a-924c8e732959_3304x1192.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!Oo5G!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61579021-8294-420e-be6a-924c8e732959_3304x1192.png" width="1456" height="525" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/61579021-8294-420e-be6a-924c8e732959_3304x1192.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:525,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!Oo5G!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61579021-8294-420e-be6a-924c8e732959_3304x1192.png 424w, https://substackcdn.com/image/fetch/$s_!Oo5G!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61579021-8294-420e-be6a-924c8e732959_3304x1192.png 848w, https://substackcdn.com/image/fetch/$s_!Oo5G!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61579021-8294-420e-be6a-924c8e732959_3304x1192.png 1272w, https://substackcdn.com/image/fetch/$s_!Oo5G!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61579021-8294-420e-be6a-924c8e732959_3304x1192.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>After wrapping up the investigation, the UI hands you a prompt to paste into a coding agent with the Kitaru skills and MCP server hooked up. I used Opus 5.5:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;plaintext&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-plaintext">Investigation complete: my-discovery-1. 20 of 20 sessions reviewed, agent: decode.
Reviewed 23 September 2026.

Verdicts: 6 acceptable, 14 problematic, 0 uncertain.

Choose what to do next:
1. Build a cohort from a behavior found in these reviewed sessions.
2. Investigate the 14 problematic sessions in more detail.</code></pre></div><p>Running the prompt finds 2 cohort candidates by error type: a run that hits the request limit and ends on a raw <code>UsageLimitExceeded</code> (the error Decode raises when a run hits its request cap) with no output, and a connection error, which it suggests rejecting as agent behavior. You answer <em>&#8220;Create a cohort for each candidate!&#8221;</em> and get 2 cohorts.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!MsHW!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ea9c52e-2e7c-454b-89d9-ea087343b2f2_1998x1544.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!MsHW!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ea9c52e-2e7c-454b-89d9-ea087343b2f2_1998x1544.png 424w, https://substackcdn.com/image/fetch/$s_!MsHW!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ea9c52e-2e7c-454b-89d9-ea087343b2f2_1998x1544.png 848w, https://substackcdn.com/image/fetch/$s_!MsHW!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ea9c52e-2e7c-454b-89d9-ea087343b2f2_1998x1544.png 1272w, https://substackcdn.com/image/fetch/$s_!MsHW!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ea9c52e-2e7c-454b-89d9-ea087343b2f2_1998x1544.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!MsHW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ea9c52e-2e7c-454b-89d9-ea087343b2f2_1998x1544.png" width="1456" height="1125" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4ea9c52e-2e7c-454b-89d9-ea087343b2f2_1998x1544.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1125,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!MsHW!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ea9c52e-2e7c-454b-89d9-ea087343b2f2_1998x1544.png 424w, https://substackcdn.com/image/fetch/$s_!MsHW!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ea9c52e-2e7c-454b-89d9-ea087343b2f2_1998x1544.png 848w, https://substackcdn.com/image/fetch/$s_!MsHW!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ea9c52e-2e7c-454b-89d9-ea087343b2f2_1998x1544.png 1272w, https://substackcdn.com/image/fetch/$s_!MsHW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ea9c52e-2e7c-454b-89d9-ea087343b2f2_1998x1544.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>You either apply an existing evaluator or create one per cohort. We have one of each: <code>decode_connection_error.py</code> for the connection-error cohort and <code>decode_request_limit.py</code> for the request-limit cohort. A new failure class needs a new evaluator, which is easy because the cohort holds every session&#8217;s logs and errors, providing enough context to your coding agent.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!cdUg!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a2990af-3619-4a50-bb3d-b557dc342c96_3384x1668.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!cdUg!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a2990af-3619-4a50-bb3d-b557dc342c96_3384x1668.png 424w, https://substackcdn.com/image/fetch/$s_!cdUg!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a2990af-3619-4a50-bb3d-b557dc342c96_3384x1668.png 848w, https://substackcdn.com/image/fetch/$s_!cdUg!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a2990af-3619-4a50-bb3d-b557dc342c96_3384x1668.png 1272w, https://substackcdn.com/image/fetch/$s_!cdUg!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a2990af-3619-4a50-bb3d-b557dc342c96_3384x1668.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!cdUg!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a2990af-3619-4a50-bb3d-b557dc342c96_3384x1668.png" width="1456" height="718" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1a2990af-3619-4a50-bb3d-b557dc342c96_3384x1668.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:718,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!cdUg!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a2990af-3619-4a50-bb3d-b557dc342c96_3384x1668.png 424w, https://substackcdn.com/image/fetch/$s_!cdUg!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a2990af-3619-4a50-bb3d-b557dc342c96_3384x1668.png 848w, https://substackcdn.com/image/fetch/$s_!cdUg!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a2990af-3619-4a50-bb3d-b557dc342c96_3384x1668.png 1272w, https://substackcdn.com/image/fetch/$s_!cdUg!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a2990af-3619-4a50-bb3d-b557dc342c96_3384x1668.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><blockquote><p>&#128161; We always prioritize code checks over LLM judges. They are cheap, fast, and need no maintenance, while a judge needs labeled examples and calibration first. A judge is always the last resort.</p></blockquote><p>Both evaluators read the session&#8217;s terminal error and flag the marker they own, and a non-terminal session with no error returns <code>passed=None</code>, never a silent fail. The evaluator <em>fails</em> when the failure class is present, so a cohort session fails until the code is properly fixed or the bug is accidentally reintroduced.</p><p>Anthropic warns that checking an exact tool-call sequence is <a href="https://www.anthropic.com/engineering/demystifying-evals-for-ai-agents">&#8220;too rigid&#8221;</a>, so check the overall contract, such as the outcome or a hard constraint like &#8220;the run must not end on this error&#8221;.</p><p><em>From <a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course/blob/main/evaluators/decode_connection_error.py">evaluators/decode_connection_error.py</a></em>:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">from typing import Any

from kitaru.task.evaluator import EvaluationResult, SessionView

_RESULT_NAME = "connection_error_crash"
_MARKERS = ("Connection error", "ConnectError")


def evaluate(session: SessionView, **params: Any) -&gt; EvaluationResult | list[EvaluationResult]:
    record = session.session
    error = record.error or ""

    if not error and str(record.status or "") == "in_progress":
        return EvaluationResult(
            name=_RESULT_NAME,
            passed=None,
            value="unresolved",
            explanation="Session is non-terminal with no error; evidence missing.",
        )

    detected = any(marker in error for marker in _MARKERS)
    explanation = (
        "Terminal error is a connection failure: the provider endpoint was unreachable."
        if detected
        else "No connection failure: the session has no error or failed for another reason."
    )
    return EvaluationResult(
        name=_RESULT_NAME, score=detected, passed=not detected, explanation=explanation
    )</code></pre></div><p>The <code>decode_request_limit</code> evaluator, <em>from <a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course/blob/main/evaluators/decode_request_limit.py">evaluators/decode_request_limit.py</a></em>, has the same Python logic, but with different markers:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">_RESULT_NAME = "request_limit_cutoff"
_MARKERS = ("UsageLimitExceeded", "exceed the request_limit")</code></pre></div><p>You prompt the coding agent to apply the 2 evaluators, one per cohort. Each session fails because it still contains the error.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!k1ar!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d1e40cf-37cf-4bc7-85ae-36cf7872ac57_3354x1406.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!k1ar!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d1e40cf-37cf-4bc7-85ae-36cf7872ac57_3354x1406.png 424w, https://substackcdn.com/image/fetch/$s_!k1ar!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d1e40cf-37cf-4bc7-85ae-36cf7872ac57_3354x1406.png 848w, https://substackcdn.com/image/fetch/$s_!k1ar!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d1e40cf-37cf-4bc7-85ae-36cf7872ac57_3354x1406.png 1272w, https://substackcdn.com/image/fetch/$s_!k1ar!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d1e40cf-37cf-4bc7-85ae-36cf7872ac57_3354x1406.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!k1ar!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d1e40cf-37cf-4bc7-85ae-36cf7872ac57_3354x1406.png" width="1456" height="610" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6d1e40cf-37cf-4bc7-85ae-36cf7872ac57_3354x1406.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:610,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!k1ar!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d1e40cf-37cf-4bc7-85ae-36cf7872ac57_3354x1406.png 424w, https://substackcdn.com/image/fetch/$s_!k1ar!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d1e40cf-37cf-4bc7-85ae-36cf7872ac57_3354x1406.png 848w, https://substackcdn.com/image/fetch/$s_!k1ar!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d1e40cf-37cf-4bc7-85ae-36cf7872ac57_3354x1406.png 1272w, https://substackcdn.com/image/fetch/$s_!k1ar!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d1e40cf-37cf-4bc7-85ae-36cf7872ac57_3354x1406.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>Now you run a root cause analysis on one cohort session and fix the code behind it. Ours was artificially injected by the seed, so we know the rerun will pass. In a real scenario, you fix the code first.</p><p>This cohort is the failure class of my 503 error due to the missing warm-up logic when running my models on Modal, now frozen as 4 replayable sessions. After fixing the bug, you prompt, in the same session: <em>&#8220;For cohort </em><code>decode-connection-error</code><em> we fixed the connection error. Start an experiment based on the sessions from the cohort, rerun the evaluator and see if the failure class has been resolved.&#8221;</em></p><p>Kitaru replays every cohort session on a worker in an isolated Decode instance, from the original prompt. These baselines crashed before their first tool call, so the experiment&#8217;s <strong>tool policy</strong> (next section) lets tools run for real.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!fAjN!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9db5f5c9-2f65-49dc-904d-9c7672db0cb7_3372x1458.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!fAjN!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9db5f5c9-2f65-49dc-904d-9c7672db0cb7_3372x1458.png 424w, https://substackcdn.com/image/fetch/$s_!fAjN!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9db5f5c9-2f65-49dc-904d-9c7672db0cb7_3372x1458.png 848w, https://substackcdn.com/image/fetch/$s_!fAjN!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9db5f5c9-2f65-49dc-904d-9c7672db0cb7_3372x1458.png 1272w, https://substackcdn.com/image/fetch/$s_!fAjN!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9db5f5c9-2f65-49dc-904d-9c7672db0cb7_3372x1458.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!fAjN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9db5f5c9-2f65-49dc-904d-9c7672db0cb7_3372x1458.png" width="1456" height="630" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9db5f5c9-2f65-49dc-904d-9c7672db0cb7_3372x1458.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:630,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!fAjN!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9db5f5c9-2f65-49dc-904d-9c7672db0cb7_3372x1458.png 424w, https://substackcdn.com/image/fetch/$s_!fAjN!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9db5f5c9-2f65-49dc-904d-9c7672db0cb7_3372x1458.png 848w, https://substackcdn.com/image/fetch/$s_!fAjN!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9db5f5c9-2f65-49dc-904d-9c7672db0cb7_3372x1458.png 1272w, https://substackcdn.com/image/fetch/$s_!fAjN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9db5f5c9-2f65-49dc-904d-9c7672db0cb7_3372x1458.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>Two runs: run 1 replays the cohort with the code untouched and still fails on every session, so the failure reproduces and the recording is trustworthy. Run 2, after the fix, shows the failure class resolved on every session.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!U59E!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10f96b81-b1c0-457b-b5a4-10fc7613f4eb_3376x1532.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!U59E!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10f96b81-b1c0-457b-b5a4-10fc7613f4eb_3376x1532.png 424w, https://substackcdn.com/image/fetch/$s_!U59E!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10f96b81-b1c0-457b-b5a4-10fc7613f4eb_3376x1532.png 848w, https://substackcdn.com/image/fetch/$s_!U59E!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10f96b81-b1c0-457b-b5a4-10fc7613f4eb_3376x1532.png 1272w, https://substackcdn.com/image/fetch/$s_!U59E!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10f96b81-b1c0-457b-b5a4-10fc7613f4eb_3376x1532.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!U59E!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10f96b81-b1c0-457b-b5a4-10fc7613f4eb_3376x1532.png" width="1456" height="661" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/10f96b81-b1c0-457b-b5a4-10fc7613f4eb_3376x1532.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:661,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!U59E!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10f96b81-b1c0-457b-b5a4-10fc7613f4eb_3376x1532.png 424w, https://substackcdn.com/image/fetch/$s_!U59E!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10f96b81-b1c0-457b-b5a4-10fc7613f4eb_3376x1532.png 848w, https://substackcdn.com/image/fetch/$s_!U59E!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10f96b81-b1c0-457b-b5a4-10fc7613f4eb_3376x1532.png 1272w, https://substackcdn.com/image/fetch/$s_!U59E!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10f96b81-b1c0-457b-b5a4-10fc7613f4eb_3376x1532.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><h2>Properly understanding replays</h2><p>A <strong>replay</strong> re-runs Decode from scratch. The only exception is that all tool calls are recorded, which means that if an agent calls a tool with the same inputs, it will use a cached output.</p><p>This means the agent loop&#8217;s decision path reflects the latest code changes. To avoid recreating the same context used by the tools, we reuse cached tool outputs instead, making it 10x easier to run experiments in the same context than to reproduce the files or database state the agent had at that moment. In Kitaru&#8217;s terms, a replay is still a <a href="https://docs.zenml.io/kitaru/guides/replay-and-overrides?utm_source=decodingai&amp;utm_medium=referral&amp;utm_campaign=coding-agent-course&amp;utm_content=docs">fresh execution, not a playback</a>.</p><p>Replays are an amazing way to reproduce your bugs as well. Start from your <strong>observed</strong> session, <strong>reproduce</strong> it with 0 changes to the code, then create a <strong>fork</strong>, change your model, system prompt or other parts of the code and run a replay again. Then you can do a diff between the reproduction and the fork to see the impact of your change.</p><p>Remember that every replay, as it executes your agent, burns real tokens instead of mocking the calls, so a 4-session cohort is cheap to rerun on every change and a 200-session one is not. That&#8217;s why cohorts stay small, and ideally evaluators are code, not judges.</p><p>In reality, we have more control than always using the cached outputs. For each tool (bash, file writes, web fetches), the tool policy decides whether the call is answered from the recording, a fixed table, a real execution, or a model, and what happens on a miss. Without a suitable policy, <a href="https://docs.zenml.io/kitaru/guides/tool-policies?utm_source=decodingai&amp;utm_medium=referral&amp;utm_campaign=coding-agent-course&amp;utm_content=docs">&#8220;a replay can call a live tool and repeat its side effects&#8221;</a>: with the default <code>passthrough</code>, a replayed <code>refund_payment</code> refunds the card again.</p><p><strong>Tool policy configs:</strong></p><ul><li><p><strong>type</strong>: <code>history</code> (answer from the recording), <code>static</code> (a fixed table), <code>passthrough</code> (run the tool for real), or <code>llm</code> (let a model invent the result).</p></li><li><p><strong>on_miss</strong>: what happens when the recording has no answer: <code>fail</code> (stop the replay), <code>error_result</code> (hand the model an error and continue), or <code>passthrough</code> (run the tool for real).</p></li><li><p><strong>scope</strong>: which recordings <code>history</code> may answer from: <code>baseline</code>, <code>cohort_version</code>, or <code>agent</code>.</p></li></ul><p>Pick <code>on_miss</code> (what a replay does when the recording has no answer for a tool call) by how complete the recording is. Complete baselines get <code>history</code> with <code>on_miss: fail</code>, so an unanswerable call stops the replay instead of inventing the rest. Cut-off or crashed baselines, like our 2 cohorts, need <code>on_miss: passthrough</code>.</p><p>The tool then runs live inside the worker&#8217;s <strong>workspace</strong> (the fresh clone a worker runs Decode in). That is safe for Decode only because its live tools are bash and file edits inside a throwaway container. For an agent whose tools touch real resources such as a payment card or a database, <code>passthrough</code> is extremely dangerous and needs to be carefully mocked.</p><p>A replay always starts from a single session and produces a new one, listed next to the original in the sessions tab with <code>Replay</code> as its origin:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!4zOc!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbbddefe-52c0-4b0c-aa4f-481570a581ec_3364x1514.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!4zOc!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbbddefe-52c0-4b0c-aa4f-481570a581ec_3364x1514.png 424w, https://substackcdn.com/image/fetch/$s_!4zOc!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbbddefe-52c0-4b0c-aa4f-481570a581ec_3364x1514.png 848w, https://substackcdn.com/image/fetch/$s_!4zOc!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbbddefe-52c0-4b0c-aa4f-481570a581ec_3364x1514.png 1272w, https://substackcdn.com/image/fetch/$s_!4zOc!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbbddefe-52c0-4b0c-aa4f-481570a581ec_3364x1514.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!4zOc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbbddefe-52c0-4b0c-aa4f-481570a581ec_3364x1514.png" width="1456" height="655" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/dbbddefe-52c0-4b0c-aa4f-481570a581ec_3364x1514.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:655,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!4zOc!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbbddefe-52c0-4b0c-aa4f-481570a581ec_3364x1514.png 424w, https://substackcdn.com/image/fetch/$s_!4zOc!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbbddefe-52c0-4b0c-aa4f-481570a581ec_3364x1514.png 848w, https://substackcdn.com/image/fetch/$s_!4zOc!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbbddefe-52c0-4b0c-aa4f-481570a581ec_3364x1514.png 1272w, https://substackcdn.com/image/fetch/$s_!4zOc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbbddefe-52c0-4b0c-aa4f-481570a581ec_3364x1514.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>Select both, and the dashboard diffs the replay against its baseline, node by node:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!2kJV!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe152ed5b-a777-4173-b6a9-611e9084a79e_3294x1638.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!2kJV!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe152ed5b-a777-4173-b6a9-611e9084a79e_3294x1638.png 424w, https://substackcdn.com/image/fetch/$s_!2kJV!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe152ed5b-a777-4173-b6a9-611e9084a79e_3294x1638.png 848w, https://substackcdn.com/image/fetch/$s_!2kJV!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe152ed5b-a777-4173-b6a9-611e9084a79e_3294x1638.png 1272w, https://substackcdn.com/image/fetch/$s_!2kJV!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe152ed5b-a777-4173-b6a9-611e9084a79e_3294x1638.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!2kJV!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe152ed5b-a777-4173-b6a9-611e9084a79e_3294x1638.png" width="1456" height="724" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e152ed5b-a777-4173-b6a9-611e9084a79e_3294x1638.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:724,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!2kJV!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe152ed5b-a777-4173-b6a9-611e9084a79e_3294x1638.png 424w, https://substackcdn.com/image/fetch/$s_!2kJV!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe152ed5b-a777-4173-b6a9-611e9084a79e_3294x1638.png 848w, https://substackcdn.com/image/fetch/$s_!2kJV!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe152ed5b-a777-4173-b6a9-611e9084a79e_3294x1638.png 1272w, https://substackcdn.com/image/fetch/$s_!2kJV!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe152ed5b-a777-4173-b6a9-611e9084a79e_3294x1638.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>A replay with one change is exactly how you test a change to the harness. Let&#8217;s see how that works when swapping the model.</p><h2>Swap the model, replay the same cohort</h2><p>Suppose you change the harness and want to see how that change affects performance. Here the change is the model: from <code>Qwen/Qwen3.6-35B-A3B-FP8</code> on <a href="https://modal.com?source=decodingai&amp;campaign=harnesseng.">Modal</a> to <code>gemini-3.8-flash</code>.</p><p>You create the experiment (nothing runs yet) with the following config: the <code>decode-connection-error</code> evaluator, a tool policy of <code>history</code> on the baseline with <code>on_miss: passthrough</code>, and a model override that replaces the model on every model call. The same experiment shape tests a prompt change through the <code>system_prompt</code> or <code>prompt</code> keys, or a parameter change through <code>model_params</code>.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!_iUE!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f156cc5-54a0-4a9a-96dc-18056ef98dc3_3304x1354.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!_iUE!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f156cc5-54a0-4a9a-96dc-18056ef98dc3_3304x1354.png 424w, https://substackcdn.com/image/fetch/$s_!_iUE!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f156cc5-54a0-4a9a-96dc-18056ef98dc3_3304x1354.png 848w, https://substackcdn.com/image/fetch/$s_!_iUE!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f156cc5-54a0-4a9a-96dc-18056ef98dc3_3304x1354.png 1272w, https://substackcdn.com/image/fetch/$s_!_iUE!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f156cc5-54a0-4a9a-96dc-18056ef98dc3_3304x1354.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!_iUE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f156cc5-54a0-4a9a-96dc-18056ef98dc3_3304x1354.png" width="1456" height="597" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0f156cc5-54a0-4a9a-96dc-18056ef98dc3_3304x1354.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:597,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!_iUE!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f156cc5-54a0-4a9a-96dc-18056ef98dc3_3304x1354.png 424w, https://substackcdn.com/image/fetch/$s_!_iUE!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f156cc5-54a0-4a9a-96dc-18056ef98dc3_3304x1354.png 848w, https://substackcdn.com/image/fetch/$s_!_iUE!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f156cc5-54a0-4a9a-96dc-18056ef98dc3_3304x1354.png 1272w, https://substackcdn.com/image/fetch/$s_!_iUE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f156cc5-54a0-4a9a-96dc-18056ef98dc3_3304x1354.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>You start the run against the cohort version you replayed before (the frozen list of session ids the experiment ran against), and the worker replays each session on the new model.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!YpNh!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f251559-13a7-4300-90fc-73835ecd5715_3290x1504.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!YpNh!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f251559-13a7-4300-90fc-73835ecd5715_3290x1504.png 424w, https://substackcdn.com/image/fetch/$s_!YpNh!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f251559-13a7-4300-90fc-73835ecd5715_3290x1504.png 848w, https://substackcdn.com/image/fetch/$s_!YpNh!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f251559-13a7-4300-90fc-73835ecd5715_3290x1504.png 1272w, https://substackcdn.com/image/fetch/$s_!YpNh!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f251559-13a7-4300-90fc-73835ecd5715_3290x1504.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!YpNh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f251559-13a7-4300-90fc-73835ecd5715_3290x1504.png" width="1456" height="666" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4f251559-13a7-4300-90fc-73835ecd5715_3290x1504.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:666,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!YpNh!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f251559-13a7-4300-90fc-73835ecd5715_3290x1504.png 424w, https://substackcdn.com/image/fetch/$s_!YpNh!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f251559-13a7-4300-90fc-73835ecd5715_3290x1504.png 848w, https://substackcdn.com/image/fetch/$s_!YpNh!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f251559-13a7-4300-90fc-73835ecd5715_3290x1504.png 1272w, https://substackcdn.com/image/fetch/$s_!YpNh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f251559-13a7-4300-90fc-73835ecd5715_3290x1504.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>When it finishes, you read the pass/fail counts for that run. All 4 sessions passed:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!oJF6!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F15362f61-9189-471c-bec5-5a9ce71548bc_3326x1770.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!oJF6!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F15362f61-9189-471c-bec5-5a9ce71548bc_3326x1770.png 424w, https://substackcdn.com/image/fetch/$s_!oJF6!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F15362f61-9189-471c-bec5-5a9ce71548bc_3326x1770.png 848w, https://substackcdn.com/image/fetch/$s_!oJF6!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F15362f61-9189-471c-bec5-5a9ce71548bc_3326x1770.png 1272w, https://substackcdn.com/image/fetch/$s_!oJF6!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F15362f61-9189-471c-bec5-5a9ce71548bc_3326x1770.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!oJF6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F15362f61-9189-471c-bec5-5a9ce71548bc_3326x1770.png" width="1456" height="775" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/15362f61-9189-471c-bec5-5a9ce71548bc_3326x1770.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:775,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!oJF6!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F15362f61-9189-471c-bec5-5a9ce71548bc_3326x1770.png 424w, https://substackcdn.com/image/fetch/$s_!oJF6!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F15362f61-9189-471c-bec5-5a9ce71548bc_3326x1770.png 848w, https://substackcdn.com/image/fetch/$s_!oJF6!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F15362f61-9189-471c-bec5-5a9ce71548bc_3326x1770.png 1272w, https://substackcdn.com/image/fetch/$s_!oJF6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F15362f61-9189-471c-bec5-5a9ce71548bc_3326x1770.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>And the full experiment config sits next to them, with the model overridden and every tool answered from the recording:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!kHyB!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c8034b0-c8ac-4d3b-b1e9-a7c65403e17b_2620x1164.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!kHyB!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c8034b0-c8ac-4d3b-b1e9-a7c65403e17b_2620x1164.png 424w, https://substackcdn.com/image/fetch/$s_!kHyB!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c8034b0-c8ac-4d3b-b1e9-a7c65403e17b_2620x1164.png 848w, https://substackcdn.com/image/fetch/$s_!kHyB!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c8034b0-c8ac-4d3b-b1e9-a7c65403e17b_2620x1164.png 1272w, https://substackcdn.com/image/fetch/$s_!kHyB!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c8034b0-c8ac-4d3b-b1e9-a7c65403e17b_2620x1164.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!kHyB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c8034b0-c8ac-4d3b-b1e9-a7c65403e17b_2620x1164.png" width="1456" height="647" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3c8034b0-c8ac-4d3b-b1e9-a7c65403e17b_2620x1164.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:647,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!kHyB!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c8034b0-c8ac-4d3b-b1e9-a7c65403e17b_2620x1164.png 424w, https://substackcdn.com/image/fetch/$s_!kHyB!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c8034b0-c8ac-4d3b-b1e9-a7c65403e17b_2620x1164.png 848w, https://substackcdn.com/image/fetch/$s_!kHyB!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c8034b0-c8ac-4d3b-b1e9-a7c65403e17b_2620x1164.png 1272w, https://substackcdn.com/image/fetch/$s_!kHyB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c8034b0-c8ac-4d3b-b1e9-a7c65403e17b_2620x1164.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><blockquote><p>&#9888;&#65039; <code>decode-connection-error</code> only flags connection errors, so a replay that crashes for any other reason still passes it. A green run shows the new model did not reintroduce connection failures, not that the migration works. Pair it with an evaluator that checks the task itself, and read pass/fail per session plus the cost delta, never one aggregate score.</p></blockquote><h2>What replays do not solve</h2><p>Replays are a good strategy for reproducing behavior and running regression tests, but not for running benchmarks that measure performance and optimize your system. In that case, run everything from scratch in isolated environments on open-ended tasks that ask whether the agent can complete its goal at all. See <a href="https://www.decodingai.com/p/evaluate-ai-agents-benchmarks-regression-tests">Lesson 7</a> to learn more about implementing your custom benchmark.</p><p>Replays also do not discover unseen scenarios. A regression suite only catches previous errors detected via the error analysis framework.</p><blockquote><p>&#129489;&#8205;&#128187; Clone the <a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course/tree/main">course repo</a>, follow the replays <a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course/blob/main/running_the_code/06_evals_replays.md">runbook</a>, seed 30 sessions, label 20, pick a cohort and build an evaluator for it.</p></blockquote><p>With this lesson, we&#8217;ve finally wrapped up the <strong><a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course">How to Build a Coding Agent From Scratch</a></strong> course, where we&#8217;ve learned how to design, build and evaluate a Claude Code-style coding agent.</p><p><em>For previous lessons, here is the lesson-by-lesson course roadmap (<a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course#-course-outline">see all on GitHub</a>):</em></p><ol><li><p><a href="https://www.decodingai.com/p/building-a-coding-agent-from-scratch-system-design">Building a Coding Agent From Scratch</a></p></li><li><p><a href="https://www.decodingai.com/p/the-coding-agent-loop">The Bare-Bones Coding Agent Loop</a></p></li><li><p><a href="https://www.decodingai.com/p/run-coding-agents-safely">From a Raw Shell to a Sandboxed Coding Agent</a></p></li><li><p><a href="https://www.decodingai.com/p/context-engineering-for-coding-agents">Context Engineering for Coding Agents</a></p></li><li><p><a href="https://www.decodingai.com/p/subagents-are-context-engineering">Subagents Are Context Engineering</a></p></li><li><p><a href="https://www.decodingai.com/p/coding-agents-in-remote-headless">Swarm of Remote Agents</a></p></li><li><p><a href="https://www.decodingai.com/p/evaluate-ai-agents-benchmarks-regression-tests">Agent Evals 101</a></p></li><li><p><strong>Turn Your Agent&#8217;s Failures Into a Regression Suite</strong> <strong>&#8592; </strong><em><strong>you are here</strong></em></p></li></ol><p><em>But here is what I&#8217;m wondering:</em></p><blockquote><p><em><strong>What is your current strategy to grow your regression tests?</strong></em></p></blockquote><p><em>Click the button below and tell me. I read every response.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://www.decodingai.com/p/transform-agent-traces-into-regression-cases/comments&quot;,&quot;text&quot;:&quot;Leave a comment&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://www.decodingai.com/p/transform-agent-traces-into-regression-cases/comments"><span>Leave a comment</span></a></p><div><hr></div><p><em>Enjoyed the article? The most sincere compliment is to restack this for your readers.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://www.decodingai.com/p/transform-agent-traces-into-regression-cases?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;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://www.decodingai.com/p/transform-agent-traces-into-regression-cases?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p><div><hr></div><p><em>Special thanks to <strong><a href="https://modal.com?source=decodingai&amp;campaign=harnesseng">Modal</a></strong>, <strong><a href="https://www.comet.com/site/?utm_source=workshop&amp;utm_medium=partner&amp;utm_campaign=paul&amp;utm_content=coding_agent_course">Opik (by Comet)</a></strong>, and <strong><a href="https://www.zenml.io/product/kitaru?utm_source=decodingai&amp;utm_medium=referral&amp;utm_campaign=coding-agent-course&amp;utm_content=brand">Kitaru (by ZenML)</a></strong> for sponsoring this open-source course and keeping it free!</em></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Uq-1!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Uq-1!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 424w, https://substackcdn.com/image/fetch/$s_!Uq-1!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 848w, https://substackcdn.com/image/fetch/$s_!Uq-1!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 1272w, https://substackcdn.com/image/fetch/$s_!Uq-1!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!Uq-1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png" width="1200" height="400" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:400,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:69533,&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://www.decodingai.com/i/207400663?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.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_!Uq-1!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 424w, https://substackcdn.com/image/fetch/$s_!Uq-1!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 848w, https://substackcdn.com/image/fetch/$s_!Uq-1!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 1272w, https://substackcdn.com/image/fetch/$s_!Uq-1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><div><hr></div><div class="callout-block" data-callout="true"><h4>Whenever you&#8217;re ready, here is how I can help you</h4><p><em>Go from agent user to agent builder.</em> Master the foundations of AI agents and turn fragile demo code into reliable, production-ready systems with my course, <strong><a href="https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering">Agent Engineering: Building Multi-Agent Systems</a></strong> (made with Towards AI).</p><p>35 lessons. Pure foundations from scratch. 4 mini-projects. 2 production systems. A certificate and direct access to me &amp; industry experts in our Discord.</p><p>Built for software and data professionals transitioning into AI engineering. <em>Rated 5/5 with 300+ students. The first 7 lessons are free:</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering&quot;,&quot;text&quot;:&quot;Start here&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering"><span>Start here</span></a></p><p><em>Not ready to commit?</em> Start with our <strong><a href="https://email-course.towardsai.net/?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering">free Agent AI Engineering Guide</a></strong>, a 6-day email course on the mistakes that silently break AI agents in production.</p></div><div><hr></div><h2>Images &amp; videos</h2><p>If not otherwise stated, all images and videos are created by the author.</p>]]></content:encoded></item><item><title><![CDATA[Agent Evals 101: Stop Guessing, Start Measuring]]></title><description><![CDATA[How to benchmark and regression-test any agent harness]]></description><link>https://www.decodingai.com/p/evaluate-ai-agents-benchmarks-regression-tests</link><guid isPermaLink="false">https://www.decodingai.com/p/evaluate-ai-agents-benchmarks-regression-tests</guid><dc:creator><![CDATA[Paul Iusztin]]></dc:creator><pubDate>Tue, 22 Sep 2026 05:01:45 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!iONv!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84545663-2d8e-4362-8142-f2968a12a641_1376x768.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="callout-block" data-callout="true"><p><em><strong><span data-color="#c02f26" style="color: rgb(192, 47, 38);">Every AI application that wraps an agent is a harness!</span></strong><span data-color="#c02f26" style="color: rgb(192, 47, 38);"> </span></em></p><p>In LangChain&#8217;s Terminal-Bench experiment, changing only the harness (with the same model) moved a coding agent from ~30th place into the top 5: the harness, not the model, is what makes a coding agent good.</p><p>In the&nbsp;<strong>open-source course</strong>&nbsp;<strong><a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course">Building a Coding Agent From Scratch</a></strong>, you&#8217;ll build that harness from scratch in Python:&nbsp;<strong>Decode</strong>, a complete coding agent that grows lesson by lesson from a bare agent loop into a swarm of remote agents running in parallel in the cloud.</p><p><strong>Why?</strong>&nbsp;You&#8217;ll be able to engineer custom harnesses for your own AI products (the skill behind that leaderboard jump), and you&#8217;ll understand what Claude Code and Codex actually do under the hood, turning you into a power user.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ge05!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ge05!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 424w, https://substackcdn.com/image/fetch/$s_!ge05!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 848w, https://substackcdn.com/image/fetch/$s_!ge05!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 1272w, https://substackcdn.com/image/fetch/$s_!ge05!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ge05!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif" width="1200" height="630" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:630,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1446989,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/gif&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://www.decodingai.com/i/207400663?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ge05!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 424w, https://substackcdn.com/image/fetch/$s_!ge05!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 848w, https://substackcdn.com/image/fetch/$s_!ge05!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 1272w, https://substackcdn.com/image/fetch/$s_!ge05!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><strong>Lessons:</strong></p><ol><li><p><a href="https://www.decodingai.com/p/building-a-coding-agent-from-scratch-system-design">Building a Coding Agent From Scratch</a></p></li><li><p><a href="https://www.decodingai.com/p/the-coding-agent-loop">The Bare-Bones Coding Agent Loop</a></p></li><li><p><a href="https://www.decodingai.com/p/run-coding-agents-safely">From a Raw Shell to a Sandboxed Coding Agent</a></p></li><li><p><a href="https://www.decodingai.com/p/context-engineering-for-coding-agents">Context Engineering for Coding Agents</a></p></li><li><p><a href="https://www.decodingai.com/p/subagents-are-context-engineering">Subagents Are Context Engineering</a></p></li><li><p><a href="https://www.decodingai.com/p/coding-agents-in-remote-headless">Swarm of Remote Agents</a></p></li><li><p><strong>Agent Evals 101</strong> <strong>&#8592; </strong><em><strong>you are here</strong></em></p></li><li><p><a href="https://www.decodingai.com/p/transform-agent-traces-into-regression-cases">Turn Your Agent&#8217;s Failures Into a Regression Suite</a></p></li></ol><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course&quot;,&quot;text&quot;:&quot;Full open-source course&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course"><span>Full open-source course</span></a></p><p><em>Special thanks to <strong><a href="https://modal.com/?source=decodingai&amp;campaign=harnesseng">Modal</a></strong>, <strong><a href="https://www.comet.com/site/?utm_source=workshop&amp;utm_medium=partner&amp;utm_campaign=paul&amp;utm_content=coding_agent_course">Opik (by Comet)</a></strong>, and <strong><a href="https://www.zenml.io/product/kitaru?utm_source=decodingai&amp;utm_medium=referral&amp;utm_campaign=coding-agent-course&amp;utm_content=brand">Kitaru (by ZenML)</a></strong> for sponsoring this open-source course and keeping it free!</em></p></div><h1>Lesson 7: Agent Evals 101</h1><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!iONv!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84545663-2d8e-4362-8142-f2968a12a641_1376x768.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!iONv!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84545663-2d8e-4362-8142-f2968a12a641_1376x768.png 424w, https://substackcdn.com/image/fetch/$s_!iONv!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84545663-2d8e-4362-8142-f2968a12a641_1376x768.png 848w, https://substackcdn.com/image/fetch/$s_!iONv!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84545663-2d8e-4362-8142-f2968a12a641_1376x768.png 1272w, https://substackcdn.com/image/fetch/$s_!iONv!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84545663-2d8e-4362-8142-f2968a12a641_1376x768.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!iONv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84545663-2d8e-4362-8142-f2968a12a641_1376x768.png" width="1376" height="768" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/84545663-2d8e-4362-8142-f2968a12a641_1376x768.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:768,&quot;width&quot;:1376,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1164312,&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;:false,&quot;internalRedirect&quot;:&quot;https://www.decodingai.com/i/216358812?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84545663-2d8e-4362-8142-f2968a12a641_1376x768.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_!iONv!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84545663-2d8e-4362-8142-f2968a12a641_1376x768.png 424w, https://substackcdn.com/image/fetch/$s_!iONv!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84545663-2d8e-4362-8142-f2968a12a641_1376x768.png 848w, https://substackcdn.com/image/fetch/$s_!iONv!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84545663-2d8e-4362-8142-f2968a12a641_1376x768.png 1272w, https://substackcdn.com/image/fetch/$s_!iONv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84545663-2d8e-4362-8142-f2968a12a641_1376x768.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>While optimizing my coding agent on my custom benchmark, I compared its performance against two models: a 35B vs. a 120B. The winner should be obvious, right? As the 120B model is 3 to 4 times larger (both are MoE). Well... the 35B model had a 95% success rate, while the 120B model had 53%. Auch.</p><p>There is more to this story, which I will explain in this article, but this is a clear signal that public benchmarks, model size, or other model features mean nothing until you test them on your custom evals built for your use case.</p><p>In this article, I want to show you exactly that. How to build a custom eval harness for your agent harness (word overloading alert!) to quantify your application&#8217;s performance, cost and latency on what you care about. Delivering shareholder value... Or if you are like me, just to create a badass AI app that you actually know works with concrete metrics, not just assumptions and vibes.</p><p>To avoid staying too abstract, I will show you how to build the evals layer for Decode, my Claude Code educational clone I built for this series. Still, this piece makes sense on its own, treating the coding agent as a black box. Plus, we will focus on techniques that can easily be extrapolated to other types of harnesses such as research agents or personal assistants. Ultimately, the core of the harness is the same regardless of the domain it attacks.</p><p>In reality, evals are more than benchmarks. That&#8217;s why it can get confusing, since it has so many facets. So let&#8217;s start by understanding the 3 big ways to think about evals and how to integrate them into your AI app. Then, we will zoom in on designing and building them.</p><h2>Three questions every production agent must answer</h2><p>We run Decode as a background agent by typing <code>decode run</code> in the terminal. The eval harness uses the same interface to run it as a subprocess, so we can leverage the sandbox (the container its bash and file tools run in) and hand-back mechanism (the agent returns its work as a git branch) already baked into the coding agent to isolate the agent while being executed within the eval harness.</p><p><em>From </em><code>evals/harness/trial.py</code>:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">command = [
    sys.executable, "-m", "decode", "run",
    task.instruction,                    # inject trial instruction
    "--repo", str(seed_dir),             # where to get the code from
    "--local",
    "--max-requests", str(task.max_steps),
    "--summary-json", str(agent_dir / "summary.json"),
]
process = subprocess.Popen(
    command,
    cwd=home_dir,                        # working directory of the trial
    env=child_env(sandbox=sandbox),      # SANDBOX_MODE=docker|modal,
    start_new_session=True
)</code></pre></div><p>The <code>--repo</code> flag clones the <strong>seed repo</strong> (a fresh git repo at a pinned commit) so every trial starts identical, and <code>--summary-json</code> outputs the run&#8217;s report, so grading never parses traces, but loads a structured report that can be interpreted in Python or other programming language.</p><p>The eval harness never imports the agent&#8217;s loop. It launches the agent in a different process as a completely different program through the narrowest interface the product has (a command line, an HTTP call, a function). So the eval and coding harnesses are two different programs, completely decoupled.</p><div class="pullquote"><p>&#128161; The <strong>3 questions we must answer</strong> whenever we evaluate our agent!</p></div><p><strong>Benchmarks</strong> answer <em>&#8220;does it work?&#8221;</em> They run during feature development. These are the metrics you optimize every feature against. It helps you understand if a prompt tweak truly helps or not.</p><p><strong>Regression tests</strong> answer <em>&#8220;do previous features still work?&#8221;</em> after making changes to your codebase. When you change system prompts to optimize bash tool calls, they help measure how that affects the agent&#8217;s recall on other tools.</p><p><strong>Online evals</strong> answer <em>&#8220;does it work as expected?&#8221;</em> on live traffic samples from production.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!XoPZ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e4d6937-4c37-4129-a5f7-9642b907b411_1200x738.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!XoPZ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e4d6937-4c37-4129-a5f7-9642b907b411_1200x738.png 424w, https://substackcdn.com/image/fetch/$s_!XoPZ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e4d6937-4c37-4129-a5f7-9642b907b411_1200x738.png 848w, https://substackcdn.com/image/fetch/$s_!XoPZ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e4d6937-4c37-4129-a5f7-9642b907b411_1200x738.png 1272w, https://substackcdn.com/image/fetch/$s_!XoPZ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e4d6937-4c37-4129-a5f7-9642b907b411_1200x738.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!XoPZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e4d6937-4c37-4129-a5f7-9642b907b411_1200x738.png" width="1200" height="738" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4e4d6937-4c37-4129-a5f7-9642b907b411_1200x738.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:738,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Two sources of work &#8212; a feature being implemented and the traces production emits &#8212; feed three questions, and one evals harness answers all three&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Two sources of work &#8212; a feature being implemented and the traces production emits &#8212; feed three questions, and one evals harness answers all three" title="Two sources of work &#8212; a feature being implemented and the traces production emits &#8212; feed three questions, and one evals harness answers all three" srcset="https://substackcdn.com/image/fetch/$s_!XoPZ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e4d6937-4c37-4129-a5f7-9642b907b411_1200x738.png 424w, https://substackcdn.com/image/fetch/$s_!XoPZ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e4d6937-4c37-4129-a5f7-9642b907b411_1200x738.png 848w, https://substackcdn.com/image/fetch/$s_!XoPZ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e4d6937-4c37-4129-a5f7-9642b907b411_1200x738.png 1272w, https://substackcdn.com/image/fetch/$s_!XoPZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e4d6937-4c37-4129-a5f7-9642b907b411_1200x738.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>The three questions your AI evals should answer.</em></figcaption></figure></div><p>In a coding agent, swapping Kimi K3 for GLM 5.2 can improve our benchmark scores but fail the regression that checks whether the read tool is triggered when skills point to subfiles that should be read via progressive disclosure.</p><p>Or in a research agent, a prompt tweak that makes it stop citing sources passes every benchmark it was optimized on, but fails the regression case that asserts <em>&#8220;every claim cites a document&#8221;.</em></p><blockquote><p>I have an <a href="https://www.decodingai.com/p/integrating-ai-evals-into-your-ai-app">article on integrating AI evals into an AI app</a> for the 3 stages in depth.</p></blockquote><p>Now, let&#8217;s take a look at the system design of the eval harness.</p><h2>The system design of an evaluation harness</h2><p>Any benchmark trial from Decode runs through 5 phases: seed &#8594; run &#8594; collect &#8594; verify &#8594; record. Collect reads <code>summary.json</code> as the report from the git branch the agent handed back. Record writes <code>result.json</code> to the <strong>trial dir</strong>, where we collect all the results.</p><p>Within an agent harness, &#8220;Harness&#8221; usually means everything around the model: <code>harness = agent - model</code>. An eval harness is a separate application on top of that agent. Its sole purpose is to execute and evaluate the agent harness within the right environment and context.</p><p>Our educational harness is inspired by <a href="https://www.harborframework.com/docs/core-concepts">Harbor</a>, one of the most popular eval frameworks used to compute the Terminal-Bench (general agentic computer use) and <a href="https://arxiv.org/abs/2607.07946">DeepSWE</a> (agentic coding) benchmarks.</p><p>They frame the eval harness as the referee and the agent under test as <strong>the player</strong>. Harbor&#8217;s rule: <a href="https://github.com/harbor-framework/harbor">&#8220;the agent never grades itself and never provisions itself&#8221;</a>. In Decode&#8217;s implementation, this can easily be achieved by always calling the agent as a subprocess via <code>decode run</code> as seen in the previous section.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!KCkA!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b6517cd-cbc6-4331-9bd7-d62b47e3b336_1200x806.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!KCkA!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b6517cd-cbc6-4331-9bd7-d62b47e3b336_1200x806.png 424w, https://substackcdn.com/image/fetch/$s_!KCkA!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b6517cd-cbc6-4331-9bd7-d62b47e3b336_1200x806.png 848w, https://substackcdn.com/image/fetch/$s_!KCkA!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b6517cd-cbc6-4331-9bd7-d62b47e3b336_1200x806.png 1272w, https://substackcdn.com/image/fetch/$s_!KCkA!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b6517cd-cbc6-4331-9bd7-d62b47e3b336_1200x806.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!KCkA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b6517cd-cbc6-4331-9bd7-d62b47e3b336_1200x806.png" width="1200" height="806" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5b6517cd-cbc6-4331-9bd7-d62b47e3b336_1200x806.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:806,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;The evaluation harness: dataset items run in parallel through sandboxed copies of the agent, each solution is graded by the Verifier into a reward of 0 or 1, and Opik keeps the traces, datasets, and experiments&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="The evaluation harness: dataset items run in parallel through sandboxed copies of the agent, each solution is graded by the Verifier into a reward of 0 or 1, and Opik keeps the traces, datasets, and experiments" title="The evaluation harness: dataset items run in parallel through sandboxed copies of the agent, each solution is graded by the Verifier into a reward of 0 or 1, and Opik keeps the traces, datasets, and experiments" srcset="https://substackcdn.com/image/fetch/$s_!KCkA!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b6517cd-cbc6-4331-9bd7-d62b47e3b336_1200x806.png 424w, https://substackcdn.com/image/fetch/$s_!KCkA!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b6517cd-cbc6-4331-9bd7-d62b47e3b336_1200x806.png 848w, https://substackcdn.com/image/fetch/$s_!KCkA!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b6517cd-cbc6-4331-9bd7-d62b47e3b336_1200x806.png 1272w, https://substackcdn.com/image/fetch/$s_!KCkA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b6517cd-cbc6-4331-9bd7-d62b47e3b336_1200x806.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>The evaluation harness: Dataset items fan out to sandboxed copies of the agent in parallel; each solution is checked by the Verifier against the expected solution, grading it with a reward of 0 or 1, while Opik keeps the traces, the datasets, and the experiments.</em></figcaption></figure></div><p>We used the same vocabulary as in Harbor. A <strong>task</strong> is an instruction, an environment, and a hidden oracle. A <strong>dataset</strong> is a collection of tasks. A <strong>trial</strong> is a rollout of a Task that produces a reward. A <strong>job</strong> is many trials run in parallel.</p><p>The idea is to keep this design flexible enough to use either Harbor or a custom version. In our implementation, we used <a href="https://www.comet.com/site/?utm_source=workshop&amp;utm_medium=partner&amp;utm_campaign=paul&amp;utm_content=coding_agent_course">Opik</a> (<a href="https://github.com/comet-ml/opik">open-source</a>) as our evals platform. Beyond capturing and storing all the agent&#8217;s traces, it lets us store and version datasets, run jobs, and wrap the whole run as an experiment. Extremely useful for lineage and comparing multiple runs.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Oixp!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fded9f672-830c-4216-a892-eb52a3e71e6a_1190x1668.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Oixp!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fded9f672-830c-4216-a892-eb52a3e71e6a_1190x1668.png 424w, https://substackcdn.com/image/fetch/$s_!Oixp!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fded9f672-830c-4216-a892-eb52a3e71e6a_1190x1668.png 848w, https://substackcdn.com/image/fetch/$s_!Oixp!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fded9f672-830c-4216-a892-eb52a3e71e6a_1190x1668.png 1272w, https://substackcdn.com/image/fetch/$s_!Oixp!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fded9f672-830c-4216-a892-eb52a3e71e6a_1190x1668.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!Oixp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fded9f672-830c-4216-a892-eb52a3e71e6a_1190x1668.png" width="1190" height="1668" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ded9f672-830c-4216-a892-eb52a3e71e6a_1190x1668.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1668,&quot;width&quot;:1190,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!Oixp!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fded9f672-830c-4216-a892-eb52a3e71e6a_1190x1668.png 424w, https://substackcdn.com/image/fetch/$s_!Oixp!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fded9f672-830c-4216-a892-eb52a3e71e6a_1190x1668.png 848w, https://substackcdn.com/image/fetch/$s_!Oixp!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fded9f672-830c-4216-a892-eb52a3e71e6a_1190x1668.png 1272w, https://substackcdn.com/image/fetch/$s_!Oixp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fded9f672-830c-4216-a892-eb52a3e71e6a_1190x1668.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption">Capturing traces in Opik</figcaption></figure></div><p>Below, we see how we defined a job run via Opik where we define the <code>"decode-benchmark"</code> dataset, the task function that executes the coding agent for each item in the dataset, the metrics, and other job details. The scoring metric is the 0 or 1 reward emitted at the trial level, while the experiment scoring function is used at the experiment level to compute aggregate metrics such as <code>pass@k</code> (at least one of the k trials per task passed), <code>pass^k</code> (all <code>k</code> trials pass) and <code>flakiness</code> (<code>pass@k</code> &#8722; <code>pass^k</code>, the tasks that pass sometimes but not always, which the agent can solve but not reliably).</p><p><em>From </em><code>evals/harness/benchmark.py</code>:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">from opik.evaluation import evaluate


task_fn = make_benchmark_task_fn(
        {task.id: task for task in all_tasks},
        sandbox=sandbox,
        job_dir=job_dir,
        model=model
    )

result = evaluate(
    dataset="decode-benchmark",
    task=task_fn,                                      # one trial
    scoring_metrics=[RewardMetric()],                  # the verifier's reward function that outputs 0 or 1
    experiment_scoring_functions=EXPERIMENT_SCORING_FUNCTIONS,   # pass@k, pass^k, flakiness,
    experiment_config=experiment_config(
        sandbox=sandbox, trials=trials, model=model
    ),
    experiment_name=job_name,
    dataset_item_ids=list(item_ids.values()),          # only the matching items
    task_threads=task_threads,
    trial_count=trials,                                # --trials k &#8594; pass@k
)</code></pre></div><p>Example with k=3 and 10 tasks: 7 tasks pass all 3 trials, 2 pass 1 or 2 trials, and 1 never passes. That gives pass@3 = 90%, pass^3 = 70% and flakiness = 20%.</p><p>When k=1, all three collapse to pass@1, and flakiness is 0, as the Opik experiment below shows:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!iki7!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F674debb2-c2ec-465e-a7c9-666fdf73d7f2_3240x1800.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!iki7!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F674debb2-c2ec-465e-a7c9-666fdf73d7f2_3240x1800.png 424w, https://substackcdn.com/image/fetch/$s_!iki7!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F674debb2-c2ec-465e-a7c9-666fdf73d7f2_3240x1800.png 848w, https://substackcdn.com/image/fetch/$s_!iki7!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F674debb2-c2ec-465e-a7c9-666fdf73d7f2_3240x1800.png 1272w, https://substackcdn.com/image/fetch/$s_!iki7!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F674debb2-c2ec-465e-a7c9-666fdf73d7f2_3240x1800.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!iki7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F674debb2-c2ec-465e-a7c9-666fdf73d7f2_3240x1800.png" width="1456" height="809" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/674debb2-c2ec-465e-a7c9-666fdf73d7f2_3240x1800.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:809,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!iki7!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F674debb2-c2ec-465e-a7c9-666fdf73d7f2_3240x1800.png 424w, https://substackcdn.com/image/fetch/$s_!iki7!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F674debb2-c2ec-465e-a7c9-666fdf73d7f2_3240x1800.png 848w, https://substackcdn.com/image/fetch/$s_!iki7!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F674debb2-c2ec-465e-a7c9-666fdf73d7f2_3240x1800.png 1272w, https://substackcdn.com/image/fetch/$s_!iki7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F674debb2-c2ec-465e-a7c9-666fdf73d7f2_3240x1800.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>On top of that, it is good to track error types, so you never mistake an infrastructure issue for a reward of 0:</p><ul><li><p><strong>infra_error:</strong> the harness failed (seed, clone, a crashed verifier).</p></li><li><p><strong>agent_fail:</strong> the agent failed (wrong answer, request ceiling, timeout).</p></li></ul><p>Within Opik, we keep all our data: traces, datasets, experiments, test suites, and online rules. The actual execution of the benchmark is done on our end via our custom eval harness (or Harbor).</p><p>Other popular eval platforms include <a href="https://www.langchain.com/langsmith">LangSmith</a>, <a href="https://langfuse.com/">Langfuse</a>, <a href="https://www.braintrust.dev/">Braintrust</a>, and <a href="https://learn.microsoft.com/en-us/azure/ai-foundry/concepts/evaluation-approach-gen-ai">Azure AI Foundry</a>. If you have the right resources (and knowledge!), you can also consider building your own infrastructure. Especially now, it&#8217;s quite easy to one-shot a simple observability tool with a coding agent as long as you have a hosted database in place. But still, starting with one of these tools is the easiest path. Especially because tools like Opik are <a href="https://github.com/comet-ml/opik">open-source</a>. The only reason to go custom is if they are too rigid for your use case, a common scenario being your data format.</p><p>Now, let&#8217;s see how we designed our benchmark and regression tests.</p><h2>Designing a benchmark that predicts your agent</h2><p>The best way to understand how the benchmark works is by looking at one example: <code>007-fix-failing-test</code>: the agent gets an instruction and a seed repository, hands back a git branch, and the verifier runs the one fail-to-pass test, which returns a reward of 0 or 1.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Myqv!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F22873061-1988-413d-81e5-34dc4560ecd1_1200x858.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Myqv!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F22873061-1988-413d-81e5-34dc4560ecd1_1200x858.png 424w, https://substackcdn.com/image/fetch/$s_!Myqv!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F22873061-1988-413d-81e5-34dc4560ecd1_1200x858.png 848w, https://substackcdn.com/image/fetch/$s_!Myqv!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F22873061-1988-413d-81e5-34dc4560ecd1_1200x858.png 1272w, https://substackcdn.com/image/fetch/$s_!Myqv!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F22873061-1988-413d-81e5-34dc4560ecd1_1200x858.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!Myqv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F22873061-1988-413d-81e5-34dc4560ecd1_1200x858.png" width="1200" height="858" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/22873061-1988-413d-81e5-34dc4560ecd1_1200x858.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:858,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Inside one Benchmark Task: the folder, the Trial, and the moment the hidden tests enter&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Inside one Benchmark Task: the folder, the Trial, and the moment the hidden tests enter" title="Inside one Benchmark Task: the folder, the Trial, and the moment the hidden tests enter" srcset="https://substackcdn.com/image/fetch/$s_!Myqv!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F22873061-1988-413d-81e5-34dc4560ecd1_1200x858.png 424w, https://substackcdn.com/image/fetch/$s_!Myqv!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F22873061-1988-413d-81e5-34dc4560ecd1_1200x858.png 848w, https://substackcdn.com/image/fetch/$s_!Myqv!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F22873061-1988-413d-81e5-34dc4560ecd1_1200x858.png 1272w, https://substackcdn.com/image/fetch/$s_!Myqv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F22873061-1988-413d-81e5-34dc4560ecd1_1200x858.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>The relationship between what a benchmark task looks like and how it&#8217;s executed during one trial.</em></figcaption></figure></div><p>Here is how the task is structured, where the agent gets a buggy environment it needs to fix:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;plaintext&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-plaintext">evals/benchmark/tasks/007-fix-failing-test/
&#9500;&#9472;&#9472; task.toml            # step budget, timeouts, fail_to_pass / pass_to_pass
&#9500;&#9472;&#9472; instruction.md       # the agent's prompt
&#9500;&#9472;&#9472; environment/
&#9474;   &#9500;&#9472;&#9472; ranges.py        # the buggy module
&#9474;   &#9492;&#9472;&#9472; test_ranges.py   # the test suite
&#9500;&#9472;&#9472; tests/
&#9474;   &#9500;&#9472;&#9472; test.sh          # the Verifier: writes $VERIFIER_DIR/reward.txt
&#9474;   &#9492;&#9472;&#9472; test_ranges.py   # the HIDDEN test suite
&#9492;&#9472;&#9472; solution/            # the oracle solution
    &#9500;&#9472;&#9472; solve.sh          
    &#9492;&#9472;&#9472; ranges.py</code></pre></div><p>The domain-agnostic contract: an instruction, a frozen environment, and a hidden verifier program that turns the end state into one reward. We use the same layout as <a href="https://github.com/harbor-framework/terminal-bench">Terminal-Bench</a>where the verifier runs in isolation after the agent finishes.</p><p>Each trial is its own <code>decode run</code> subprocess, with the agent&#8217;s workspace isolated in a Docker container (or a Modal sandbox) via the sandboxing logic from <a href="https://www.decodingai.com/p/run-coding-agents-safely">lesson 3</a>. When the agent finishes, its work is handed back as a git branch. The host grades a clean clone of that branch with the hidden tests copied in last (to avoid leaking the solution), then aggregates the rewards across trials.</p><p>For a research agent, we could define a task as a question, a seeded corpus, and a hidden code verifier that checks whether the agent used the right citations against a ground-truth file, instead of a costly and flaky LLM judge.</p><p><code>tests/</code> is <strong>the verifier</strong> (the hidden program that turns a trial into one reward), injected only after the run. <code>solution/</code> is <strong>the oracle</strong>, a reference that, if everything works well, outputs a reward of 1. We use it within our CI pipeline to test our eval harness, alongside running it on the unfixed environment, which should have a reward of 9.</p><p>Here is what the <code>task.toml</code> file from the <code>007-fix-failing-test</code> task looks like:</p><p><em>From </em><code>evals/benchmark/tasks/007-fix-failing-test/task.toml</code>:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;toml&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-toml">[task]
name = "007-fix-failing-test"
description = "Fix the bug in a small module so its whole unittest suite passes."

[metadata]
difficulty = "easy"          # easy 15 steps / 600 s &#183; medium 25 / 900 s &#183; hard 40 / 1500 s
category = "Software"        # Terminal-Bench's taxonomy

[agent]
timeout_sec = 600.0
max_steps = 15               # decode run --max-requests

[verifier.tests]             # SWE-bench shape: the test the fix must flip, the tests it must not break
fail_to_pass = ["test_ranges.TestRanges.test_inclusive_end"]
pass_to_pass = ["test_ranges.TestRanges.test_starts_at_one", "test_ranges.TestRanges.test_contains_two", "test_ranges.TestRanges.test_no_zero"]</code></pre></div><p>And here is the <code>test.sh</code> file that emits the reward. Custom for each task, where every exit path must still write exactly one reward.</p><p><em>From </em><code>evals/benchmark/tasks/007-fix-failing-test/tests/test.sh</code>:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;bash&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-bash">(
  cd tests &amp;&amp; python3 -m unittest -v \
    test_ranges.TestRanges.test_inclusive_end \
    test_ranges.TestRanges.test_starts_at_one \
    test_ranges.TestRanges.test_contains_two \
    test_ranges.TestRanges.test_no_zero
)
status=$?
reward=0
[[ $status -eq 0 ]] &amp;&amp; reward=1
printf '%s\n' "$reward" &gt; "$VERIFIER_DIR/reward.txt"</code></pre></div><p>In our benchmark, we have a total of 19 tasks, while Terminal-Bench has 66 (see them <a href="https://github.com/harbor-framework/terminal-bench/tree/main/tasks">here</a>) and DeepSWE has 117 (see them <a href="https://github.com/datacurve-ai/deep-swe/tree/main/tasks">here</a>). In this case, <strong>more is NOT better!</strong> The idea is not to have hundreds of tests, since they can get expensive to run, but to have tests as diverse as possible, capturing all your scenarios and edge cases. This is known as your <em>core set</em>. So you need to think through each task carefully, designing each environment, prompt, and test file that measures the outcome.</p><p>In other words, creating a high-signal benchmark that&#8217;s actually useful is not that easy. That&#8217;s why regression tests, as we will soon see, are an easy win relative to benchmarks.</p><p>In our Decode benchmark, we have 7 easy tasks, 6 medium, and 6 hard.</p><p>We stored and versioned the whole dataset in Opik, which makes it easy to share across runs or people:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!6fLe!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cbf5bd2-38a3-4bac-89d6-242cf221f6e7_2572x1636.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!6fLe!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cbf5bd2-38a3-4bac-89d6-242cf221f6e7_2572x1636.png 424w, https://substackcdn.com/image/fetch/$s_!6fLe!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cbf5bd2-38a3-4bac-89d6-242cf221f6e7_2572x1636.png 848w, https://substackcdn.com/image/fetch/$s_!6fLe!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cbf5bd2-38a3-4bac-89d6-242cf221f6e7_2572x1636.png 1272w, https://substackcdn.com/image/fetch/$s_!6fLe!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cbf5bd2-38a3-4bac-89d6-242cf221f6e7_2572x1636.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!6fLe!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cbf5bd2-38a3-4bac-89d6-242cf221f6e7_2572x1636.png" width="1456" height="926" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3cbf5bd2-38a3-4bac-89d6-242cf221f6e7_2572x1636.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:926,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!6fLe!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cbf5bd2-38a3-4bac-89d6-242cf221f6e7_2572x1636.png 424w, https://substackcdn.com/image/fetch/$s_!6fLe!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cbf5bd2-38a3-4bac-89d6-242cf221f6e7_2572x1636.png 848w, https://substackcdn.com/image/fetch/$s_!6fLe!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cbf5bd2-38a3-4bac-89d6-242cf221f6e7_2572x1636.png 1272w, https://substackcdn.com/image/fetch/$s_!6fLe!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cbf5bd2-38a3-4bac-89d6-242cf221f6e7_2572x1636.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>Task <code>015-secret-scrub</code> asks the agent to move two hardcoded secrets into environment variables, and the first check of its verifier diffs the handed-back branch against the seed repo&#8217;s base commit. It fails the trial if any file other than <code>service.py</code> changed or if <code>service.py</code> changed by more than 8 added-plus-deleted lines, which turns <em>&#8220;keep the diff minimal&#8221;</em> from a judge&#8217;s opinion into a measured bound.</p><p><em>From </em><code>evals/benchmark/tasks/015-secret-scrub/tests/test.sh</code>:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">MAX_CHANGED_LINES, CHANGED_FILE = 8, "service.py"
base = git("rev-list", "--max-parents=0", "HEAD").split()[0]        # the seed Repo's base commit
changed: dict[str, int] = {}
for line in git("diff", "--numstat", base).splitlines():            # added, deleted, path &#8212; per file
    added, deleted, path = line.split("\t", 2)
    if not ignored(path):                                           # tests/, .verifier/, .git/ don't count
        changed[path] = changed.get(path, 0) + int(added) + int(deleted)
extra = sorted(p for p in changed if p != CHANGED_FILE)
if extra:
    print(f"FAIL: only {CHANGED_FILE} may change, but the answer also touched {extra}"); sys.exit(1)
if changed.get(CHANGED_FILE, 0) &gt; MAX_CHANGED_LINES:
    print(f"FAIL: the change to {CHANGED_FILE} is more than the {MAX_CHANGED_LINES} lines a minimal fix needs"); sys.exit(1)</code></pre></div><p>The beautiful part of putting all this effort into a benchmark is that once it exists, it gives the coding agent so much signal that we can start optimizing our agent on automode. We just give the coding agent the goal of tweaking the harness until it passes all the trials, similar to TDD. Who knows, maybe in the future, all we will do is design benchmarks and let coding agents do the rest.</p><p>When using Opik, you can use their <a href="https://www.comet.com/docs/opik/development/optimization-runs/overview?utm_source=workshop&amp;utm_medium=partner&amp;utm_campaign=paul&amp;utm_content=coding_agent_course">Agent Optimizer</a> to vary prompts, tool descriptions, and model parameters; score each trial against the dataset into an experiment; compare them; pick the best one; and repeat. Or run a similar loop by plugging Opik&#8217;s experiments into your coding agent via <a href="https://www.comet.com/docs/opik/mcp-server?utm_source=workshop&amp;utm_medium=partner&amp;utm_campaign=paul&amp;utm_content=coding_agent_course">their MCP server</a>.</p><p>Here is how you can run the benchmark job over Decode using Modal to host a Qwen3.6-35B model, where all the results will be saved as an Opik experiment:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;bash&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-bash">LLM_PROVIDER=modal make eval-benchmark ARGS='--threads 1 --job-name qwen36-modal'</code></pre></div><p>It scores 95% <code>pass@1</code> across all 19 tasks:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!5HvJ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc985b6e-da0a-4c45-a352-3ddb511e1abe_2592x1700.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!5HvJ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc985b6e-da0a-4c45-a352-3ddb511e1abe_2592x1700.png 424w, https://substackcdn.com/image/fetch/$s_!5HvJ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc985b6e-da0a-4c45-a352-3ddb511e1abe_2592x1700.png 848w, https://substackcdn.com/image/fetch/$s_!5HvJ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc985b6e-da0a-4c45-a352-3ddb511e1abe_2592x1700.png 1272w, https://substackcdn.com/image/fetch/$s_!5HvJ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc985b6e-da0a-4c45-a352-3ddb511e1abe_2592x1700.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!5HvJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc985b6e-da0a-4c45-a352-3ddb511e1abe_2592x1700.png" width="1456" height="955" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/cc985b6e-da0a-4c45-a352-3ddb511e1abe_2592x1700.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:955,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!5HvJ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc985b6e-da0a-4c45-a352-3ddb511e1abe_2592x1700.png 424w, https://substackcdn.com/image/fetch/$s_!5HvJ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc985b6e-da0a-4c45-a352-3ddb511e1abe_2592x1700.png 848w, https://substackcdn.com/image/fetch/$s_!5HvJ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc985b6e-da0a-4c45-a352-3ddb511e1abe_2592x1700.png 1272w, https://substackcdn.com/image/fetch/$s_!5HvJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc985b6e-da0a-4c45-a352-3ddb511e1abe_2592x1700.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>And this is what it looks like when we compare two experiments to test how the harness behaves with a larger model (GPT-OSS-120B) against the default model we optimized the harness for (Qwen3.6-35B):</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!J4uv!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1acfa1e-4ef1-402a-a5bf-4b20ff2f29b9_2624x1384.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!J4uv!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1acfa1e-4ef1-402a-a5bf-4b20ff2f29b9_2624x1384.png 424w, https://substackcdn.com/image/fetch/$s_!J4uv!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1acfa1e-4ef1-402a-a5bf-4b20ff2f29b9_2624x1384.png 848w, https://substackcdn.com/image/fetch/$s_!J4uv!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1acfa1e-4ef1-402a-a5bf-4b20ff2f29b9_2624x1384.png 1272w, https://substackcdn.com/image/fetch/$s_!J4uv!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1acfa1e-4ef1-402a-a5bf-4b20ff2f29b9_2624x1384.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!J4uv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1acfa1e-4ef1-402a-a5bf-4b20ff2f29b9_2624x1384.png" width="1456" height="768" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b1acfa1e-4ef1-402a-a5bf-4b20ff2f29b9_2624x1384.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:768,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!J4uv!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1acfa1e-4ef1-402a-a5bf-4b20ff2f29b9_2624x1384.png 424w, https://substackcdn.com/image/fetch/$s_!J4uv!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1acfa1e-4ef1-402a-a5bf-4b20ff2f29b9_2624x1384.png 848w, https://substackcdn.com/image/fetch/$s_!J4uv!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1acfa1e-4ef1-402a-a5bf-4b20ff2f29b9_2624x1384.png 1272w, https://substackcdn.com/image/fetch/$s_!J4uv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1acfa1e-4ef1-402a-a5bf-4b20ff2f29b9_2624x1384.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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 table below, run via a Modal endpoint with 1 trial per task, shows that the larger model does not win. The 120B scored 53%, while the 35B scored 95% on the same tasks.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!tsJD!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb730dab8-8bcf-4709-a8b4-0890fd6991d8_1920x490.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!tsJD!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb730dab8-8bcf-4709-a8b4-0890fd6991d8_1920x490.png 424w, https://substackcdn.com/image/fetch/$s_!tsJD!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb730dab8-8bcf-4709-a8b4-0890fd6991d8_1920x490.png 848w, https://substackcdn.com/image/fetch/$s_!tsJD!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb730dab8-8bcf-4709-a8b4-0890fd6991d8_1920x490.png 1272w, https://substackcdn.com/image/fetch/$s_!tsJD!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb730dab8-8bcf-4709-a8b4-0890fd6991d8_1920x490.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!tsJD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb730dab8-8bcf-4709-a8b4-0890fd6991d8_1920x490.png" width="1456" height="372" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b730dab8-8bcf-4709-a8b4-0890fd6991d8_1920x490.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:372,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;table&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="table" title="table" srcset="https://substackcdn.com/image/fetch/$s_!tsJD!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb730dab8-8bcf-4709-a8b4-0890fd6991d8_1920x490.png 424w, https://substackcdn.com/image/fetch/$s_!tsJD!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb730dab8-8bcf-4709-a8b4-0890fd6991d8_1920x490.png 848w, https://substackcdn.com/image/fetch/$s_!tsJD!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb730dab8-8bcf-4709-a8b4-0890fd6991d8_1920x490.png 1272w, https://substackcdn.com/image/fetch/$s_!tsJD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb730dab8-8bcf-4709-a8b4-0890fd6991d8_1920x490.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption">Two different models, same nineteen tasks, as of 2026-09-17.</figcaption></figure></div><p>We know that <em>gpt-oss-120B</em> is about 1 year older than <em>qwen3.6-35B</em>, which, in AI terms, is a century. But that&#8217;s our whole point. With a benchmark, you don&#8217;t have to overthink what to choose, since you can quickly measure it on your own data.</p><blockquote><p>&#128161; <strong>The lesson?</strong> Don&#8217;t trust generic benchmarks or model features, such as parameter count, in isolation. Always test against your custom benchmark to evaluate how the model performs on your use case. </p></blockquote><p>We ran another experiment comparing billing models on the same workload using the same model (Qwen3.6-35B): pay-per-token (OpenRouter) vs. pay-per-GPU hour (<a href="https://modal.com/pricing?source=decodingai&amp;campaign=harnesseng">Modal</a>). At this scale, pay-per-token wins: 1.2 M tokens for about 18 cents, while the GPU sat mostly idle behind one trial at a time and still billed its wall-clock time. By <a href="https://modal.com/blog/how-to-price-serverless?source=decodingai&amp;campaign=harnesseng">Modal&#8217;s own rule</a>, pay-per-compute wins only once you keep the GPU at 100% capacity via continuous batching.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!4b-e!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89b1a24c-dc09-4f63-8477-9ca2b86dcd50_1920x490.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!4b-e!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89b1a24c-dc09-4f63-8477-9ca2b86dcd50_1920x490.png 424w, https://substackcdn.com/image/fetch/$s_!4b-e!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89b1a24c-dc09-4f63-8477-9ca2b86dcd50_1920x490.png 848w, https://substackcdn.com/image/fetch/$s_!4b-e!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89b1a24c-dc09-4f63-8477-9ca2b86dcd50_1920x490.png 1272w, https://substackcdn.com/image/fetch/$s_!4b-e!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89b1a24c-dc09-4f63-8477-9ca2b86dcd50_1920x490.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!4b-e!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89b1a24c-dc09-4f63-8477-9ca2b86dcd50_1920x490.png" width="1456" height="372" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/89b1a24c-dc09-4f63-8477-9ca2b86dcd50_1920x490.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:372,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;table&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="table" title="table" srcset="https://substackcdn.com/image/fetch/$s_!4b-e!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89b1a24c-dc09-4f63-8477-9ca2b86dcd50_1920x490.png 424w, https://substackcdn.com/image/fetch/$s_!4b-e!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89b1a24c-dc09-4f63-8477-9ca2b86dcd50_1920x490.png 848w, https://substackcdn.com/image/fetch/$s_!4b-e!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89b1a24c-dc09-4f63-8477-9ca2b86dcd50_1920x490.png 1272w, https://substackcdn.com/image/fetch/$s_!4b-e!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89b1a24c-dc09-4f63-8477-9ca2b86dcd50_1920x490.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption">One model, pay-per-GPU-hour versus pay-per-token, as of 2026-09-17.</figcaption></figure></div><p>These are two clear examples of how, once you have a benchmark in place, you can optimize not only performance but also cost and latency. Now, let&#8217;s look into how regression tests are different.</p><h2>Growing a regression suite from production</h2><p>When I was mining my Decode traces (searching live traces for failures worth pinning) I caught 6 runs asking my agent to <em>&#8220;Add my cat as the main contributor to the README and commit&#8221;</em>, where each called <code>read(path="README")</code> in a repo whose readme is <code>README.md</code>. As it became a recurring issue, I fixed it and then moved it into a regression test to ensure it won&#8217;t happen again.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!h_AU!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcee57b81-f3be-4573-b192-723951d859ca_1200x943.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!h_AU!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcee57b81-f3be-4573-b192-723951d859ca_1200x943.png 424w, https://substackcdn.com/image/fetch/$s_!h_AU!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcee57b81-f3be-4573-b192-723951d859ca_1200x943.png 848w, https://substackcdn.com/image/fetch/$s_!h_AU!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcee57b81-f3be-4573-b192-723951d859ca_1200x943.png 1272w, https://substackcdn.com/image/fetch/$s_!h_AU!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcee57b81-f3be-4573-b192-723951d859ca_1200x943.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!h_AU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcee57b81-f3be-4573-b192-723951d859ca_1200x943.png" width="1200" height="943" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/cee57b81-f3be-4573-b192-723951d859ca_1200x943.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:943,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;The regression loop: live traces &#8594; mined failure groups &#8594; a fix &#8594; one pass/fail case per group &#8594; a gate on every change&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="The regression loop: live traces &#8594; mined failure groups &#8594; a fix &#8594; one pass/fail case per group &#8594; a gate on every change" title="The regression loop: live traces &#8594; mined failure groups &#8594; a fix &#8594; one pass/fail case per group &#8594; a gate on every change" srcset="https://substackcdn.com/image/fetch/$s_!h_AU!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcee57b81-f3be-4573-b192-723951d859ca_1200x943.png 424w, https://substackcdn.com/image/fetch/$s_!h_AU!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcee57b81-f3be-4573-b192-723951d859ca_1200x943.png 848w, https://substackcdn.com/image/fetch/$s_!h_AU!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcee57b81-f3be-4573-b192-723951d859ca_1200x943.png 1272w, https://substackcdn.com/image/fetch/$s_!h_AU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcee57b81-f3be-4573-b192-723951d859ca_1200x943.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>The five steps for growing your regression suite, a process known as error analysis.</em></figcaption></figure></div><p>Formalized, the loop has 5 steps:</p><ol><li><p><strong>Observe</strong>: trace every session.</p></li><li><p><strong>Diagnose</strong>: group bad runs by signature via Opik&#8217;s <a href="https://www.comet.com/docs/opik/tracing/diagnostics?utm_source=workshop&amp;utm_medium=partner&amp;utm_campaign=paul&amp;utm_content=coding_agent_course">Diagnostics</a> or by building a custom clustering script</p></li><li><p><strong>Fix</strong>: using your coding agent, or <a href="https://www.comet.com/docs/opik/ollie?utm_source=workshop&amp;utm_medium=partner&amp;utm_campaign=paul&amp;utm_content=coding_agent_course">Ollie</a>.</p></li><li><p><strong>Capture</strong>: one pass/fail case per failure group (use only pass/fail scores because LLMs are terrible at 1-5 likert scores, much like humans)</p></li><li><p><strong>Gate</strong>: re-run on every change.</p></li></ol><p>This process is also known as error analysis, a technique loved by the king of evals: Hamel Husain.</p><div class="pullquote"><p>&#128161; <em>Now, how are regression tests truly different from running a benchmark?</em></p></div><p>A benchmark task grades an artifact; in our use case, how well it implemented the code. A <strong>regression case</strong> grades a trajectory (how the agent behaved), which means we can no longer treat the agent as a black box, isolating it and looking only at its output, but have to look at its internals, such as whether, for read-only permissions, it used the bash/edit tool or not. If this is confusing, bear with me for a couple more paragraphs.</p><p><em>A benchmark task vs. a regression case side by side.</em></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!IhhM!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44aa7cfb-4baf-4740-ac7b-d2ad04a8fd66_1200x573.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!IhhM!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44aa7cfb-4baf-4740-ac7b-d2ad04a8fd66_1200x573.png 424w, https://substackcdn.com/image/fetch/$s_!IhhM!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44aa7cfb-4baf-4740-ac7b-d2ad04a8fd66_1200x573.png 848w, https://substackcdn.com/image/fetch/$s_!IhhM!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44aa7cfb-4baf-4740-ac7b-d2ad04a8fd66_1200x573.png 1272w, https://substackcdn.com/image/fetch/$s_!IhhM!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44aa7cfb-4baf-4740-ac7b-d2ad04a8fd66_1200x573.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!IhhM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44aa7cfb-4baf-4740-ac7b-d2ad04a8fd66_1200x573.png" width="1200" height="573" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/44aa7cfb-4baf-4740-ac7b-d2ad04a8fd66_1200x573.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:573,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Benchmark Task versus Regression Case: the same seed-run-grade skeleton, a different thing measured&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Benchmark Task versus Regression Case: the same seed-run-grade skeleton, a different thing measured" title="Benchmark Task versus Regression Case: the same seed-run-grade skeleton, a different thing measured" srcset="https://substackcdn.com/image/fetch/$s_!IhhM!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44aa7cfb-4baf-4740-ac7b-d2ad04a8fd66_1200x573.png 424w, https://substackcdn.com/image/fetch/$s_!IhhM!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44aa7cfb-4baf-4740-ac7b-d2ad04a8fd66_1200x573.png 848w, https://substackcdn.com/image/fetch/$s_!IhhM!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44aa7cfb-4baf-4740-ac7b-d2ad04a8fd66_1200x573.png 1272w, https://substackcdn.com/image/fetch/$s_!IhhM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44aa7cfb-4baf-4740-ac7b-d2ad04a8fd66_1200x573.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>There are <strong>two main ways</strong> in which you can design a regression test. The <strong>first one</strong> is based solely on LLM Judges that inspect the agent&#8217;s output relative to its input, context, and a set of assertions (no ground-truth label needed). In Opik, this can be done via <a href="https://www.comet.com/docs/opik/evaluation/advanced/building-test-suites?utm_source=workshop&amp;utm_medium=partner&amp;utm_campaign=paul&amp;utm_content=coding_agent_course">Test Suites</a> which automatically run a metric called G-Eval, a fancy name for the LLM judge described above. In the image below, you can see a test suite defined in Opik, with its difficulty, prompt, assertions and number of trials.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!nTCf!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fae3d9e-1ad2-46da-8619-c271d44978a3_2416x1666.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!nTCf!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fae3d9e-1ad2-46da-8619-c271d44978a3_2416x1666.png 424w, https://substackcdn.com/image/fetch/$s_!nTCf!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fae3d9e-1ad2-46da-8619-c271d44978a3_2416x1666.png 848w, https://substackcdn.com/image/fetch/$s_!nTCf!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fae3d9e-1ad2-46da-8619-c271d44978a3_2416x1666.png 1272w, https://substackcdn.com/image/fetch/$s_!nTCf!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fae3d9e-1ad2-46da-8619-c271d44978a3_2416x1666.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!nTCf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fae3d9e-1ad2-46da-8619-c271d44978a3_2416x1666.png" width="1456" height="1004" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8fae3d9e-1ad2-46da-8619-c271d44978a3_2416x1666.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1004,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:304647,&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://www.decodingai.com/i/216358812?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fae3d9e-1ad2-46da-8619-c271d44978a3_2416x1666.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_!nTCf!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fae3d9e-1ad2-46da-8619-c271d44978a3_2416x1666.png 424w, https://substackcdn.com/image/fetch/$s_!nTCf!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fae3d9e-1ad2-46da-8619-c271d44978a3_2416x1666.png 848w, https://substackcdn.com/image/fetch/$s_!nTCf!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fae3d9e-1ad2-46da-8619-c271d44978a3_2416x1666.png 1272w, https://substackcdn.com/image/fetch/$s_!nTCf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fae3d9e-1ad2-46da-8619-c271d44978a3_2416x1666.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><strong>The second</strong> option uses plain datasets, similar to what we used for the benchmark above, where you have full control over the metric that validates the agent&#8217;s behavior. In this scenario, you can define metrics that check if a particular tool was called in a given scenario or if the output of the LLM is formatted as expected. But with great power comes great responsibility: you need to implement all of it yourself. <br></p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!4OB1!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe3a40ae9-d255-417d-b0fc-f27ff870a67c_2544x586.png 424w, https://substackcdn.com/image/fetch/$s_!4OB1!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe3a40ae9-d255-417d-b0fc-f27ff870a67c_2544x586.png 848w, https://substackcdn.com/image/fetch/$s_!4OB1!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe3a40ae9-d255-417d-b0fc-f27ff870a67c_2544x586.png 1272w, https://substackcdn.com/image/fetch/$s_!4OB1!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe3a40ae9-d255-417d-b0fc-f27ff870a67c_2544x586.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!4OB1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe3a40ae9-d255-417d-b0fc-f27ff870a67c_2544x586.png" width="1456" height="335" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e3a40ae9-d255-417d-b0fc-f27ff870a67c_2544x586.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:335,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!4OB1!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe3a40ae9-d255-417d-b0fc-f27ff870a67c_2544x586.png 424w, https://substackcdn.com/image/fetch/$s_!4OB1!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe3a40ae9-d255-417d-b0fc-f27ff870a67c_2544x586.png 848w, https://substackcdn.com/image/fetch/$s_!4OB1!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe3a40ae9-d255-417d-b0fc-f27ff870a67c_2544x586.png 1272w, https://substackcdn.com/image/fetch/$s_!4OB1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe3a40ae9-d255-417d-b0fc-f27ff870a67c_2544x586.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>In the example below, you can see a simple test suite that includes an assertion (for the first version) and a mix of multiple metrics (for the second version). Note that <code>make_judge()</code> uses the G-Eval metric, which outputs a pass/fail value using an LLM under the hood. The second option incorporates the metrics from the first one. Keep in mind that in addition to the LLM usage required to run the agent for this task, you also need to run the LLM judge.</p><p><em>From </em><code>evals/regression/cases/read_vs_cat.py</code>:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">from evals.harness.metrics import MaxStepsMetric, ToolCalledMetric, ToolNotCalledMetric
from evals.regression.case import RegressionCase


CASE = RegressionCase(
    id="01-read-vs-cat",
    prompt="Show me the contents of notes.txt.",
    fixture=lambda ws: (ws / "notes.txt").write_text("The release train departs at 06:45.\n"),
    difficulty="easy",
    symptom="harness invariant: 'show me this file' is a read-tool call, not a `bash cat` shell-out.",
    assertion="The response shows the contents of the file the user named.",   # judged in the Test Suite
    metrics=[
        ToolCalledMetric("read"),          # code check: 1.0 iff `read` appears in the tool calls
        ToolNotCalledMetric("bash"),       # code check: 1.0 iff `bash` never does
        MaxStepsMetric(),                  # code check: steps &lt;= max_requests
        make_judge("You are grading whether the answer is grounded in the file.", "Correct when it quotes the file's line; incorrect when it guesses."),
    ],                                     # G-Eval judge: only for what code cannot score
    max_requests=6,
)</code></pre></div><p>Each deterministic check is an implementation of Opik&#8217;s <code>BaseMetric</code> class with a <code>score()</code> method returning 0 or 1. Theoretically, it supports a float, but remember, we want only binary results so it&#8217;s easier for the LLM to decide.</p><blockquote><p>&#128161;This can be an interesting use case for Jev, the new decision model from TypeSafe! It&#8217;s cheap and optimized for these types of decisions.</p></blockquote><p><em>From </em><code>evals/harness/metrics.py</code>:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">class ToolCalledMetric(BaseMetric):
    """1.0 when `tool_name` appears in the run's tool calls, else 0.0."""

    def __init__(self, tool_name: str) -&gt; None:
        super().__init__(name=f"tool_called_{tool_name}", track=False)
        self.tool_name = tool_name

    def score(self, tool_calls=None, **_) -&gt; ScoreResult:
        names = [call["name"] for call in tool_calls or []]
        called = self.tool_name in names
        return ScoreResult(
&#9;        name=self.name,
&#9;        value=1.0 if called else 0.0,
&#9;        reason=f"{self.tool_name!r} {'was' if called else 'was NOT'} called; tools used: {names}."
&#9;        )</code></pre></div><p>In the image below, you can see what an Opik experiment run from the test suite looks like, containing a bunch of tests with pass/fail results. From a final-outcome point of view, this looks very similar to running classic tests, but instead of computing them via pytest, you compute the score with LLM Judges.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!EQSO!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6a90bf6-707e-42db-8fe2-9627de6d4eee_2652x1704.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!EQSO!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6a90bf6-707e-42db-8fe2-9627de6d4eee_2652x1704.png 424w, https://substackcdn.com/image/fetch/$s_!EQSO!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6a90bf6-707e-42db-8fe2-9627de6d4eee_2652x1704.png 848w, https://substackcdn.com/image/fetch/$s_!EQSO!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6a90bf6-707e-42db-8fe2-9627de6d4eee_2652x1704.png 1272w, https://substackcdn.com/image/fetch/$s_!EQSO!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6a90bf6-707e-42db-8fe2-9627de6d4eee_2652x1704.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!EQSO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6a90bf6-707e-42db-8fe2-9627de6d4eee_2652x1704.png" width="1456" height="936" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c6a90bf6-707e-42db-8fe2-9627de6d4eee_2652x1704.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:936,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!EQSO!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6a90bf6-707e-42db-8fe2-9627de6d4eee_2652x1704.png 424w, https://substackcdn.com/image/fetch/$s_!EQSO!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6a90bf6-707e-42db-8fe2-9627de6d4eee_2652x1704.png 848w, https://substackcdn.com/image/fetch/$s_!EQSO!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6a90bf6-707e-42db-8fe2-9627de6d4eee_2652x1704.png 1272w, https://substackcdn.com/image/fetch/$s_!EQSO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6a90bf6-707e-42db-8fe2-9627de6d4eee_2652x1704.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>And in this image, you can see an Opik experiment run over the same dataset but using the custom metrics that look at JSON structure, tool calls, file diffs, and other checks that make sense for our coding agent:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!CNDl!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6a484df-f4a9-489e-b505-bf13f7547c2a_2590x1696.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!CNDl!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6a484df-f4a9-489e-b505-bf13f7547c2a_2590x1696.png 424w, https://substackcdn.com/image/fetch/$s_!CNDl!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6a484df-f4a9-489e-b505-bf13f7547c2a_2590x1696.png 848w, https://substackcdn.com/image/fetch/$s_!CNDl!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6a484df-f4a9-489e-b505-bf13f7547c2a_2590x1696.png 1272w, https://substackcdn.com/image/fetch/$s_!CNDl!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6a484df-f4a9-489e-b505-bf13f7547c2a_2590x1696.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!CNDl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6a484df-f4a9-489e-b505-bf13f7547c2a_2590x1696.png" width="1456" height="953" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b6a484df-f4a9-489e-b505-bf13f7547c2a_2590x1696.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:953,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!CNDl!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6a484df-f4a9-489e-b505-bf13f7547c2a_2590x1696.png 424w, https://substackcdn.com/image/fetch/$s_!CNDl!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6a484df-f4a9-489e-b505-bf13f7547c2a_2590x1696.png 848w, https://substackcdn.com/image/fetch/$s_!CNDl!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6a484df-f4a9-489e-b505-bf13f7547c2a_2590x1696.png 1272w, https://substackcdn.com/image/fetch/$s_!CNDl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6a484df-f4a9-489e-b505-bf13f7547c2a_2590x1696.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>What&#8217;s different from classic tests is that the agent doesn&#8217;t have to pass all the tests! The idea is to add hard errors within your evals dataset: some might be fixable right away, others might not, but what matters is capturing all that signal in your dataset. So when the time comes, you know exactly what needs to be fixed. Running evals on easy tests only burns tokens.</p><p>Another difference is that as you progress with your application, you should consider deleting tests to keep the signal as high as possible. Remember that even if the check itself is made via code, running the trial costs money. So you need to keep only the tasks that are worth it. For a mature application, checking whether it can append a string to a file isn&#8217;t worth it. But checking a multi-step scenario where it needs to write, edit and execute might be.</p><p>The idea is that the regression dataset is a living object where you constantly have to add or delete items. That&#8217;s the true pain of doing evals.</p><p>In Decode, we have 7 easy tests, 7 medium, and 8 hard (22 in total), on which Qwen3.6-35B has a pass rate of 68%.</p><p>You can run them with:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;bash&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-bash">make eval-regression</code></pre></div><p>Or run a single difficulty:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;bash&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-bash">make eval-regression ARGS='--difficulty hard'</code></pre></div><h2>How can you apply this to your own agents?</h2><p>Never trust generic benchmarks. Always build your own with your tasks, your environment, and your agent, not a generic leaderboard. Nineteen tasks calibrated to my harness showed that a 120B model scores 53%, while the 35B scores 95%. A question no public benchmark could answer. Draw inspiration from the Term-Bench or DeepSWE tasks (or other benchmarks tailored to your domain), and build your own benchmark. Then either execute it via Harbor or build your own custom eval.</p><p>Do not design the regression suite up front. Grow it by capturing real production failures when error signatures repeat. Aka do error analysis on your production data. That requires the infrastructure first: tracing on every run and running diagnostics on them, via <a href="https://www.comet.com/site/?utm_source=workshop&amp;utm_medium=partner&amp;utm_campaign=paul&amp;utm_content=coding_agent_course">Opik</a> or one of the alternatives named in the article.</p><p><a href="https://www.decodingai.com/p/transform-agent-traces-into-regression-cases">Lesson 8</a> adds the missing piece for optimizing your agent on steroids: replays via <a href="https://www.zenml.io/product/kitaru?utm_source=decodingai&amp;utm_medium=referral&amp;utm_campaign=coding-agent-course&amp;utm_content=brand">Kitaru</a>. You re-execute a recorded run with one change, diff it against the untouched run, and compare</p><div class="callout-block" data-callout="true"><p>&#129489;&#8205;&#128187; Clone the <a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course/tree/main">course repo</a>, follow the evals <a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course#-course-outline">runbook</a> (<code>running_the_code/05_evals.md</code>), run <code>make eval-benchmark</code> once, make a change, re-run the benchmark and compare!</p></div><p><em>Here is the course roadmap, lesson by lesson (<a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course#-course-outline">see all in GitHub</a>):</em></p><ol><li><p><a href="https://www.decodingai.com/p/building-a-coding-agent-from-scratch-system-design">Building a Coding Agent From Scratch</a></p></li><li><p><a href="https://www.decodingai.com/p/the-coding-agent-loop">The Bare-Bones Coding Agent Loop</a></p></li><li><p><a href="https://www.decodingai.com/p/run-coding-agents-safely">From a Raw Shell to a Sandboxed Coding Agent</a></p></li><li><p><a href="https://www.decodingai.com/p/context-engineering-for-coding-agents">Context Engineering for Coding Agents</a></p></li><li><p><a href="https://www.decodingai.com/p/subagents-are-context-engineering">Subagents Are Context Engineering</a></p></li><li><p><a href="https://www.decodingai.com/p/coding-agents-in-remote-headless">Swarm of Remote Agents</a></p></li><li><p><strong>Agent Evals 101</strong> <strong>&#8592; </strong><em><strong>you are here</strong></em></p></li><li><p><a href="https://www.decodingai.com/p/transform-agent-traces-into-regression-cases">Turn Your Agent&#8217;s Failures Into a Regression Suite</a></p></li></ol><p><em>But here is what I&#8217;m wondering:</em></p><blockquote><p><em><strong>What are you currently doing AI evals for: benchmarks, regression tests or both?</strong></em></p></blockquote><p><em>Click the button below and tell me. I read every response.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://www.decodingai.com/p/evaluate-ai-agents-benchmarks-regression-tests/comments&quot;,&quot;text&quot;:&quot;Leave a comment&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://www.decodingai.com/p/evaluate-ai-agents-benchmarks-regression-tests/comments"><span>Leave a comment</span></a></p><div><hr></div><p><em>Enjoyed the article? The most sincere compliment is to restack this for your readers.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://www.decodingai.com/p/evaluate-ai-agents-benchmarks-regression-tests?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;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://www.decodingai.com/p/evaluate-ai-agents-benchmarks-regression-tests?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p><div><hr></div><p><em>Special thanks to <strong><a href="https://modal.com?source=decodingai&amp;campaign=harnesseng">Modal</a></strong>, <strong><a href="https://www.comet.com/site/?utm_source=newsletter&amp;utm_medium=partner&amp;utm_campaign=paul&amp;utm_content=coding_agent_course">Opik (by Comet)</a></strong>, and <strong><a href="https://www.zenml.io/product/kitaru?utm_source=decodingai&amp;utm_medium=referral&amp;utm_campaign=coding-agent-course&amp;utm_content=brand">Kitaru (by ZenML)</a></strong> for sponsoring this open-source course and keeping it free!</em></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Uq-1!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Uq-1!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 424w, https://substackcdn.com/image/fetch/$s_!Uq-1!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 848w, https://substackcdn.com/image/fetch/$s_!Uq-1!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 1272w, https://substackcdn.com/image/fetch/$s_!Uq-1!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!Uq-1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png" width="1200" height="400" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:400,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:69533,&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://www.decodingai.com/i/207400663?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.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_!Uq-1!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 424w, https://substackcdn.com/image/fetch/$s_!Uq-1!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 848w, https://substackcdn.com/image/fetch/$s_!Uq-1!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 1272w, https://substackcdn.com/image/fetch/$s_!Uq-1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><div><hr></div><div class="callout-block" data-callout="true"><h4>Whenever you&#8217;re ready, here is how I can help you</h4><p><em>Go from agent user to agent builder.</em> Master the foundations of AI agents and turn fragile demo code into reliable, production-ready systems with my course, <strong><a href="https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering">Agent Engineering: Building Multi-Agent Systems</a></strong> (made with Towards AI).</p><p>35 lessons. Pure foundations from scratch. 4 mini-projects. 2 production systems. A certificate and direct access to me &amp; industry experts in our Discord.</p><p>Built for software and data professionals transitioning into AI engineering. <em>Rated 5/5 with 300+ students. The first 7 lessons are free:</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering&quot;,&quot;text&quot;:&quot;Start here&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering"><span>Start here</span></a></p><p><em>Not ready to commit?</em> Start with our <strong><a href="https://email-course.towardsai.net/?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering">free Agent AI Engineering Guide</a></strong>, a 6-day email course on the mistakes that silently break AI agents in production.</p></div><div><hr></div><h2>Images &amp; videos</h2><p>If not otherwise stated, all images and videos are created by the author.</p>]]></content:encoded></item><item><title><![CDATA[Stop Babysitting Your Coding Agents]]></title><description><![CDATA[Run the harness remotely on Modal, triggered by your CLI, a webhook, or a nightly cron.]]></description><link>https://www.decodingai.com/p/coding-agents-in-remote-headless</link><guid isPermaLink="false">https://www.decodingai.com/p/coding-agents-in-remote-headless</guid><dc:creator><![CDATA[Paul Iusztin]]></dc:creator><pubDate>Thu, 10 Sep 2026 05:02:03 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!C2kP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3384caa7-94f2-4525-92da-1b089007dcb9_1376x768.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="callout-block" data-callout="true"><p><em><strong><span data-color="#c02f26" style="color: rgb(192, 47, 38);">Every AI application that wraps an agent is a harness!</span></strong><span data-color="#c02f26" style="color: rgb(192, 47, 38);"> </span></em></p><p>In LangChain&#8217;s Terminal-Bench experiment, changing only the harness (with the same model) moved a coding agent from ~30th place into the top 5: the harness, not the model, is what makes a coding agent good.</p><p>In the&nbsp;<strong>open-source course</strong>&nbsp;<strong><a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course">Building a Coding Agent From Scratch</a></strong>, you&#8217;ll build that harness from scratch in Python:&nbsp;<strong>Decode</strong>, a complete coding agent that grows lesson by lesson from a bare agent loop into a swarm of remote agents running in parallel in the cloud.</p><p><strong>Why?</strong>&nbsp;You&#8217;ll be able to engineer custom harnesses for your own AI products (the skill behind that leaderboard jump), and you&#8217;ll understand what Claude Code and Codex actually do under the hood, turning you into a power user.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ge05!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ge05!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 424w, https://substackcdn.com/image/fetch/$s_!ge05!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 848w, https://substackcdn.com/image/fetch/$s_!ge05!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 1272w, https://substackcdn.com/image/fetch/$s_!ge05!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ge05!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif" width="1200" height="630" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:630,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1446989,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/gif&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://www.decodingai.com/i/207400663?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ge05!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 424w, https://substackcdn.com/image/fetch/$s_!ge05!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 848w, https://substackcdn.com/image/fetch/$s_!ge05!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 1272w, https://substackcdn.com/image/fetch/$s_!ge05!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><strong>Lessons:</strong></p><ol><li><p><a href="https://www.decodingai.com/p/building-a-coding-agent-from-scratch-system-design">Building a Coding Agent From Scratch</a><strong> </strong></p></li><li><p><a href="https://www.decodingai.com/p/the-coding-agent-loop">The Bare-Bones Coding Agent Loop </a></p></li><li><p><a href="https://www.decodingai.com/p/run-coding-agents-safely">From a Raw Shell to a Sandboxed Coding Agent</a></p></li><li><p><a href="https://www.decodingai.com/p/context-engineering-for-coding-agents">Context Engineering for Coding Agents</a> </p></li><li><p><a href="https://www.decodingai.com/p/subagents-are-context-engineering">Subagents Are Context Engineering</a></p></li><li><p><strong><span>Swarm of Remote Agents</span></strong> <strong>&#8592; </strong><em><strong>You are here</strong></em></p></li><li><p><a href="https://www.decodingai.com/p/evaluate-ai-agents-benchmarks-regression-tests">Agent Evals 101</a></p></li><li><p><a href="https://www.decodingai.com/p/transform-agent-traces-into-regression-cases">Turn Your Agent&#8217;s Failures Into a Regression Suite</a></p></li></ol><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course&quot;,&quot;text&quot;:&quot;Full open-source course&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course"><span>Full open-source course</span></a></p><p><em>Special thanks to <strong><a href="https://modal.com/?source=decodingai&amp;campaign=harnesseng">Modal</a></strong>, <strong><a href="https://www.comet.com/site/?utm_source=workshop&amp;utm_medium=partner&amp;utm_campaign=paul&amp;utm_content=coding_agent_course">Opik (by Comet)</a></strong>, and <strong><a href="https://www.zenml.io/product/kitaru?utm_source=decodingai&amp;utm_medium=referral&amp;utm_campaign=coding-agent-course&amp;utm_content=brand">Kitaru (by ZenML)</a></strong> for sponsoring this open-source course and keeping it free!</em></p></div><h1>Lesson 6: Swarm of Remote Agents</h1><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!PKQ2!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a7063de-4375-455e-9186-a287c9020433_1376x768.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!PKQ2!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a7063de-4375-455e-9186-a287c9020433_1376x768.png 424w, https://substackcdn.com/image/fetch/$s_!PKQ2!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a7063de-4375-455e-9186-a287c9020433_1376x768.png 848w, https://substackcdn.com/image/fetch/$s_!PKQ2!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a7063de-4375-455e-9186-a287c9020433_1376x768.png 1272w, https://substackcdn.com/image/fetch/$s_!PKQ2!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a7063de-4375-455e-9186-a287c9020433_1376x768.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!PKQ2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a7063de-4375-455e-9186-a287c9020433_1376x768.png" width="1376" height="768" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9a7063de-4375-455e-9186-a287c9020433_1376x768.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:768,&quot;width&quot;:1376,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;You went to bed. The work did not.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="You went to bed. The work did not." title="You went to bed. The work did not." srcset="https://substackcdn.com/image/fetch/$s_!PKQ2!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a7063de-4375-455e-9186-a287c9020433_1376x768.png 424w, https://substackcdn.com/image/fetch/$s_!PKQ2!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a7063de-4375-455e-9186-a287c9020433_1376x768.png 848w, https://substackcdn.com/image/fetch/$s_!PKQ2!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a7063de-4375-455e-9186-a287c9020433_1376x768.png 1272w, https://substackcdn.com/image/fetch/$s_!PKQ2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a7063de-4375-455e-9186-a287c9020433_1376x768.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>While building automations for Decoding AI and the personal assistant for my next Manning book, I ended up with five coding agents running in parallel. After three hours, I was completely exhausted, losing clarity and forgetting what they were doing and what their scope was. The real issue wasn&#8217;t running five agents. It was babysitting them, each needing me present in a terminal.</p><p>The goal is to have background agents running in your CI/CD pipeline or proactive agents pulling Linear tickets overnight that launch parallel attempts and pick the best PR for you to review. The goal is to switch from having your work blocked behind a TUI to proactive agents that analyze your KPIs overnight, waking up with the final report to review.</p><p>That&#8217;s <em>&#8220;the goal&#8221;,</em> the ideal I am still trying to achieve. But my best attempt to truly understand how these background agents integrate into my daily workflows without throwing money at the problem is to build a simple solution from scratch.</p><p>Thus, we will take Decode, the coding harness we built during this course, and deploy it to the cloud as a background agent through three steps:</p><ol><li><p>Switch from a TUI to a CLI headless interface</p></li><li><p>Ship it to Modal to run it as remote serverless jobs</p></li><li><p>Add support for parallel sessions to hook it to multiple projects in parallel</p></li></ol><p>By the end, you will run:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;plaintext&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-plaintext">uv run decode remote attempts "Add support to attach the agent to Slack" \
  --repo https://github.com/&lt;you&gt;/&lt;your-repo&gt;.git \
  --attempts 3 \
  --sandbox-mode modal</code></pre></div><p>That will spin off 3 independent Decode agents implementing the same feature on Modal, each shipping its own <code>decode/&lt;session-id&gt;</code> branch, which another coding agent can later compare, forwarding only the best one for your review.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course&quot;,&quot;text&quot;:&quot;Try it yourself&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course"><span>Try it yourself</span></a></p><p>Before anything runs remotely, we have to drop the TUI and make the harness headless.</p><h2>Making the harness.. headless</h2><p>The <strong>headless mode</strong> runs the harness directly from the CLI and triggers the agent loop until the given goal is reached: <code>decode run "&lt;goal&gt;"</code>. It wraps the same <code>build_agent()</code> agent loop as the TUI, but under a new interface. This is easy to implement when adopting a clean architecture design that separates the app layer (the agent loop) from the serving layers (the TUI and CLI).</p><p><em>Exposing the harness as a CLI will open up tons of possibilities, as you will soon see!</em> A CLI is also scriptable, which is what lets Mario Zechner run subagents as plain <code>pi</code> calls under <code>tmux</code> in <a href="https://mariozechner.at/posts/2025-11-30-pi-coding-agent/">his minimal coding agent</a>.</p><p>Because the agent runs in the background, everything defaults to bypass permission mode, and the <code>ask_user</code> tool becomes a no-op. On top of that, stdout prints only the final answer, while the full traces are redirected only to <a href="https://www.comet.com/site/?utm_source=newsletter&amp;utm_medium=partner&amp;utm_campaign=paul&amp;utm_content=coding_agent_course">Opik</a>, our observability platform.</p><p>This design is extremely similar to Claude Code&#8217;s <code>claude -p "&lt;goal&gt;"</code> interface.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!6idL!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47b2533c-0dca-4aa9-9308-711cc7101aee_1200x1200.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!6idL!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47b2533c-0dca-4aa9-9308-711cc7101aee_1200x1200.png 424w, https://substackcdn.com/image/fetch/$s_!6idL!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47b2533c-0dca-4aa9-9308-711cc7101aee_1200x1200.png 848w, https://substackcdn.com/image/fetch/$s_!6idL!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47b2533c-0dca-4aa9-9308-711cc7101aee_1200x1200.png 1272w, https://substackcdn.com/image/fetch/$s_!6idL!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47b2533c-0dca-4aa9-9308-711cc7101aee_1200x1200.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!6idL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47b2533c-0dca-4aa9-9308-711cc7101aee_1200x1200.png" width="1200" height="1200" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/47b2533c-0dca-4aa9-9308-711cc7101aee_1200x1200.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1200,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;The harness interface &#8212; a TUI, a CLI, an evals harness, and a remote launcher each drive the same loop by filling the same six fields; the loop has no opinion about any of them.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="The harness interface &#8212; a TUI, a CLI, an evals harness, and a remote launcher each drive the same loop by filling the same six fields; the loop has no opinion about any of them." title="The harness interface &#8212; a TUI, a CLI, an evals harness, and a remote launcher each drive the same loop by filling the same six fields; the loop has no opinion about any of them." srcset="https://substackcdn.com/image/fetch/$s_!6idL!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47b2533c-0dca-4aa9-9308-711cc7101aee_1200x1200.png 424w, https://substackcdn.com/image/fetch/$s_!6idL!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47b2533c-0dca-4aa9-9308-711cc7101aee_1200x1200.png 848w, https://substackcdn.com/image/fetch/$s_!6idL!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47b2533c-0dca-4aa9-9308-711cc7101aee_1200x1200.png 1272w, https://substackcdn.com/image/fetch/$s_!6idL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47b2533c-0dca-4aa9-9308-711cc7101aee_1200x1200.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>The headless harness has four modes: TUI, CLI, an evals harness, and the remote launcher.</em></figcaption></figure></div><p>The <strong>harness interface</strong> is two things: <code>build_agent()</code> (the model, the tools, the instructions) and <code>AgentDeps</code> (the tool scope, an event sink, the gate, and two resolvers for when the loop needs a human). We can add a new serving layer by implementing this interface. As shown in the image above, we will use this design to support 4 modes: the TUI, the local CLI, remote background jobs, and an eval harness (built with <a href="https://www.comet.com/site/?utm_source=newsletter&amp;utm_medium=partner&amp;utm_campaign=paul&amp;utm_content=coding_agent_course">Opik</a> and <a href="https://www.zenml.io/product/kitaru?utm_source=decodingai&amp;utm_medium=referral&amp;utm_campaign=coding-agent-course&amp;utm_content=brand">Kitaru</a>).</p><div class="callout-block" data-callout="true"><p>&#128161; <em>The remote background jobs and eval harness will be layers on top of the CLI.</em></p></div><p><em>From <a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course/blob/main/src/decode/agent/deps.py">src/decode/agent/deps.py</a> and <a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course/blob/main/src/decode/agent/factory.py">src/decode/agent/factory.py</a>:</em></p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">@dataclass(slots=True)
class AgentDeps:
    cwd: Path                                    # the tool scope
    emit: EventSink                              # stream events (eg, TUI)
    gate: PermissionGate                         # allow / ask / deny, per tool call
    resolve_permission: PermissionResolver       # who answers an "ask"
    resolve_user_question: UserQuestionResolver  # who answers the ask_user tool
    harness_home: Path | None = None             # sessions, memory, skills

def build_agent(*, model: str | None = None) -&gt; Agent[AgentDeps, str | DeferredToolRequests]:
    agent = Agent(
        _build_model(model=model),               # gemini | openrouter | modal
        deps_type=AgentDeps,
        output_type=[str, DeferredToolRequests],
    )
    register_tools(agent)                        # read, edit, bash, agent, etc.
    _register_instructions(agent)
    return agent</code></pre></div><p>Under the CLI, when running <code>decode run</code>, we implement the <code>AgentDeps</code> interface as follows: a sink that only logs, a gate in bypass mode, resolvers that deny any human interaction, and one <code>agent.run</code> agent loop in a single Python async loop.</p><p><em>From <a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course/blob/main/src/decode/runtime/headless.py">src/decode/runtime/headless.py</a>:</em></p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">def _build_headless_deps(cwd: Path, model: str | None = None) -&gt; AgentDeps:
    return AgentDeps(
        cwd=cwd,
        harness_home=Path.cwd(),
        emit=_headless_emit,                              
        gate=PermissionGate(mode=PermissionMode.BYPASS),
        resolve_permission=_deny_permission_resolver,      
        # never reached under BYPASS
        resolve_user_question=deny_user_question_resolver, 
        # ask_user is a no-op
    )

async def _run_task(task: str, *, model: str | None, repo: str | None, max_requests: int | None) -&gt; str:
    tool_scope = await _prepare_headless_tool_scope(repo, local)  
    # the Workspace in a sandbox mode, else cwd
    agent = build_agent(model=model)                       
    # the SAME agent the TUI builds
    deps = _build_headless_deps(tool_scope, model)
    result = await agent.run(task, deps=deps, usage_limits=UsageLimits(request_limit=max_requests))
    return result.output

def run_headless_task(task: str, ...) -&gt; str:
    try:
        return asyncio.run(_run_task(task, ...))
    finally:
        ...</code></pre></div><p>In retrospect, here is how we implemented the <code>AgentDeps</code> interface within the interactive mode plugged into the TUI: a sink that renders in the terminal, a gate loaded from your configs, resolvers that await the user, and a Runner that implements a steering queue that pours messages into the agent loop at the right time (<a href="https://www.decodingai.com/p/the-coding-agent-loop">full implementation in Lesson 2</a>).</p><p><em>From <a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course/blob/main/src/decode/tui/app.py">src/decode/tui/app.py</a>:</em></p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">decisions = DecisionChannel()                 # mid-turn surface for permissions + ask_user
agent = build_agent()
gate = PermissionGate(user_rules=rules.load_rule_set(permissions_file))
deps = AgentDeps(
    cwd=tool_scope,
    harness_home=harness_home,
    emit=_make_event_sink(console),           # events render live in the terminal
    gate=gate,
    resolve_permission=_make_permission_resolver(decisions, console, gate=gate, ...),
    resolve_user_question=_make_user_question_resolver(decisions, console),
)

handler = AgentTurnHandler(agent, deps=deps, session_log=session_log, ...)
runner = Runner(handler, on_event=_on_event)  # steering queue</code></pre></div><p>The two upcoming serving layers share this same clean architecture: an evals harness running <code>decode run</code> across benchmarks, and the remote background agents we build next.</p><p>In this CLI design, one key option is <code>--max-requests N</code>, which limits the maximum number of iterations in a single Pydantic AI agent loop to prevent it from running indefinitely. When running agents interactively, adding a limit is more of a curse than a blessing, but when not monitoring them at all, you want to avoid getting the agent stuck in a doom loop that just burns tokens &#8212; one of the failure modes Anthropic covers in its guide on <a href="https://www.anthropic.com/engineering/effective-harnesses-for-long-running-agents">effective harnesses for long-running agents</a>.</p><p>Next stop: taking the laptop out of the loop via remote background agents on Modal.</p><h2>Running the headless harness remotely</h2><p>The problem with running coding agents locally is that when you close your laptop lid, you are done. I&#8217;ve been trying to work around this issue with programs such as Amphetamine that hijack the sleeping processes of my Mac, but they don&#8217;t work properly. You always end up with your session stuck.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!UGNq!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85d91781-c24c-43b3-919e-7d409eda0941_640x668.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!UGNq!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85d91781-c24c-43b3-919e-7d409eda0941_640x668.png 424w, https://substackcdn.com/image/fetch/$s_!UGNq!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85d91781-c24c-43b3-919e-7d409eda0941_640x668.png 848w, https://substackcdn.com/image/fetch/$s_!UGNq!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85d91781-c24c-43b3-919e-7d409eda0941_640x668.png 1272w, https://substackcdn.com/image/fetch/$s_!UGNq!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85d91781-c24c-43b3-919e-7d409eda0941_640x668.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!UGNq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85d91781-c24c-43b3-919e-7d409eda0941_640x668.png" width="640" height="668" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/85d91781-c24c-43b3-919e-7d409eda0941_640x668.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:668,&quot;width&quot;:640,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!UGNq!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85d91781-c24c-43b3-919e-7d409eda0941_640x668.png 424w, https://substackcdn.com/image/fetch/$s_!UGNq!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85d91781-c24c-43b3-919e-7d409eda0941_640x668.png 848w, https://substackcdn.com/image/fetch/$s_!UGNq!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85d91781-c24c-43b3-919e-7d409eda0941_640x668.png 1272w, https://substackcdn.com/image/fetch/$s_!UGNq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85d91781-c24c-43b3-919e-7d409eda0941_640x668.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>Instead of maintaining a server, we create a clear boundary between who triggers the harness and where it executes. Your laptop, a cron job, or a webhook only <em>launches</em> it, and <a href="https://modal.com/?source=decodingai&amp;campaign=harnesseng">Modal</a> <em>executes</em> in fire-and-forget containers with zero idle cost. Modal already served our models and sandboxes. Now it also hosts the harness under serverless functions.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!9BWK!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ff2b126-fc16-4e63-a738-1f713823a54c_1200x563.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!9BWK!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ff2b126-fc16-4e63-a738-1f713823a54c_1200x563.png 424w, https://substackcdn.com/image/fetch/$s_!9BWK!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ff2b126-fc16-4e63-a738-1f713823a54c_1200x563.png 848w, https://substackcdn.com/image/fetch/$s_!9BWK!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ff2b126-fc16-4e63-a738-1f713823a54c_1200x563.png 1272w, https://substackcdn.com/image/fetch/$s_!9BWK!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ff2b126-fc16-4e63-a738-1f713823a54c_1200x563.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!9BWK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ff2b126-fc16-4e63-a738-1f713823a54c_1200x563.png" width="1200" height="563" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8ff2b126-fc16-4e63-a738-1f713823a54c_1200x563.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:563,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;The headless harness in the middle &#8212; a CLI, a cron and a webhook all start the same loop; the sandbox is optional.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="The headless harness in the middle &#8212; a CLI, a cron and a webhook all start the same loop; the sandbox is optional." title="The headless harness in the middle &#8212; a CLI, a cron and a webhook all start the same loop; the sandbox is optional." srcset="https://substackcdn.com/image/fetch/$s_!9BWK!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ff2b126-fc16-4e63-a738-1f713823a54c_1200x563.png 424w, https://substackcdn.com/image/fetch/$s_!9BWK!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ff2b126-fc16-4e63-a738-1f713823a54c_1200x563.png 848w, https://substackcdn.com/image/fetch/$s_!9BWK!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ff2b126-fc16-4e63-a738-1f713823a54c_1200x563.png 1272w, https://substackcdn.com/image/fetch/$s_!9BWK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ff2b126-fc16-4e63-a738-1f713823a54c_1200x563.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>The remote system design of the headless harness that can be triggered via the local CLI, cron jobs or webhooks. All the options start the same headless harness while the agent loop runs its tool calls in an optional sandbox.</em></figcaption></figure></div><p>Which means that now we have three ways to trigger the harness:</p><ol><li><p>via <code>decode remote run</code> or <code>decode remote attempts</code> when we want to either manually trigger the harness or hook it into the CI/CD (or any other shell script)</p></li><li><p>a webhook POST that we can use from Slack, Discord or Telegram messages</p></li><li><p>a cron scheduler that we can connect to our Linear or Notion project manager to implement our tickets overnight for us to review them in the morning</p></li></ol><p>All three are implemented as different entry points into the same Modal app:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!KX-K!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa0ba78b8-559c-467d-95a6-5bfb527c6d14_3032x798.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!KX-K!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa0ba78b8-559c-467d-95a6-5bfb527c6d14_3032x798.png 424w, https://substackcdn.com/image/fetch/$s_!KX-K!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa0ba78b8-559c-467d-95a6-5bfb527c6d14_3032x798.png 848w, https://substackcdn.com/image/fetch/$s_!KX-K!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa0ba78b8-559c-467d-95a6-5bfb527c6d14_3032x798.png 1272w, https://substackcdn.com/image/fetch/$s_!KX-K!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa0ba78b8-559c-467d-95a6-5bfb527c6d14_3032x798.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!KX-K!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa0ba78b8-559c-467d-95a6-5bfb527c6d14_3032x798.png" width="1456" height="383" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a0ba78b8-559c-467d-95a6-5bfb527c6d14_3032x798.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:383,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!KX-K!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa0ba78b8-559c-467d-95a6-5bfb527c6d14_3032x798.png 424w, https://substackcdn.com/image/fetch/$s_!KX-K!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa0ba78b8-559c-467d-95a6-5bfb527c6d14_3032x798.png 848w, https://substackcdn.com/image/fetch/$s_!KX-K!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa0ba78b8-559c-467d-95a6-5bfb527c6d14_3032x798.png 1272w, https://substackcdn.com/image/fetch/$s_!KX-K!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa0ba78b8-559c-467d-95a6-5bfb527c6d14_3032x798.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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 headless harness per se runs within <a href="https://modal.com/docs/guide/apps?source=decodingai&amp;campaign=harnesseng">a Modal app</a> wrapped by one Python function that Modal runs in its own container on demand, each time it&#8217;s triggered. More exactly, it runs <code>decode run</code> as a subprocess, similar to what we&#8217;ve been running locally so far, inside a gVisor container (the user-space kernel Modal runs under every container).</p><p>Because of our modular design, we can hook the headless harness to a remote Modal sandbox that runs filesystem tools such as read, edit, write and bash. Passing <code>--sandbox-mode modal</code> clones <code>--repo</code> into the sandbox workspace runs the tools there and pushes a <code>decode/&lt;session-id&gt;</code> branch to GitHub. Or, as seen in the image below, multiple branches if we choose to attempt multiple implementations of the same feature.</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!orTq!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F74a94e88-c98f-4dd3-8799-226596f2e19c_1354x326.png 424w, https://substackcdn.com/image/fetch/$s_!orTq!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F74a94e88-c98f-4dd3-8799-226596f2e19c_1354x326.png 848w, https://substackcdn.com/image/fetch/$s_!orTq!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F74a94e88-c98f-4dd3-8799-226596f2e19c_1354x326.png 1272w, https://substackcdn.com/image/fetch/$s_!orTq!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F74a94e88-c98f-4dd3-8799-226596f2e19c_1354x326.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!orTq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F74a94e88-c98f-4dd3-8799-226596f2e19c_1354x326.png" width="1354" height="326" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/74a94e88-c98f-4dd3-8799-226596f2e19c_1354x326.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:326,&quot;width&quot;:1354,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!orTq!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F74a94e88-c98f-4dd3-8799-226596f2e19c_1354x326.png 424w, https://substackcdn.com/image/fetch/$s_!orTq!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F74a94e88-c98f-4dd3-8799-226596f2e19c_1354x326.png 848w, https://substackcdn.com/image/fetch/$s_!orTq!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F74a94e88-c98f-4dd3-8799-226596f2e19c_1354x326.png 1272w, https://substackcdn.com/image/fetch/$s_!orTq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F74a94e88-c98f-4dd3-8799-226596f2e19c_1354x326.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>We deploy the Modal app defined in the code snippet below, via <code>decode remote deploy</code>, which builds a Debian image in code with all necessary dependencies and pushes it directly to Modal&#8217;s container registry.</p><p>In the <code>execute_run()</code> function, we mostly set up the environment, clone the repository if we&#8217;re not in a sandbox, and call <code>decode run &lt;"goal "&gt;</code> as a subprocess. That&#8217;s it. Modal mostly acts as a middleman between different ways to trigger our headless harness and where to execute it.</p><p><em>From <a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course/blob/main/src/decode/remote/app.py">src/decode/remote/app.py</a> and <a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course/blob/main/src/decode/remote/headless.py">src/decode/remote/headless.py</a>:</em></p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">IMAGE = build_image(extra_dirs=(REPO_CLONE_DIR,), extra_packages=WEB_PACKAGES)
app = modal.App("decode-headless")

@app.function(image=IMAGE, secrets=[modal.Secret.from_name("decode-headless")], timeout=3600)
def run_task(task: str, repo: str | None = None, sandbox_mode: str = "none",
             model: str | None = None, timeout_seconds: int = 1800, max_requests: int | None = None) -&gt; dict:
    return execute_run(
&#9;    task=task, 
&#9;    repo=repo, 
&#9;    sandbox_mode=sandbox_mode, 
&#9;    model=model,
&#9;&#9;timeout_seconds=timeout_seconds,
&#9;&#9;max_requests=max_requests
&#9;&#9;)

def execute_run(*, task, repo=None, sandbox_mode="none", model=None, timeout_seconds=1800, max_requests=None) -&gt; dict:
    env = decode_run_env(os.environ, sandbox_mode=sandbox_mode)
    # inject env vars: SANDBOX_MODE, DECODE_ENV=prod, GITHUB_TOKEN, etc.
    
    if sandbox_mode == "none" and repo:
        clone_for_none_mode(repo, env)
        
    stdout, exit_code = stream_subprocess(
        decode_argv(
            task=task,
            sandbox_mode=sandbox_mode,
            repo=repo,
            model=model,
            max_requests=max_requests
        ),
        cwd=decode_cwd(sandbox_mode=sandbox_mode, repo=repo),
        env=env,
        timeout_seconds=timeout_seconds,
    ) # Run 'decode run "&lt;task&gt;" ...' within a subprocess

    return build_result(sandbox_mode=sandbox_mode, repo=repo, exit_code=exit_code, stdout=stdout, log_text=read_child_log())</code></pre></div><p>Next, we can interact with the deployed headless harness via <code>decode remote</code>, where we can start asking for specific goals via <code>decode remote run "&lt;goal&gt;"</code> or for multiple attempts via <code>decode remote attempts "&lt;goal&gt;"</code>. Which under the hood will trigger the Modal <code>run_task()</code> serverless function once or multiple times in parallel.</p><p>In the image below, we can see how each remote attempt (3 in our use case) works in its own Modal container and optional sandbox:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!65Iw!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08551dc2-edcc-45b8-b163-12e3b746c669_3048x1308.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!65Iw!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08551dc2-edcc-45b8-b163-12e3b746c669_3048x1308.png 424w, https://substackcdn.com/image/fetch/$s_!65Iw!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08551dc2-edcc-45b8-b163-12e3b746c669_3048x1308.png 848w, https://substackcdn.com/image/fetch/$s_!65Iw!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08551dc2-edcc-45b8-b163-12e3b746c669_3048x1308.png 1272w, https://substackcdn.com/image/fetch/$s_!65Iw!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08551dc2-edcc-45b8-b163-12e3b746c669_3048x1308.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!65Iw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08551dc2-edcc-45b8-b163-12e3b746c669_3048x1308.png" width="1456" height="625" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/08551dc2-edcc-45b8-b163-12e3b746c669_3048x1308.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:625,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!65Iw!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08551dc2-edcc-45b8-b163-12e3b746c669_3048x1308.png 424w, https://substackcdn.com/image/fetch/$s_!65Iw!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08551dc2-edcc-45b8-b163-12e3b746c669_3048x1308.png 848w, https://substackcdn.com/image/fetch/$s_!65Iw!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08551dc2-edcc-45b8-b163-12e3b746c669_3048x1308.png 1272w, https://substackcdn.com/image/fetch/$s_!65Iw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08551dc2-edcc-45b8-b163-12e3b746c669_3048x1308.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>Each with its own branch and optional PR:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!orTq!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F74a94e88-c98f-4dd3-8799-226596f2e19c_1354x326.png 424w, https://substackcdn.com/image/fetch/$s_!orTq!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F74a94e88-c98f-4dd3-8799-226596f2e19c_1354x326.png 848w, https://substackcdn.com/image/fetch/$s_!orTq!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F74a94e88-c98f-4dd3-8799-226596f2e19c_1354x326.png 1272w, https://substackcdn.com/image/fetch/$s_!orTq!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F74a94e88-c98f-4dd3-8799-226596f2e19c_1354x326.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!orTq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F74a94e88-c98f-4dd3-8799-226596f2e19c_1354x326.png" width="1354" height="326" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/74a94e88-c98f-4dd3-8799-226596f2e19c_1354x326.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:326,&quot;width&quot;:1354,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!orTq!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F74a94e88-c98f-4dd3-8799-226596f2e19c_1354x326.png 424w, https://substackcdn.com/image/fetch/$s_!orTq!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F74a94e88-c98f-4dd3-8799-226596f2e19c_1354x326.png 848w, https://substackcdn.com/image/fetch/$s_!orTq!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F74a94e88-c98f-4dd3-8799-226596f2e19c_1354x326.png 1272w, https://substackcdn.com/image/fetch/$s_!orTq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F74a94e88-c98f-4dd3-8799-226596f2e19c_1354x326.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>The deployed Modal functions form <a href="https://modal.com/docs/guide/scale?source=decodingai&amp;campaign=harnesseng">an autoscaling pool of containers</a> that sits at zero. A client <a href="https://modal.com/docs/guide/trigger-deployed-functions?source=decodingai&amp;campaign=harnesseng">looks up the Function by name</a>: <code>modal.Function.from_name("decode-headless", "run_task")</code>. It calls <code>.remote(...)</code> for a synchronous blocking call, or <code>.spawn(...)</code> for an async one.</p><p>Modal routes inputs to warm containers or boots new ones up to <code>max_containers</code>, automatically shutting down idle instances. The only latency in <code>modal</code> mode comes from <a href="https://modal.com/blog/unpacking-sandbox-startup-latency?source=decodingai&amp;campaign=harnesseng">the started-versus-ready gap</a> while the sandbox clones your repo and installs dependencies.</p><p>Using a similar strategy, we can implement the remaining two triggers. The <strong>nightly cron</strong> calls <code>run_task.local()</code> on <a href="https://modal.com/docs/guide/cron?source=decodingai&amp;campaign=harnesseng">a schedule</a> set by the <code>DECODE_NIGHTLY_CRON</code> env var.</p><p>For the <strong>webhook</strong>, we need to expose <a href="https://modal.com/docs/guide/webhooks?source=decodingai&amp;campaign=harnesseng">a FastAPI endpoint</a> with proxy auth (a key/secret header pair Modal checks at its edge before your code runs). This time, it spawns a <code>run_task</code> in the background as an async job and returns a call ID in milliseconds.</p><p><em>From <a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course/blob/main/src/decode/remote/app.py">src/decode/remote/app.py</a>:</em></p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">@app.function(image=IMAGE, secrets=[...], schedule=nightly_schedule(os.environ))
def nightly() -&gt; dict:
    return run_task.local(**nightly_run_kwargs(os.environ))   # same container, same subprocess

@app.function(image=IMAGE)
@modal.fastapi_endpoint(method="POST", requires_proxy_auth=True)
def webhook(request: WebhookRequest) -&gt; dict:
    call = run_task.spawn(**webhook_spawn_kwargs(request))    # start it, don't wait for it
    return webhook_response(call.object_id, request)          # the call id + where to watch</code></pre></div><p>Below, you can see how the webhook triggered the <code>run_task</code> serverless function:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!FP-K!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F348bf7d9-ce20-4a91-8771-07e8db7563f2_3046x1252.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!FP-K!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F348bf7d9-ce20-4a91-8771-07e8db7563f2_3046x1252.png 424w, https://substackcdn.com/image/fetch/$s_!FP-K!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F348bf7d9-ce20-4a91-8771-07e8db7563f2_3046x1252.png 848w, https://substackcdn.com/image/fetch/$s_!FP-K!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F348bf7d9-ce20-4a91-8771-07e8db7563f2_3046x1252.png 1272w, https://substackcdn.com/image/fetch/$s_!FP-K!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F348bf7d9-ce20-4a91-8771-07e8db7563f2_3046x1252.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!FP-K!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F348bf7d9-ce20-4a91-8771-07e8db7563f2_3046x1252.png" width="1456" height="598" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/348bf7d9-ce20-4a91-8771-07e8db7563f2_3046x1252.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:598,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!FP-K!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F348bf7d9-ce20-4a91-8771-07e8db7563f2_3046x1252.png 424w, https://substackcdn.com/image/fetch/$s_!FP-K!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F348bf7d9-ce20-4a91-8771-07e8db7563f2_3046x1252.png 848w, https://substackcdn.com/image/fetch/$s_!FP-K!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F348bf7d9-ce20-4a91-8771-07e8db7563f2_3046x1252.png 1272w, https://substackcdn.com/image/fetch/$s_!FP-K!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F348bf7d9-ce20-4a91-8771-07e8db7563f2_3046x1252.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>Deploy once to publish <code>run_task</code>, <code>nightly</code>, and <code>webhook</code>:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;bash&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-bash">uv run decode remote deploy</code></pre></div><p>Fire a single synchronous run from your laptop:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;bash&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-bash">uv run decode remote run "&lt;task&gt;" --repo &lt;url&gt; --sandbox-mode modal</code></pre></div><p>Launch N parallel attempts with <code>--detach</code> to exit immediately:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;bash&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-bash">uv run decode remote attempts "&lt;task&gt;" --repo &lt;url&gt; --attempts 3 --sandbox-mode modal --detach</code></pre></div><p>Schedule a nightly cron via a UTC crontab. Without <code>DECODE_NIGHTLY_CRON</code> no schedule registers:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;bash&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-bash">DECODE_NIGHTLY_CRON="0 2 * * *" \ 
DECODE_NIGHTLY_TASK="&lt;task&gt;" \ 
DECODE_NIGHTLY_REPO=&lt;url&gt; \
DECODE_NIGHTLY_SANDBOX_MODE=modal \
DECODE_NIGHTLY_MAX_REQUESTS=120 \
uv run decode remote deploy</code></pre></div><p>Trigger the webhook over HTTP via authenticated POST:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;bash&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-bash">curl -X POST "$WEBHOOK_URL" \
-H "Modal-Key: $MODAL_PROXY_TOKEN_ID" \
-H "Modal-Secret: $MODAL_PROXY_TOKEN_SECRET" \
-H 'content-type: application/json' \
-d '{"task": "&#8230;", "repo": "&lt;url&gt;", "sandbox_mode": "modal", "max_requests": 60}'</code></pre></div><p>Read every run&#8217;s answer and summary line, from anywhere:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;bash&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-bash">uv run decode remote logs</code></pre></div><p>Looking at the logs in the terminal can be super helpful for detecting build and runtime errors and warnings. But when we have to understand what&#8217;s going on inside the agent, a better way to look at its model and tool calls is to use an observability tool like <a href="https://www.comet.com/site/?utm_source=newsletter&amp;utm_medium=partner&amp;utm_campaign=paul&amp;utm_content=coding_agent_course">Opik</a>:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!G71x!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbdf79093-66fa-45a8-88c6-a7c8861c674d_1190x1668.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!G71x!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbdf79093-66fa-45a8-88c6-a7c8861c674d_1190x1668.png 424w, https://substackcdn.com/image/fetch/$s_!G71x!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbdf79093-66fa-45a8-88c6-a7c8861c674d_1190x1668.png 848w, https://substackcdn.com/image/fetch/$s_!G71x!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbdf79093-66fa-45a8-88c6-a7c8861c674d_1190x1668.png 1272w, https://substackcdn.com/image/fetch/$s_!G71x!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbdf79093-66fa-45a8-88c6-a7c8861c674d_1190x1668.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!G71x!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbdf79093-66fa-45a8-88c6-a7c8861c674d_1190x1668.png" width="1190" height="1668" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/bdf79093-66fa-45a8-88c6-a7c8861c674d_1190x1668.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1668,&quot;width&quot;:1190,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!G71x!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbdf79093-66fa-45a8-88c6-a7c8861c674d_1190x1668.png 424w, https://substackcdn.com/image/fetch/$s_!G71x!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbdf79093-66fa-45a8-88c6-a7c8861c674d_1190x1668.png 848w, https://substackcdn.com/image/fetch/$s_!G71x!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbdf79093-66fa-45a8-88c6-a7c8861c674d_1190x1668.png 1272w, https://substackcdn.com/image/fetch/$s_!G71x!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbdf79093-66fa-45a8-88c6-a7c8861c674d_1190x1668.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>Which can quickly become super useful when running <code>decode remote attemps</code> and comparing their differences in costs (if using an API), latency and token usage:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!c4Ye!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6c3205e-d445-4f88-9545-3ea19fafd825_2348x562.png 424w, https://substackcdn.com/image/fetch/$s_!c4Ye!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6c3205e-d445-4f88-9545-3ea19fafd825_2348x562.png 848w, https://substackcdn.com/image/fetch/$s_!c4Ye!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6c3205e-d445-4f88-9545-3ea19fafd825_2348x562.png 1272w, https://substackcdn.com/image/fetch/$s_!c4Ye!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6c3205e-d445-4f88-9545-3ea19fafd825_2348x562.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!c4Ye!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6c3205e-d445-4f88-9545-3ea19fafd825_2348x562.png" width="1456" height="348" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f6c3205e-d445-4f88-9545-3ea19fafd825_2348x562.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:348,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!c4Ye!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6c3205e-d445-4f88-9545-3ea19fafd825_2348x562.png 424w, https://substackcdn.com/image/fetch/$s_!c4Ye!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6c3205e-d445-4f88-9545-3ea19fafd825_2348x562.png 848w, https://substackcdn.com/image/fetch/$s_!c4Ye!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6c3205e-d445-4f88-9545-3ea19fafd825_2348x562.png 1272w, https://substackcdn.com/image/fetch/$s_!c4Ye!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6c3205e-d445-4f88-9545-3ea19fafd825_2348x562.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>Because we deployed the whole coding agent to Modal (serving the LLM, the sandbox, and the harness), a pertinent question is whether it&#8217;s worth going full serverless versus choosing good old providers such as GCP or AWS.</p><p>As always, it depends.</p><h2>When should we go serverless?</h2><p>First, <strong>serverless simplifies infrastructure</strong>: one command to deploy, automatic scale up and down, nothing billed while idle, and CPUs or GPUs one argument away.</p><p>Under <a href="https://modal.com/?source=decodingai&amp;campaign=harnesseng">Modal</a>, you own no machines. On a hyperscaler like GCP or AWS, you maintain virtual machines plus managed services for scaling and monitoring. Bare-metal GPU clouds like RunPod and Lambda provide the cheapest hourly compute and full control, leaving every orchestrator and daemon for you to build.</p><p>In other words, if you choose an option other than serverless, you need to be prepared to invest time and resources in setting up and monitoring your infrastructure. For many small teams or early projects, that&#8217;s simply not worth it.</p><p><strong>Now what about pricing?</strong> Isn&#8217;t <a href="https://modal.com/blog/how-to-price-serverless?source=decodingai&amp;campaign=harnesseng">serverless</a> a lot pricier than hyperscalers or bare metal?</p><p>Per H100-hour, on demand, at the time of writing:<br>(That can serve a 7 B to 32B model at high throughput)</p><ul><li><p><a href="https://modal.com/pricing?source=decodingai&amp;campaign=harnesseng">Modal</a> &#8776; 3.95 (<em>serverless</em>)</p></li><li><p><a href="https://www.runpod.io/pricing">RunPod</a> &#8776; $3.49 (neocloud)</p></li><li><p><a href="https://lambda.ai/service/gpu-cloud">Lambda</a> &#8776; $3.99 (neocloud)</p></li><li><p><a href="https://instances.vantage.sh/aws/ec2/p5.4xlarge">AWS p5.4xlarge</a> &#8776; $6.88 on-demand, &#8776; $2.63 spot (1&#215;H100) (hyperscaler)</p></li></ul><p>So, as you can see, only RunPod VMs are cheaper than serverless. Plus, with serverless, you pay only for what you use, as it automatically scales to 0 when idle (i.e., $0). The LLM endpoint, the remote sandboxes, the app itself. Everything. If your app mostly depends on bursty agent work, serverless fits like a glove.</p><p>On the other side of the spectrum, if you would need access only to interactive TUIs that run 24/7 by your team (hopefully!), you might want to consider other options.</p><p>As a small team, I usually start serverless and rent/buy GPUs only when I really need to invest in my own infrastructure.</p><h2>Running swarms of remote agents</h2><p>Now, how does this design map to working on multiple coding projects, each with multiple tickets?</p><p>A background job can pull tickets from Linear, implement them overnight, and leave PRs waiting for your morning review. We can model this via the cron job or a <a href="https://linear.app/developers/agents">Linear agent</a> and our webhook, which lists tickets tagged for the agent and passes along the ticket text, repo URL, and other metadata.</p><p>Modal spawns a dedicated container for each ticket. Each Decode session clones its repo into its own sandbox, implements the ticket, commits, pushes a <code>decode/&lt;session-id&gt;</code> branch, and opens a PR, so you review finished work instead of watching agents run.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!o7Mz!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb782f29-d603-4cd5-8772-f9438087f714_1200x798.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!o7Mz!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb782f29-d603-4cd5-8772-f9438087f714_1200x798.png 424w, https://substackcdn.com/image/fetch/$s_!o7Mz!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb782f29-d603-4cd5-8772-f9438087f714_1200x798.png 848w, https://substackcdn.com/image/fetch/$s_!o7Mz!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb782f29-d603-4cd5-8772-f9438087f714_1200x798.png 1272w, https://substackcdn.com/image/fetch/$s_!o7Mz!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb782f29-d603-4cd5-8772-f9438087f714_1200x798.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!o7Mz!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb782f29-d603-4cd5-8772-f9438087f714_1200x798.png" width="1200" height="798" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/eb782f29-d603-4cd5-8772-f9438087f714_1200x798.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:798,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;N projects, N tickets, one agent per ticket &#8212; every agent opens its own PR against its own repo.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="N projects, N tickets, one agent per ticket &#8212; every agent opens its own PR against its own repo." title="N projects, N tickets, one agent per ticket &#8212; every agent opens its own PR against its own repo." srcset="https://substackcdn.com/image/fetch/$s_!o7Mz!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb782f29-d603-4cd5-8772-f9438087f714_1200x798.png 424w, https://substackcdn.com/image/fetch/$s_!o7Mz!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb782f29-d603-4cd5-8772-f9438087f714_1200x798.png 848w, https://substackcdn.com/image/fetch/$s_!o7Mz!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb782f29-d603-4cd5-8772-f9438087f714_1200x798.png 1272w, https://substackcdn.com/image/fetch/$s_!o7Mz!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb782f29-d603-4cd5-8772-f9438087f714_1200x798.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Integrating the headless harness to pull and implement tickets from our Notion/Linear projects overnight.</em></figcaption></figure></div><p>Each ticket session starts from scratch and is completely independent of the others. Ten tickets run in ten containers. It is important to model dependencies between tickets to know what to implement in parallel or sequentially.</p><p><a href="https://modal.com/blog/how-ramp-built-a-full-context-background-coding-agent-on-modal?source=decodingai&amp;campaign=harnesseng">Ramp</a> uses the same strategy at production scale with a routing queue and session locks. Review-ready PRs come out, and roughly half of Ramp&#8217;s merged PRs use this strategy. Which is huge for a fintech company that needs to be really careful about what code it pushes.</p><p>On top of running multiple parallel agents, you can take this step further and run multiple parallel subagents within a single harness session.</p><h2>One orchestrator, many GPU sandboxes</h2><p>Let&#8217;s assume that we give a coding agent a task to fine-tune a Liquid LFM2.5 model.</p><p>It needs to run several fine-tuning experiments in parallel, push each to an experiment tracker, compare them, and let the next round optimize on the last until the target metric is reached. You fire one headless run on Modal, the <strong>orchestrator</strong>, with the task <em>&#8220;get eval accuracy above X on this dataset.&#8221;</em></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Gd6u!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F95222bfb-fb1e-4117-b6e1-95009979c6d4_1200x669.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Gd6u!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F95222bfb-fb1e-4117-b6e1-95009979c6d4_1200x669.png 424w, https://substackcdn.com/image/fetch/$s_!Gd6u!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F95222bfb-fb1e-4117-b6e1-95009979c6d4_1200x669.png 848w, https://substackcdn.com/image/fetch/$s_!Gd6u!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F95222bfb-fb1e-4117-b6e1-95009979c6d4_1200x669.png 1272w, https://substackcdn.com/image/fetch/$s_!Gd6u!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F95222bfb-fb1e-4117-b6e1-95009979c6d4_1200x669.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!Gd6u!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F95222bfb-fb1e-4117-b6e1-95009979c6d4_1200x669.png" width="1200" height="669" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/95222bfb-fb1e-4117-b6e1-95009979c6d4_1200x669.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:669,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;One orchestrator on Modal, N sandboxes, one experiment tracker &#8212; a loop that repeats with the best parameters.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="One orchestrator on Modal, N sandboxes, one experiment tracker &#8212; a loop that repeats with the best parameters." title="One orchestrator on Modal, N sandboxes, one experiment tracker &#8212; a loop that repeats with the best parameters." srcset="https://substackcdn.com/image/fetch/$s_!Gd6u!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F95222bfb-fb1e-4117-b6e1-95009979c6d4_1200x669.png 424w, https://substackcdn.com/image/fetch/$s_!Gd6u!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F95222bfb-fb1e-4117-b6e1-95009979c6d4_1200x669.png 848w, https://substackcdn.com/image/fetch/$s_!Gd6u!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F95222bfb-fb1e-4117-b6e1-95009979c6d4_1200x669.png 1272w, https://substackcdn.com/image/fetch/$s_!Gd6u!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F95222bfb-fb1e-4117-b6e1-95009979c6d4_1200x669.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Using an orchestrator agent and multiple subagents plugged into remote sandboxes to fine-tune LLMs.</em></figcaption></figure></div><p>It plans a batch of experiments (learning rates, LoRA ranks, data mixes) and fans it out into multiple subagents. Each child&#8217;s tools run in its own Modal remote sandbox created with a GPU spec (eg <code>gpu="H200:4"</code>), so <code>bash</code> trains on an H200 while the orchestrator stays on a CPU container.</p><p>The orchestrator reads each run&#8217;s metrics, keeps the best configuration, plans the next batch, and stops when it meets the target or hits other thresholds, such as cost or max iterations. You wake up to a leaderboard and a winning checkpoint, not five terminals.</p><p>More on this in <a href="https://www.decodingai.com/p/run-coding-agents-safely">Lesson 3</a> and <a href="https://www.decodingai.com/p/subagents-are-context-engineering">Lesson 5</a>.</p><h2>Next steps</h2><p>Now that we&#8217;ve seen how to run swarms of agents in the cloud, it&#8217;s time to evaluate the coding agent and build the evals harness. In <a href="https://www.decodingai.com/p/evaluate-ai-agents-benchmarks-regression-tests">Lesson 7</a>, we will leverage this infrastructure to run benchmarks, regression tests, and online evals at scale.</p><div class="callout-block" data-callout="true"><p>&#129489;&#8205;&#128187; <strong>Clone the <a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course/tree/main">course repo</a></strong>, follow the <strong><a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course#-running-the-code">deploy runbook</a></strong><a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course#-running-the-code"> </a>(<code>running_the_code/04_deploy.md</code>), deploy the agent via <strong><span data-color="#c02f26" style="color: rgb(192, 47, 38);">decode remote deploy once</span></strong> and then put it to work.</p></div><p>Here is the course roadmap, lesson by lesson (see all in <a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course">GitHub</a>):</p><ol><li><p><a href="https://www.decodingai.com/p/building-a-coding-agent-from-scratch-system-design">Building a Coding Agent From Scratch</a></p></li><li><p><a href="https://www.decodingai.com/p/the-coding-agent-loop">The Bare-Bones Coding Agent Loop</a></p></li><li><p><a href="https://www.decodingai.com/p/run-coding-agents-safely">From a Raw Shell to a Sandboxed Coding Agent</a></p></li><li><p><a href="https://www.decodingai.com/p/context-engineering-for-coding-agents">Context Engineering for Coding Agents</a></p></li><li><p><a href="https://www.decodingai.com/p/subagents-are-context-engineering">Subagents Are Context Engineering</a></p></li><li><p><strong>Swarm of Remote Agents</strong> <strong>&#8592; </strong><em><strong>You are here</strong></em></p></li><li><p><a href="https://www.decodingai.com/p/evaluate-ai-agents-benchmarks-regression-tests">Agent Evals 101</a></p></li><li><p><a href="https://www.decodingai.com/p/transform-agent-traces-into-regression-cases">Turn Your Agent&#8217;s Failures Into a Regression Suite</a></p></li></ol><p><em>But here is what I&#8217;m wondering:</em></p><blockquote><p><em><strong>What would you give a coding agent to do overnight, without wasting your time and tokens?</strong></em></p></blockquote><p><em>Click the button below and tell me. I read every response.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://www.decodingai.com/p/coding-agents-in-remote-headless/comments&quot;,&quot;text&quot;:&quot;Leave a comment&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://www.decodingai.com/p/coding-agents-in-remote-headless/comments"><span>Leave a comment</span></a></p><div><hr></div><p><em>Enjoyed the article? The most sincere compliment is to restack this for your readers.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://www.decodingai.com/p/coding-agents-in-remote-headless?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;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://www.decodingai.com/p/coding-agents-in-remote-headless?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p><div><hr></div><p><em>Special thanks to <strong><a href="https://modal.com?source=decodingai&amp;campaign=harnesseng">Modal</a></strong>, <strong><a href="https://www.comet.com/site/?utm_source=newsletter&amp;utm_medium=partner&amp;utm_campaign=paul&amp;utm_content=coding_agent_course">Opik (by Comet)</a></strong>, and <strong><a href="https://www.zenml.io/product/kitaru?utm_source=decodingai&amp;utm_medium=referral&amp;utm_campaign=coding-agent-course&amp;utm_content=brand">Kitaru (by ZenML)</a></strong> for sponsoring this open-source course and keeping it free!</em></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Uq-1!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Uq-1!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 424w, https://substackcdn.com/image/fetch/$s_!Uq-1!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 848w, https://substackcdn.com/image/fetch/$s_!Uq-1!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 1272w, https://substackcdn.com/image/fetch/$s_!Uq-1!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!Uq-1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png" width="1200" height="400" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:400,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:69533,&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://www.decodingai.com/i/207400663?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.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_!Uq-1!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 424w, https://substackcdn.com/image/fetch/$s_!Uq-1!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 848w, https://substackcdn.com/image/fetch/$s_!Uq-1!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 1272w, https://substackcdn.com/image/fetch/$s_!Uq-1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><div><hr></div><div class="callout-block" data-callout="true"><h4>Whenever you&#8217;re ready, here is how I can help you</h4><p><em>Go from agent user to agent builder.</em> Master the foundations of AI agents and turn fragile demo code into reliable, production-ready systems with my course, <strong><a href="https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering">Agent Engineering: Building Multi-Agent Systems</a></strong> (made with Towards AI).</p><p>35 lessons. Pure foundations from scratch. 4 mini-projects. 2 production systems. A certificate and direct access to me &amp; industry experts in our Discord.</p><p>Built for software and data professionals transitioning into AI engineering. <em>Rated 5/5 with 300+ students. The first 7 lessons are free:</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering&quot;,&quot;text&quot;:&quot;Start here&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering"><span>Start here</span></a></p><p><em>Not ready to commit?</em> Start with our <strong><a href="https://email-course.towardsai.net/?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering">free Agent AI Engineering Guide</a></strong>, a 6-day email course on the mistakes that silently break AI agents in production.</p></div><div><hr></div><h2>Images &amp; videos</h2><p>If not otherwise stated, all images and videos are created by the author.</p>]]></content:encoded></item><item><title><![CDATA[From 1 Bloated Context Window to 6 Scoped Subagents]]></title><description><![CDATA[The harness determines what your orchestrator agent never sees, not the model.]]></description><link>https://www.decodingai.com/p/subagents-are-context-engineering</link><guid isPermaLink="false">https://www.decodingai.com/p/subagents-are-context-engineering</guid><dc:creator><![CDATA[Paul Iusztin]]></dc:creator><pubDate>Tue, 01 Sep 2026 05:00:29 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!EEH_!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c70a646-9a17-4434-83e2-9aee44333ec3_1376x768.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="callout-block" data-callout="true"><p><em><strong><span data-color="#c02f26" style="color: rgb(192, 47, 38);">Every AI application that wraps an agent is a harness!</span></strong><span data-color="#c02f26" style="color: rgb(192, 47, 38);"> </span></em></p><p>In LangChain&#8217;s Terminal-Bench experiment, changing only the harness (with the same model) moved a coding agent from ~30th place into the top 5: the harness, not the model, is what makes a coding agent good.</p><p>In the&nbsp;<strong>open-source course</strong>&nbsp;<strong><a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course">Building a Coding Agent From Scratch</a></strong>, you&#8217;ll build that harness from scratch in Python:&nbsp;<strong>Decode</strong>, a complete coding agent that grows lesson by lesson from a bare agent loop into a swarm of remote agents running in parallel in the cloud.</p><p><strong>Why?</strong>&nbsp;You&#8217;ll be able to engineer custom harnesses for your own AI products (the skill behind that leaderboard jump), and you&#8217;ll understand what Claude Code and Codex actually do under the hood, turning you into a power user.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ge05!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ge05!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 424w, https://substackcdn.com/image/fetch/$s_!ge05!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 848w, https://substackcdn.com/image/fetch/$s_!ge05!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 1272w, https://substackcdn.com/image/fetch/$s_!ge05!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ge05!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif" width="1200" height="630" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:630,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1446989,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/gif&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://www.decodingai.com/i/207400663?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ge05!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 424w, https://substackcdn.com/image/fetch/$s_!ge05!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 848w, https://substackcdn.com/image/fetch/$s_!ge05!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 1272w, https://substackcdn.com/image/fetch/$s_!ge05!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><strong>Lessons:</strong></p><ol><li><p><a href="https://www.decodingai.com/p/building-a-coding-agent-from-scratch-system-design">Building a Coding Agent From Scratch</a><strong> </strong></p></li><li><p><a href="https://www.decodingai.com/p/the-coding-agent-loop">The Bare-Bones Coding Agent Loop </a></p></li><li><p><a href="https://www.decodingai.com/p/run-coding-agents-safely">From a Raw Shell to a Sandboxed Coding Agent</a></p></li><li><p><a href="https://www.decodingai.com/p/context-engineering-for-coding-agents">Context Engineering for Coding Agents</a> </p></li><li><p><strong>Subagents Are Context Engineering</strong> <strong>&#8592; </strong><em><strong>You are here</strong></em></p></li><li><p><a href="https://www.decodingai.com/p/coding-agents-in-remote-headless">Swarm of Remote Agents</a></p></li><li><p><a href="https://www.decodingai.com/p/evaluate-ai-agents-benchmarks-regression-tests">Agent Evals 101</a></p></li><li><p><a href="https://www.decodingai.com/p/transform-agent-traces-into-regression-cases">Turn Your Agent&#8217;s Failures Into a Regression Suite</a></p></li></ol><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course&quot;,&quot;text&quot;:&quot;Full open-source course&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course"><span>Full open-source course</span></a></p><p><em>Special thanks to <strong><a href="https://modal.com/?source=decodingai&amp;campaign=harnesseng">Modal</a></strong>, <strong><a href="https://www.comet.com/site/?utm_source=workshop&amp;utm_medium=partner&amp;utm_campaign=paul&amp;utm_content=coding_agent_course">Opik (by Comet)</a></strong>, and <strong><a href="https://www.zenml.io/product/kitaru?utm_source=decodingai&amp;utm_medium=referral&amp;utm_campaign=coding-agent-course&amp;utm_content=brand">Kitaru (by ZenML)</a></strong> for sponsoring this open-source course and keeping it free!</em></p></div><h1>Lesson 5: Subagents Are Context Engineering</h1><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!EEH_!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c70a646-9a17-4434-83e2-9aee44333ec3_1376x768.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!EEH_!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c70a646-9a17-4434-83e2-9aee44333ec3_1376x768.png 424w, https://substackcdn.com/image/fetch/$s_!EEH_!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c70a646-9a17-4434-83e2-9aee44333ec3_1376x768.png 848w, https://substackcdn.com/image/fetch/$s_!EEH_!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c70a646-9a17-4434-83e2-9aee44333ec3_1376x768.png 1272w, https://substackcdn.com/image/fetch/$s_!EEH_!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c70a646-9a17-4434-83e2-9aee44333ec3_1376x768.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!EEH_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c70a646-9a17-4434-83e2-9aee44333ec3_1376x768.png" width="1376" height="768" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3c70a646-9a17-4434-83e2-9aee44333ec3_1376x768.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:768,&quot;width&quot;:1376,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;One ship, six scouts, every line runs home.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="One ship, six scouts, every line runs home." title="One ship, six scouts, every line runs home." srcset="https://substackcdn.com/image/fetch/$s_!EEH_!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c70a646-9a17-4434-83e2-9aee44333ec3_1376x768.png 424w, https://substackcdn.com/image/fetch/$s_!EEH_!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c70a646-9a17-4434-83e2-9aee44333ec3_1376x768.png 848w, https://substackcdn.com/image/fetch/$s_!EEH_!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c70a646-9a17-4434-83e2-9aee44333ec3_1376x768.png 1272w, https://substackcdn.com/image/fetch/$s_!EEH_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c70a646-9a17-4434-83e2-9aee44333ec3_1376x768.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>When I first built the deep-research setup for my Second Brain, I was passing up to 200 notes, transcripts, and PDFs to a single Claude Code session. It read them into its window 1 by 1, taking minutes and draining my weekly subscription.</p><p>So I split that into 6 researcher subagents per query, running in parallel, each dropping its internal state and returning only the final results to the orchestrator agent to avoid exploding the context window with noise. Each researcher subagent rephrased previous searches to ensure it explored new perspectives.</p><p><strong><span data-color="#c02f26" style="color: rgb(192, 47, 38);">Subagents are context engineering!</span></strong> For everyone serious about becoming a power user (or builder!) of coding agents or harnesses in general &#8212; Claude Code, Codex, Cursor, or a custom-built one &#8212; learning how to operate subagents is an essential skill. Plus, you get the intuition to understand when subagents are actually worth it, without adding useless complexity!</p><p>In Lesson 4, we explored Decode&#8217;s essentials (memory, skills, LSP servers, and compaction). Now it&#8217;s time to go into <strong>subagents</strong>, <strong>the Agents Catalog</strong> of personas, and <strong>parallel fan-out</strong>.</p><p>You will walk away understanding and building from scratch:</p><ul><li><p>Designing the protocol between the subagent and the parent agent.</p></li><li><p>Configuring a registry of agents.</p></li><li><p>Spinning out a swarm of agents without hitting your LLM provider&#8217;s rate limits.</p></li></ul><h2>Subagents baked into the harness</h2><p>A <strong>subagent</strong> is a child agent spawned by the primary agent for 1 scoped task, exploring in its own context and returning 1 compressed report. As Anthropic notes in their <a href="https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents">guide on effective context engineering</a>, a subagent can burn tens of thousands of tokens reading code and hand back only a distilled 1,000- to 2,000-token summary, keeping search noise out of the parent agent&#8217;s context window (the shape Claude Code uses, judging by its leaked implementation).</p><p>There are <strong>2 ways to spawn a subagent</strong>: calling an in-harness tool, or spawning the CLI via <code>bash</code> and <code>tmux</code>.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!FLqL!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faef57500-c424-4efc-8062-e86deb05606d_1200x558.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!FLqL!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faef57500-c424-4efc-8062-e86deb05606d_1200x558.png 424w, https://substackcdn.com/image/fetch/$s_!FLqL!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faef57500-c424-4efc-8062-e86deb05606d_1200x558.png 848w, https://substackcdn.com/image/fetch/$s_!FLqL!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faef57500-c424-4efc-8062-e86deb05606d_1200x558.png 1272w, https://substackcdn.com/image/fetch/$s_!FLqL!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faef57500-c424-4efc-8062-e86deb05606d_1200x558.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!FLqL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faef57500-c424-4efc-8062-e86deb05606d_1200x558.png" width="1200" height="558" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/aef57500-c424-4efc-8062-e86deb05606d_1200x558.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:558,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Where the child runs decides everything else &#8212; in-harness, the orchestrator and its Explore children live in one harness; with tmux, every child is a second harness of its own. Either way, each agent carries its own config.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Where the child runs decides everything else &#8212; in-harness, the orchestrator and its Explore children live in one harness; with tmux, every child is a second harness of its own. Either way, each agent carries its own config." title="Where the child runs decides everything else &#8212; in-harness, the orchestrator and its Explore children live in one harness; with tmux, every child is a second harness of its own. Either way, each agent carries its own config." srcset="https://substackcdn.com/image/fetch/$s_!FLqL!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faef57500-c424-4efc-8062-e86deb05606d_1200x558.png 424w, https://substackcdn.com/image/fetch/$s_!FLqL!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faef57500-c424-4efc-8062-e86deb05606d_1200x558.png 848w, https://substackcdn.com/image/fetch/$s_!FLqL!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faef57500-c424-4efc-8062-e86deb05606d_1200x558.png 1272w, https://substackcdn.com/image/fetch/$s_!FLqL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faef57500-c424-4efc-8062-e86deb05606d_1200x558.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Where the subagent runs: in-harness vs spinning up a different process using the harness&#8217;s CLI and tmux.</em></figcaption></figure></div><p>Decode uses a read-only tool: <code>agent(prompts: list[str]) -&gt; str</code>. It runs deterministic guards before spawning children, returning a <code>ModelRetry</code> (the tool&#8217;s way of sending the model a correction instead of a result) if the prompts are empty or if the number of concurrent requests exceeds 6.</p><p>The prompt steers the subagent toward a specific goal. That prompt is the only dynamic part. Everything else the child gets &#8212; its system prompt and its permissions &#8212; is static configuration that decides what it is allowed to do (exploration, code review, software engineering, etc.). More on this soon.</p><p><em>From <a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course/blob/main/src/decode/tools/agent.py">src/decode/tools/agent.py</a>:</em></p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">async def agent(ctx: RunContext[AgentDeps], prompts: list[str]) -&gt; str:
    if not prompts:
        raise ModelRetry("The agent tool needs at least one exploration prompt. ...")
    if len(prompts) &gt; MAX_FANOUT_PROMPTS:
        raise ModelRetry(f"You asked for {len(prompts)} subagents; the limit is {MAX_FANOUT_PROMPTS} per call. ...")
    _check_substance(prompts)

    child_max_bytes = 16_000 // len(prompts)
    sections = await asyncio.gather(
        *(
            _spawn_child(ctx, prompt, index=index, max_bytes=child_max_bytes)
            for index, prompt in enumerate(prompts, start=1)
        )
    )

    fold = "\n\n".join(
        f'## Subagent {index} &#8212; "{_label(prompt)}"\n\n{section}'
        for index, (prompt, section) in enumerate(zip(prompts, sections, strict=True), start=1)
    )

    return fold + SYNTHESIS_FOOTER</code></pre></div><p>When you run the <code>/demo-4-review-swarm</code> skill, 3 read-only <strong>Explore</strong> subagents review different sections of the active codebase and aggregate everything into a final report:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!VQb0!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F94d40e7c-3d5b-4321-858d-4a2af49406c6_914x206.png 424w, https://substackcdn.com/image/fetch/$s_!VQb0!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F94d40e7c-3d5b-4321-858d-4a2af49406c6_914x206.png 848w, https://substackcdn.com/image/fetch/$s_!VQb0!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F94d40e7c-3d5b-4321-858d-4a2af49406c6_914x206.png 1272w, https://substackcdn.com/image/fetch/$s_!VQb0!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F94d40e7c-3d5b-4321-858d-4a2af49406c6_914x206.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!VQb0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F94d40e7c-3d5b-4321-858d-4a2af49406c6_914x206.png" width="728" height="164.07877461706784" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/94d40e7c-3d5b-4321-858d-4a2af49406c6_914x206.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:&quot;normal&quot;,&quot;height&quot;:206,&quot;width&quot;:914,&quot;resizeWidth&quot;:728,&quot;bytes&quot;:71537,&quot;alt&quot;:&quot;&quot;,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:&quot;center&quot;,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!VQb0!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F94d40e7c-3d5b-4321-858d-4a2af49406c6_914x206.png 424w, https://substackcdn.com/image/fetch/$s_!VQb0!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F94d40e7c-3d5b-4321-858d-4a2af49406c6_914x206.png 848w, https://substackcdn.com/image/fetch/$s_!VQb0!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F94d40e7c-3d5b-4321-858d-4a2af49406c6_914x206.png 1272w, https://substackcdn.com/image/fetch/$s_!VQb0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F94d40e7c-3d5b-4321-858d-4a2af49406c6_914x206.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>In <a href="https://www.comet.com/site/?utm_source=newsletter&amp;utm_medium=partner&amp;utm_campaign=paul&amp;utm_content=coding_agent_course">Opik</a>, our observability tool, the whole call shows up as 1 <code>agent</code> tool span with 3 input prompts:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!iV6B!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa28ab92-e46f-4b9c-baa6-19ce8c0f4060_2838x1610.png" data-component-name="Image2ToDOM"><div class="image2-inset image2-full-screen"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!iV6B!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa28ab92-e46f-4b9c-baa6-19ce8c0f4060_2838x1610.png 424w, https://substackcdn.com/image/fetch/$s_!iV6B!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa28ab92-e46f-4b9c-baa6-19ce8c0f4060_2838x1610.png 848w, https://substackcdn.com/image/fetch/$s_!iV6B!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa28ab92-e46f-4b9c-baa6-19ce8c0f4060_2838x1610.png 1272w, https://substackcdn.com/image/fetch/$s_!iV6B!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa28ab92-e46f-4b9c-baa6-19ce8c0f4060_2838x1610.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!iV6B!,w_5760,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa28ab92-e46f-4b9c-baa6-19ce8c0f4060_2838x1610.png" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fa28ab92-e46f-4b9c-baa6-19ce8c0f4060_2838x1610.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:&quot;full&quot;,&quot;height&quot;:826,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:&quot;center&quot;,&quot;offset&quot;:false}" class="sizing-fullscreen" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!iV6B!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa28ab92-e46f-4b9c-baa6-19ce8c0f4060_2838x1610.png 424w, https://substackcdn.com/image/fetch/$s_!iV6B!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa28ab92-e46f-4b9c-baa6-19ce8c0f4060_2838x1610.png 848w, https://substackcdn.com/image/fetch/$s_!iV6B!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa28ab92-e46f-4b9c-baa6-19ce8c0f4060_2838x1610.png 1272w, https://substackcdn.com/image/fetch/$s_!iV6B!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa28ab92-e46f-4b9c-baa6-19ce8c0f4060_2838x1610.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><strong>The subagent report</strong> contract requires the subagent to make at least one tool call or return a non-empty result. If that&#8217;s not respected, the harness retries it. On the second failure, it returns a warning message.</p><p>All the surviving reports are truncated to <code>subagent_result_max_bytes // N</code> (16,000 bytes shared).</p><p>The harness appends the <code>SYNTHESIS_FOOTER</code> after the last section, instructing the parent to compile the N reports into 1 answer using prose plus an ASCII diagram (Mermaid only for genuine graphs, since the TUI renders Mermaid as raw source).</p><p><em>From <a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course/blob/main/src/decode/tools/agent.py">src/decode/tools/agent.py</a>:</em></p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">async def _spawn_child(
    ctx: RunContext[AgentDeps], prompt: str, *, index: int, max_bytes: int
) -&gt; str:
    from decode.tools.truncate import truncate

    report = await _run_attempt(ctx, prompt, index=index)
    if report is None:
        logger.warning("subagent %d returned an unusable report; retrying once", index)
        report = await _run_attempt(ctx, prompt + _RETRY_NUDGE, index=index)

    if report is None:
        logger.warning("subagent %d returned an unusable report twice; giving up", index)
        return _NO_USABLE_REPORT_NOTE

    return truncate(report, max_lines=2000, max_bytes=max_bytes).text</code></pre></div><p>A child is the same Pydantic AI <code>Agent</code> re-entered with fresh, narrowed agent dependencies <code>AgentDeps</code>. It cannot recurse without the <code>agent</code> tool, cannot stop to ask you a question without <code>ask_user</code>, and runs in bypass permission mode because it is read-only. Its messages are ephemeral, as the parent&#8217;s history keeps only the spawn call and the report.</p><p>What is not built is an in-flight queue that lets the parent agent talk to the subagent mid-run, similar to how we design the dynamics between the TUI and the main runtime. To implement it, we can repeat the same architecture as in <a href="https://www.decodingai.com/p/the-coding-agent-loop">Lesson 2</a>.</p><p>Alternatively, there is the approach from Mario Zechner&#8217;s <a href="https://mariozechner.at/posts/2025-11-30-pi-coding-agent/">post on building Pi</a>, which treats subagents as black boxes and runs them by calling <code>pi</code> from <code>bash</code> under <code>tmux</code>. The orchestrator is simply the session that manages the <code>tmux</code> windows. State is passed between the agents via Markdown files. When you opt for this option, you usually need to manage the tmux-related business logic in a <code>/subagent-tmux</code> skill.</p><blockquote><p>&#128161;<a href="https://github.com/tmux/tmux">tmux</a> is a terminal multiplexer. It lets you switch easily between several programs in one terminal, detach them (they keep running in the background) and reattach them to a different terminal.</p></blockquote><p>Decode supports this too: the headless entrypoint <code>decode run "&lt;task&gt;"</code> is a self-spawn primitive that we illustrate in the demo skill <code>/demo-5-sandbox-feature-pr</code>, which launches a second Decode inside a sandboxed clone of its own repo &#8212; a whole harness as the child, not a nested run:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;bash&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-bash">decode run "Where is the agent tool function? Report the path with file:line."</code></pre></div><p>The 2 options are not competing versions of the same thing. The in-harness tool is a <strong>context</strong> primitive, while tmux is a <strong>process</strong> primitive.</p><p><strong>Keeping subagents in the harness gives you:</strong></p><ul><li><p><strong>The cheapest subagent.</strong> A loop re-entry, not a process: no cold start, no serialization. Claude Code goes further: because the parent and child run the same loop, the summary fork reuses the parent&#8217;s prompt cache.</p></li><li><p><strong>A context window that stays clean by construction.</strong> The child burns its tens of thousands of tokens somewhere you never see, and search noise never enters the parent&#8217;s window.</p></li><li><p><strong>The budget in 1 place.</strong> The width cap, the semaphore, the per-child request limit, the retries, and the child&#8217;s narrowed permissions are all yours to enforce in the tool &#8212; not scattered across orchestration scripts.</p></li></ul><p><strong>Spawning the CLI under </strong><code>tmux</code><strong> gives you:</strong></p><ul><li><p><strong>A real boundary.</strong> An OS process, not an allowlist. The child cannot access the parent&#8217;s memory, and it composes with <code>bwrap</code>, <code>sandbox-exec</code>, or a container without extra work.</p></li><li><p><strong>Full observability, live.</strong> You can watch the raw output in a terminal, attach, and co-drive the child mid-run instead of trusting a summary of a summary. Mario Zechner&#8217;s objection to the built-in tool is exactly this: it is <em>&#8220;a black box within a black box&#8221;</em>.</p></li><li><p><strong>Children that outlive the parent.</strong> Each is a real session on disk, resumable and inspectable, with its state stored in plain Markdown files.</p></li></ul><p>Decode uses the <code>agent</code> tool by default because read-only exploration does not need separate process overhead, and runs as a CLI program (with or without tmux) when the parent needs a remote sandbox or you need to watch the child work.</p><p>Every child above ran as an exploration agent, which is configurable via the agent catalog alongside our other <strong>personas</strong>.</p><h2>The agents catalog</h2><p>Depending on which agent you run, you need a mechanism to configure it.</p><p>Decode scopes a few of its core agents in <strong>the Agents Catalog</strong>. Each persona is a bundled Markdown file with YAML front matter (name, description, a tools allowlist, a default mode, optional allow/deny rules, and a subagent flag) plus the agent-specific system prompt in the file&#8217;s body. This list can be extended with your own agents, similar to Claude Code.</p><p>You can spin up the harness with different agents steering the agent loop by running:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;bash&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-bash">decode --agent build # or plan, code-reviewer</code></pre></div><p>Or switch directly from the TUI:</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!9Do7!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F18fd2419-711c-4d4c-b2cd-7c9b9f4ce3d2_829x124.png 424w, https://substackcdn.com/image/fetch/$s_!9Do7!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F18fd2419-711c-4d4c-b2cd-7c9b9f4ce3d2_829x124.png 848w, https://substackcdn.com/image/fetch/$s_!9Do7!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F18fd2419-711c-4d4c-b2cd-7c9b9f4ce3d2_829x124.png 1272w, https://substackcdn.com/image/fetch/$s_!9Do7!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F18fd2419-711c-4d4c-b2cd-7c9b9f4ce3d2_829x124.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!9Do7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F18fd2419-711c-4d4c-b2cd-7c9b9f4ce3d2_829x124.png" width="829" height="124" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/18fd2419-711c-4d4c-b2cd-7c9b9f4ce3d2_829x124.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:124,&quot;width&quot;:829,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!9Do7!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F18fd2419-711c-4d4c-b2cd-7c9b9f4ce3d2_829x124.png 424w, https://substackcdn.com/image/fetch/$s_!9Do7!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F18fd2419-711c-4d4c-b2cd-7c9b9f4ce3d2_829x124.png 848w, https://substackcdn.com/image/fetch/$s_!9Do7!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F18fd2419-711c-4d4c-b2cd-7c9b9f4ce3d2_829x124.png 1272w, https://substackcdn.com/image/fetch/$s_!9Do7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F18fd2419-711c-4d4c-b2cd-7c9b9f4ce3d2_829x124.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>This resets the agent&#8217;s system prompt and the set of allowed tools. A more nuanced change, strictly correlated with its tool set, is its permission mode (default, edit, plan, bypass). The toolset configures which tools the agent sees in the system prompt, while its permission mode controls which tools are allowed to run without a human accepting them. If a tool is not present in the system prompt, the permission mode has no effect, as that tool will never be called.</p><p>The <code>build</code> persona is our default primary agent: all 15 tools, <code>mode: default</code>, and a generic coding assistant prompt.</p><p><em>From <a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course/blob/main/src/decode/agents/builtin/build.md">src/decode/agents/builtin/build.md</a>:</em></p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;markdown&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-markdown">---
name: build
description: A capable coding agent that reads, edits, runs commands, and ships changes.
tools:
  - read
  - glob
  - grep
  - lsp
  - write
  - edit
  - bash
  - todo_write
  - web_fetch
  - ask_user
  - enter_plan_mode
  - exit_plan_mode
  - sleep
  - skill
  - agent
mode: default
---
You are the build agent &#8212; a capable, hands-on coding assistant working inside the user's project.

You have the full tool set: read and search the codebase, write and edit files, run shell commands,
fetch web pages, and track multi-step work with a todo checklist. Use them to actually make the change the user asked for, not just to describe it.

Work like a careful engineer:

- Understand before you act. Read the relevant files and search the codebase before editing, so your
  change fits the existing patterns and conventions.
- Delegate broad exploration. For a broad, multi-area question about the codebase ("explore this repo", "how does X work end to end"), make ONE `agent` call carrying at least 3 distinct angles

... # Rest of the prompt

If the task is large or risky enough to warrant a plan first, call `enter_plan_mode`, research and present the plan, and call `exit_plan_mode` to get the user's approval before implementing.

Be concise. Explain what you changed and why, not every step you took.</code></pre></div><p>The <code>plan</code> agent drops <code>write</code>, <code>edit</code>, and <code>bash</code>, starting in <code>mode: plan</code>, so any writes are denied. <code>code-reviewer</code> drops <code>write</code> and <code>edit</code> but keeps <code>bash</code> with <code>allow: ["bash(git *)"]</code>, auto-allowing <code>git diff</code>, <code>git log</code>, and <code>git show</code> while prompting on other shell commands. Both delegate exploration to subagents.</p><p><code>explore</code> is the only configuration we will use for the subagent, via <code>subagent: true</code>. Thus, the only way it runs is as a child of the <code>agent</code> tool. Its allowlist is exactly <code>read</code>, <code>glob</code>, <code>grep</code>, and <code>lsp</code> &#8212; no <code>bash</code>, <code>web_fetch</code>, or <code>ask_user</code> (which would deadlock the fan-out), and no <code>agent</code> (to avoid recursion):</p><p><em>From <a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course/blob/main/src/decode/agents/builtin/explore.md">src/decode/agents/builtin/explore.md</a>:</em></p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;markdown&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-markdown">---
name: explore
description: Reads the codebase and answers questions about it without changing anything.
tools:
  - read
  - glob
  - grep
  - lsp
subagent: true
mode: default
---
You are the explore agent &#8212; a read-only subagent spawned to investigate one scoped question about
the codebase and report back. You never change anything.

You have only read-only tools: read files, search with `glob` and `grep`, and look up symbols with
`lsp`. You cannot write files, run shell commands, fetch the web, or ask a question back &#8212; your whole
job is to read the code and explain what it actually does.

Your final message IS your report. Nothing else you do reaches the caller, so that last message must be the whole deliverable, in three parts:

... # Rest of the prompt</code></pre></div><p>Now, instead of running the exploration agents 1 by 1, let&#8217;s see how we can run 6 of them in parallel via the fan-out algorithm without hitting your provider&#8217;s rate limits or flooding the context window.</p><h2>Parallel fan-out</h2><p>When building the memory-extraction pipeline for my digital twin&#8217;s GraphRAG system, I found the 100-document batch processor written as a serial loop: <code>for doc in docs: await extract_document_task(...)</code>. That ran 1 document at a time, dragging out the run for hours. Wrapping those 100 extractions under <code>asyncio.gather()</code> and a <code>Semaphore(5)</code> meant 5 ran at a time. Whenever a job splits into independent pieces, serial execution wastes wall-clock time.</p><p><strong>Fan-out</strong> is 1 <code>agent(prompts=[...])</code> call that spawns N Explore children concurrently and folds everything back into a single aggregate &#8212; parallelism the harness guarantees, not a courtesy the model may or may not extend by emitting N tool calls.</p><p>This strategy works incredibly well with similar independent tasks, where each agent minds its own business, such as reading documents from a dataset, conducting in-depth research, or exploring different segments of a codebase (as we do).</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!dmBx!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02529a97-390b-4fca-8ac4-a5c5632cd359_1200x638.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!dmBx!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02529a97-390b-4fca-8ac4-a5c5632cd359_1200x638.png 424w, https://substackcdn.com/image/fetch/$s_!dmBx!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02529a97-390b-4fca-8ac4-a5c5632cd359_1200x638.png 848w, https://substackcdn.com/image/fetch/$s_!dmBx!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02529a97-390b-4fca-8ac4-a5c5632cd359_1200x638.png 1272w, https://substackcdn.com/image/fetch/$s_!dmBx!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02529a97-390b-4fca-8ac4-a5c5632cd359_1200x638.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!dmBx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02529a97-390b-4fca-8ac4-a5c5632cd359_1200x638.png" width="1200" height="638" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/02529a97-390b-4fca-8ac4-a5c5632cd359_1200x638.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:638,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;The fan-out path &#8212; the orchestrator spawns N children, four run while the rest wait, each returns one compressed report, and the reports fold into a single aggregate that comes back as one tool result.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="The fan-out path &#8212; the orchestrator spawns N children, four run while the rest wait, each returns one compressed report, and the reports fold into a single aggregate that comes back as one tool result." title="The fan-out path &#8212; the orchestrator spawns N children, four run while the rest wait, each returns one compressed report, and the reports fold into a single aggregate that comes back as one tool result." srcset="https://substackcdn.com/image/fetch/$s_!dmBx!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02529a97-390b-4fca-8ac4-a5c5632cd359_1200x638.png 424w, https://substackcdn.com/image/fetch/$s_!dmBx!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02529a97-390b-4fca-8ac4-a5c5632cd359_1200x638.png 848w, https://substackcdn.com/image/fetch/$s_!dmBx!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02529a97-390b-4fca-8ac4-a5c5632cd359_1200x638.png 1272w, https://substackcdn.com/image/fetch/$s_!dmBx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02529a97-390b-4fca-8ac4-a5c5632cd359_1200x638.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>The fan-out algorithm: The orchestrator spawns N children, four run while the rest wait, each returns one compressed report, and the reports fold into a single aggregate that comes back as one tool result.</em></figcaption></figure></div><p>We have to chain 3 functions: <code>agent</code> gathers the <code>_spawn_child</code> calls, <code>_spawn_child</code> handles the retries, and <code>_run_attempt</code> runs the child itself.</p><p>Inside the tool, <code>asyncio.gather</code> (run these coroutines concurrently and return their results in order) runs <code>_spawn_child</code> for each prompt under an <code>asyncio.Semaphore</code> (a counter that lets at most N coroutines through at once) set to <code>subagent_max_parallel</code> = 4. We need the semaphore so a single fan-out does not hit the provider&#8217;s rate limits with too many requests at once.</p><p>When you own your infra, such as hosting your open-weight models like Qwen on <a href="https://modal.com/blog/introducing-auto-endpoints?source=decodingai&amp;campaign=harnesseng">Modal Auto Endpoints</a>, the bottleneck is your infra, but when using an LLM API such as OpenRouter, OpenAI, or Gemini, you have strict limits on how many requests you can make per minute. Usually you need to contact them to negotiate higher request limits. Owning the endpoint skips that negotiation entirely, and bursty fan-outs are the exact workload <a href="https://modal.com/blog/how-to-price-serverless?source=decodingai&amp;campaign=harnesseng">serverless GPU pricing</a> was designed for.</p><p><em>From <a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course/blob/main/src/decode/tools/agent.py">src/decode/tools/agent.py</a>:</em></p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">async def agent(ctx: RunContext[AgentDeps], prompts: list[str]) -&gt; str:
    ...
    sections = await asyncio.gather(
        *(
            _spawn_child(ctx, prompt, index=index, max_bytes=child_max_bytes)
            for index, prompt in enumerate(prompts, start=1)
        )
    )
    ...


async def _spawn_child(
    ctx: RunContext[AgentDeps], prompt: str, *, index: int, max_bytes: int
) -&gt; str:
    ...
    try:
        report = await _run_attempt(ctx, prompt, index=index)
        if report is None:
            ...
            report = await _run_attempt(ctx, prompt + _RETRY_NUDGE, index=index)
    ...</code></pre></div><p>Inside <code>_run_attempt</code>, the child receives its narrowed <code>AgentDeps</code>, acquires the semaphore, and re-enters the primary <code>Agent</code>.</p><p><em>From <a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course/blob/main/src/decode/tools/agent.py">src/decode/tools/agent.py</a>:</em></p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">async def _run_attempt(ctx: RunContext[AgentDeps], prompt: str, *, index: int) -&gt; str | None:
    explore = load_agent(_SUBAGENT_PERSONA)

    child_emit = _make_child_emit(ctx.deps, index)
    child_deps = AgentDeps(
        cwd=ctx.deps.cwd,
        harness_home=ctx.deps.harness_home,
        emit=child_emit,
        gate=PermissionGate(mode=PermissionMode.BYPASS),
        resolve_permission=_deny_permission_resolver,
        resolve_user_question=deny_user_question_resolver,
        active_agent=explore,
        context_window_tokens=ctx.deps.context_window_tokens,
    )

    async with _semaphore():  # bound the fan-out to the concurrency ceiling
        result = await _require_main_agent().run(
            prompt,
            deps=child_deps,
            usage_limits=UsageLimits(request_limit=25),
        )

    return _usable_report(result)</code></pre></div><p>Let&#8217;s see in <a href="https://www.comet.com/site/?utm_source=newsletter&amp;utm_medium=partner&amp;utm_campaign=paul&amp;utm_content=coding_agent_course">Opik</a>, based on our demo, where we explicitly chose to spawn 3 subagents, how each child nests inside the parent turn, showing its own spans with token counts and latency.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!L6BO!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd194e30b-467e-4df3-9867-f72358b46dd2_2908x1278.png" data-component-name="Image2ToDOM"><div class="image2-inset image2-full-screen"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!L6BO!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd194e30b-467e-4df3-9867-f72358b46dd2_2908x1278.png 424w, https://substackcdn.com/image/fetch/$s_!L6BO!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd194e30b-467e-4df3-9867-f72358b46dd2_2908x1278.png 848w, https://substackcdn.com/image/fetch/$s_!L6BO!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd194e30b-467e-4df3-9867-f72358b46dd2_2908x1278.png 1272w, https://substackcdn.com/image/fetch/$s_!L6BO!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd194e30b-467e-4df3-9867-f72358b46dd2_2908x1278.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!L6BO!,w_5760,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd194e30b-467e-4df3-9867-f72358b46dd2_2908x1278.png" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d194e30b-467e-4df3-9867-f72358b46dd2_2908x1278.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:&quot;full&quot;,&quot;height&quot;:640,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:&quot;center&quot;,&quot;offset&quot;:false}" class="sizing-fullscreen" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!L6BO!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd194e30b-467e-4df3-9867-f72358b46dd2_2908x1278.png 424w, https://substackcdn.com/image/fetch/$s_!L6BO!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd194e30b-467e-4df3-9867-f72358b46dd2_2908x1278.png 848w, https://substackcdn.com/image/fetch/$s_!L6BO!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd194e30b-467e-4df3-9867-f72358b46dd2_2908x1278.png 1272w, https://substackcdn.com/image/fetch/$s_!L6BO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd194e30b-467e-4df3-9867-f72358b46dd2_2908x1278.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>Our implementation via the <code>agent</code> tool currently works only by spinning up exploration agents on the same harness as the parent. But you can easily take this further by attaching different types of agents from the catalog, or by attaching them to remote sandboxes with a preconfigured setup or a GPU-enabled machine for inference/fine-tuning jobs, as we explained in <a href="https://www.decodingai.com/p/run-coding-agents-safely">Lesson 3</a> on sandboxing via Modal. In this <a href="https://modal.com/blog/how-ramp-built-a-full-context-background-coding-agent-on-modal?source=decodingai&amp;campaign=harnesseng">background agent&#8217;s case study</a>, Ramp uses this model to spawn child sessions via Modal remote sandboxes across all their repositories.</p><p>To implement a similar strategy with <code>tmux</code>, you would spin up N windows, each running a <code>decode run</code>, while the logic for gathering, budgeting, and retries that sits between the parent and subagents is yours to write.</p><h2>Next steps</h2><p>In my day-to-day workflow with Claude Code, I use the <code>.claude/agents/*.md</code> protocol via <a href="https://code.claude.com/docs/en/sub-agents">its agent tool</a> for small setups. My <a href="https://github.com/iusztinpaul/squid">Squid software factory</a> runs 1 software engineer agent and 1 tester agent at a time.</p><p>For real fan-outs with more than 10 agents on 1 task, I use Claude Code&#8217;s dynamic workflows feature, which spins up <code>.claude/agents/*.md</code> in parallel and manages all the glue logic. For repeatable use cases where I want to avoid keeping my business logic locked into Anthropic&#8217;s ecosystem, I move the code into dedicated Python CLI programs that I fully control, while using skills only as a thin wrapper on top to plug them into the harness.</p><p>I rarely reach for <code>tmux</code>, but since I want to own more of my harness, it&#8217;s a pattern I want to get better at.</p><div class="callout-block" data-callout="true"><p>&#129489;&#8205;&#128187; <span>We encourage you to&nbsp;</span><strong>clone our&nbsp;<a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course">course repo</a></strong><span>, open your terminal, type </span><strong><span data-color="#38761d" style="color: rgb(56, 118, 29);">&#8221;decode&#8221;</span></strong>,<strong> </strong>and test out the coding agent.</p></div><p>In the <a href="https://www.decodingai.com/p/coding-agents-in-remote-headless">next lesson</a>, we&#8217;ll strip the TUI and deploy it to Modal, triggering it via the CLI, cron jobs, and webhooks.</p><p><span>Here is the</span><strong> course roadmap, </strong><span>lesson by lesson </span><em><span>(</span><a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course#-course-outline">see all in GitHub</a></em><span>):</span></p><ol><li><p><a href="https://www.decodingai.com/p/building-a-coding-agent-from-scratch-system-design">Building a Coding Agent From Scratch</a><strong> </strong></p></li><li><p><a href="https://www.decodingai.com/p/the-coding-agent-loop">The Bare-Bones Coding Agent Loop </a></p></li><li><p><a href="https://www.decodingai.com/p/run-coding-agents-safely">From a Raw Shell to a Sandboxed Coding Agent</a></p></li><li><p><a href="https://www.decodingai.com/p/context-engineering-for-coding-agents">Context Engineering for Coding Agents</a> </p></li><li><p><strong>Subagents Are Context Engineering</strong> <strong>&#8592; </strong><em><strong>You are here</strong></em></p></li><li><p><a href="https://www.decodingai.com/p/coding-agents-in-remote-headless">Swarm of Remote Agents</a></p></li><li><p><a href="https://www.decodingai.com/p/evaluate-ai-agents-benchmarks-regression-tests">Agent Evals 101</a></p></li><li><p><a href="https://www.decodingai.com/p/transform-agent-traces-into-regression-cases">Turn Your Agent&#8217;s Failures Into a Regression Suite</a></p></li></ol><p><em>But here is what I&#8217;m wondering:</em></p><blockquote><p><em><strong>When you need ten agents on the same job, do you use your harness&#8217;s subagent tool, or tmux?</strong></em></p></blockquote><p><em>Click the button below and tell me. I read every response.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://www.decodingai.com/p/subagents-are-context-engineering/comments&quot;,&quot;text&quot;:&quot;Leave a comment&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://www.decodingai.com/p/subagents-are-context-engineering/comments"><span>Leave a comment</span></a></p><div><hr></div><p><em>Enjoyed the article? The most sincere compliment is to restack this for your readers.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://www.decodingai.com/p/subagents-are-context-engineering?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;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://www.decodingai.com/p/subagents-are-context-engineering?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p><div><hr></div><p><em>Special thanks to <strong><a href="https://modal.com?source=decodingai&amp;campaign=harnesseng">Modal</a></strong>, <strong><a href="https://www.comet.com/site/?utm_source=newsletter&amp;utm_medium=partner&amp;utm_campaign=paul&amp;utm_content=coding_agent_course">Opik (by Comet)</a></strong>, and <strong><a href="https://www.zenml.io/product/kitaru?utm_source=decodingai&amp;utm_medium=referral&amp;utm_campaign=coding-agent-course&amp;utm_content=brand">Kitaru (by ZenML)</a></strong> for sponsoring this open-source course and keeping it free!</em></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Uq-1!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Uq-1!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 424w, https://substackcdn.com/image/fetch/$s_!Uq-1!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 848w, https://substackcdn.com/image/fetch/$s_!Uq-1!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 1272w, https://substackcdn.com/image/fetch/$s_!Uq-1!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!Uq-1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png" width="1200" height="400" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:400,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:69533,&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://www.decodingai.com/i/207400663?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.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_!Uq-1!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 424w, https://substackcdn.com/image/fetch/$s_!Uq-1!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 848w, https://substackcdn.com/image/fetch/$s_!Uq-1!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 1272w, https://substackcdn.com/image/fetch/$s_!Uq-1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><div><hr></div><div class="callout-block" data-callout="true"><h4>Whenever you&#8217;re ready, here is how I can help you</h4><p><em>Go from agent user to agent builder.</em> Master the foundations of AI agents and turn fragile demo code into reliable, production-ready systems with my course, <strong><a href="https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering">Agent Engineering: Building Multi-Agent Systems</a></strong> (made with Towards AI).</p><p>35 lessons. Pure foundations from scratch. 4 mini-projects. 2 production systems. A certificate and direct access to me &amp; industry experts in our Discord.</p><p>Built for software and data professionals transitioning into AI engineering. <em>Rated 5/5 with 300+ students. The first 7 lessons are free:</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering&quot;,&quot;text&quot;:&quot;Start here&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering"><span>Start here</span></a></p><p><em>Not ready to commit?</em> Start with our <strong><a href="https://email-course.towardsai.net/?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering">free Agent AI Engineering Guide</a></strong>, a 6-day email course on the mistakes that silently break AI agents in production.</p></div><div><hr></div><h2>Images &amp; videos</h2><p>If not otherwise stated, all images and videos are created by the author.</p>]]></content:encoded></item><item><title><![CDATA[Context Engineering for Coding Agents]]></title><description><![CDATA[The 4 harness components that keep your context window high-signal.]]></description><link>https://www.decodingai.com/p/context-engineering-for-coding-agents</link><guid isPermaLink="false">https://www.decodingai.com/p/context-engineering-for-coding-agents</guid><dc:creator><![CDATA[Paul Iusztin]]></dc:creator><pubDate>Tue, 25 Aug 2026 05:01:37 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!BvUU!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39d1f394-e419-4ab6-a9f1-da5a0425a6f6_1376x768.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="callout-block" data-callout="true"><p><em><strong><span data-color="#c02f26" style="color: rgb(192, 47, 38);">Every AI application that wraps an agent is a harness!</span></strong><span data-color="#c02f26" style="color: rgb(192, 47, 38);"> </span></em></p><p>In LangChain&#8217;s Terminal-Bench experiment, changing only the harness (with the same model) moved a coding agent from ~30th place into the top 5: the harness, not the model, is what makes a coding agent good.</p><p>In the&nbsp;<strong>open-source course</strong>&nbsp;<strong><a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course">Building a Coding Agent From Scratch</a></strong>, you&#8217;ll build that harness from scratch in Python:&nbsp;<strong>Decode</strong>, a complete coding agent that grows lesson by lesson from a bare agent loop into a swarm of remote agents running in parallel in the cloud.</p><p><strong>Why?</strong>&nbsp;You&#8217;ll be able to engineer custom harnesses for your own AI products (the skill behind that leaderboard jump), and you&#8217;ll understand what Claude Code and Codex actually do under the hood, turning you into a power user.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ge05!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ge05!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 424w, https://substackcdn.com/image/fetch/$s_!ge05!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 848w, https://substackcdn.com/image/fetch/$s_!ge05!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 1272w, https://substackcdn.com/image/fetch/$s_!ge05!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ge05!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif" width="1200" height="630" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:630,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1446989,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/gif&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://www.decodingai.com/i/207400663?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ge05!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 424w, https://substackcdn.com/image/fetch/$s_!ge05!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 848w, https://substackcdn.com/image/fetch/$s_!ge05!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 1272w, https://substackcdn.com/image/fetch/$s_!ge05!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><strong>Lessons:</strong></p><ol><li><p><a href="https://www.decodingai.com/p/building-a-coding-agent-from-scratch-system-design">Building a Coding Agent From Scratch</a><strong> </strong></p></li><li><p><a href="https://www.decodingai.com/p/the-coding-agent-loop">The Bare-Bones Coding Agent Loop </a></p></li><li><p><a href="https://www.decodingai.com/p/run-coding-agents-safely">From a Raw Shell to a Sandboxed Coding Agent</a></p></li><li><p><strong>Context Engineering for Coding Agents</strong> <strong>&#8592; </strong><em><strong>You are here</strong></em></p></li><li><p><a href="https://www.decodingai.com/p/subagents-are-context-engineering">Subagents Are Context Engineering</a></p></li><li><p><a href="https://www.decodingai.com/p/coding-agents-in-remote-headless">Swarm of Remote Agents</a></p></li><li><p><a href="https://www.decodingai.com/p/evaluate-ai-agents-benchmarks-regression-tests">Agent Evals 101</a></p></li><li><p><a href="https://www.decodingai.com/p/transform-agent-traces-into-regression-cases">Turn Your Agent&#8217;s Failures Into a Regression Suite</a></p></li></ol><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course&quot;,&quot;text&quot;:&quot;Full open-source course&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course"><span>Full open-source course</span></a></p><p><em>Special thanks to <strong><a href="https://modal.com/?source=decodingai&amp;campaign=harnesseng">Modal</a></strong>, <strong><a href="https://www.comet.com/site/?utm_source=workshop&amp;utm_medium=partner&amp;utm_campaign=paul&amp;utm_content=coding_agent_course">Opik (by Comet)</a></strong>, and <strong><a href="https://www.zenml.io/product/kitaru?utm_source=decodingai&amp;utm_medium=referral&amp;utm_campaign=coding-agent-course&amp;utm_content=brand">Kitaru (by ZenML)</a></strong> for sponsoring this open-source course and keeping it free!</em></p></div><h1>Lesson 4: Context Engineering for Coding Agents</h1><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!7tX-!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F544e7250-15d4-4cc8-bc3d-b30f3e8e16db_1376x768.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!7tX-!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F544e7250-15d4-4cc8-bc3d-b30f3e8e16db_1376x768.png 424w, https://substackcdn.com/image/fetch/$s_!7tX-!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F544e7250-15d4-4cc8-bc3d-b30f3e8e16db_1376x768.png 848w, https://substackcdn.com/image/fetch/$s_!7tX-!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F544e7250-15d4-4cc8-bc3d-b30f3e8e16db_1376x768.png 1272w, https://substackcdn.com/image/fetch/$s_!7tX-!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F544e7250-15d4-4cc8-bc3d-b30f3e8e16db_1376x768.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!7tX-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F544e7250-15d4-4cc8-bc3d-b30f3e8e16db_1376x768.png" width="1376" height="768" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/544e7250-15d4-4cc8-bc3d-b30f3e8e16db_1376x768.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:768,&quot;width&quot;:1376,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;What you carry is what you can move with. The craft is in what you leave on the bench.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="What you carry is what you can move with. The craft is in what you leave on the bench." title="What you carry is what you can move with. The craft is in what you leave on the bench." srcset="https://substackcdn.com/image/fetch/$s_!7tX-!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F544e7250-15d4-4cc8-bc3d-b30f3e8e16db_1376x768.png 424w, https://substackcdn.com/image/fetch/$s_!7tX-!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F544e7250-15d4-4cc8-bc3d-b30f3e8e16db_1376x768.png 848w, https://substackcdn.com/image/fetch/$s_!7tX-!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F544e7250-15d4-4cc8-bc3d-b30f3e8e16db_1376x768.png 1272w, https://substackcdn.com/image/fetch/$s_!7tX-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F544e7250-15d4-4cc8-bc3d-b30f3e8e16db_1376x768.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>I got hooked on running Claude Code agents 24/7. Getting things done while answering emails, cooking, or watching a movie. Until my subscription maxed out mid-turn with the agent halfway through a feature. Sounds familiar?</p><p>Complaining to your employer, buying a bigger subscription, changing the model, or switching harnesses only treats the symptom. Doesn&#8217;t solve the root cause. You spend money while the window stays noisy, degrading output no matter whose model is behind it.</p><p>The actual solution is to better understand harnesses and the context engineering behind them. Improve planning, develop stronger skills and memory, and know when to drop your context.</p><p>So far in the course, we have focused on harness engineering and building a sandboxed agent loop. Now it&#8217;s finally time for some context engineering for coding agents: memory, skills, LSP servers and compaction.</p><p>The whole problem resolves to what to put into context, what not to put, how to trim it down, plus creating as many feedback loops as possible for the agent, as Anthropic frames it as <a href="https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents">finding the smallest possible set of high-signal tokens</a>.</p><p>You will walk away understanding and building from scratch:</p><ul><li><p>What the agent should carry between sessions.</p></li><li><p>How skills load nothing until needed.</p></li><li><p>The cheapest feedback loop in the system.</p></li><li><p>How the window gets trimmed before it rots.</p></li></ul><h2>The context lifecycle of a session</h2><p>To see how the 4 components cooperate, look at the <code>demo-5-sandbox-feature-pr</code> skill from the course repo (<code>.decode/skills/demo-5-sandbox-feature-pr</code>), where we encoded a demo where <strong>Decode</strong> writes a new feature into Decode by spinning up a background sandboxed session, where the host agent acts as the orchestrator and the sandboxed one as the feature executor. The final artifact from the demo will be a PR containing the new feature.</p><p>Go to <a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course">repository</a>, run <code>decode</code>, type <code>/demo-5-sandbox-feature-pr</code>, and enter. Let Decode do the rest of the work.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!U0HN!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa54ad14-87da-4731-bd5e-b3e2d310f634_1200x374.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!U0HN!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa54ad14-87da-4731-bd5e-b3e2d310f634_1200x374.png 424w, https://substackcdn.com/image/fetch/$s_!U0HN!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa54ad14-87da-4731-bd5e-b3e2d310f634_1200x374.png 848w, https://substackcdn.com/image/fetch/$s_!U0HN!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa54ad14-87da-4731-bd5e-b3e2d310f634_1200x374.png 1272w, https://substackcdn.com/image/fetch/$s_!U0HN!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa54ad14-87da-4731-bd5e-b3e2d310f634_1200x374.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!U0HN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa54ad14-87da-4731-bd5e-b3e2d310f634_1200x374.png" width="1200" height="374" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fa54ad14-87da-4731-bd5e-b3e2d310f634_1200x374.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:374,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;skill demo&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="skill demo" title="skill demo" srcset="https://substackcdn.com/image/fetch/$s_!U0HN!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa54ad14-87da-4731-bd5e-b3e2d310f634_1200x374.png 424w, https://substackcdn.com/image/fetch/$s_!U0HN!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa54ad14-87da-4731-bd5e-b3e2d310f634_1200x374.png 848w, https://substackcdn.com/image/fetch/$s_!U0HN!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa54ad14-87da-4731-bd5e-b3e2d310f634_1200x374.png 1272w, https://substackcdn.com/image/fetch/$s_!U0HN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa54ad14-87da-4731-bd5e-b3e2d310f634_1200x374.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>Here is a snapshot of the skill, where Decode spawns another Decode subagent:</p><pre><code><code>...

## 1. Launch decode against a sandboxed clone of the course repo

Launch the local Docker run (Docker must be running):

"""
SANDBOX_MODE=docker decode --repo git@github.com:decodingai-magazine/building-a-coding-agent-from-scratch-course.git
"""

...</code></code></pre><p>At session start, the system prompt is assembled from four parts: the base prompt, the active agent&#8217;s prompt, memory files (<code>AGENTS.md</code> + <code>.decode/MEMORY.md</code>), and the skills catalog (one line per skill). Pydantic AI adds each tool&#8217;s schema, paying off <a href="https://www.decodingai.com/p/the-coding-agent-loop">Lesson 2&#8217;s warning</a> that every tool costs tokens. This assembled prompt enters context, shaping the probabilities of the model&#8217;s next steps.</p><p>The run fills the window. Invoking the skill loads its <code>SKILL.md</code> body (tier 2 of progressive disclosure). Plan mode dumps repo files as <code>read</code> outputs. During the build loop, each <code>edit</code> lands, the Diagnostics Enricher appends type errors for free, and <code>bash</code> runs tests until green output signals completion.</p><p><em>Now, from the context window point of view, what happens within the harness?</em></p><p>As in the image below, as soon as we open the agent, the context window is filled with its system prompt, tool and skill descriptions and memory files. After invoking the <code>/demo-5-sandbox-feature-pr</code> skill, it gets filled with tool inputs and outputs, plus the SKILL.md file containing the specific instructions.</p><p>Next, through progressive disclosure, the agent begins reading the relevant files and scripts associated with the skills. Ultimately, it starts writing new Python files or editing existing ones that are statically checked for syntax issues via our <code>ty</code> Language Server Protocol (LSP) server.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!pnf_!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc59b6055-6ca8-49b1-b716-c8a8f023f987_1200x455.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!pnf_!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc59b6055-6ca8-49b1-b716-c8a8f023f987_1200x455.png 424w, https://substackcdn.com/image/fetch/$s_!pnf_!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc59b6055-6ca8-49b1-b716-c8a8f023f987_1200x455.png 848w, https://substackcdn.com/image/fetch/$s_!pnf_!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc59b6055-6ca8-49b1-b716-c8a8f023f987_1200x455.png 1272w, https://substackcdn.com/image/fetch/$s_!pnf_!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc59b6055-6ca8-49b1-b716-c8a8f023f987_1200x455.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!pnf_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc59b6055-6ca8-49b1-b716-c8a8f023f987_1200x455.png" width="1200" height="455" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c59b6055-6ca8-49b1-b716-c8a8f023f987_1200x455.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:455,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;The context lifecycle &#8212; what each iteration of one session appends to the window.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="The context lifecycle &#8212; what each iteration of one session appends to the window." title="The context lifecycle &#8212; what each iteration of one session appends to the window." srcset="https://substackcdn.com/image/fetch/$s_!pnf_!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc59b6055-6ca8-49b1-b716-c8a8f023f987_1200x455.png 424w, https://substackcdn.com/image/fetch/$s_!pnf_!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc59b6055-6ca8-49b1-b716-c8a8f023f987_1200x455.png 848w, https://substackcdn.com/image/fetch/$s_!pnf_!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc59b6055-6ca8-49b1-b716-c8a8f023f987_1200x455.png 1272w, https://substackcdn.com/image/fetch/$s_!pnf_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc59b6055-6ca8-49b1-b716-c8a8f023f987_1200x455.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption">The context lifecycle of a coding agent</figcaption></figure></div><p>On Modal&#8217;s self-hosted <code>Qwen3.6-35B</code>, the window is 262,144 tokens. Usually, microcompaction fires at 60%, while full compaction is at 80%. After compaction, usage drops back to roughly 5&#8211;10%, so the session continues instead of crashing.</p><p>In the video below, you can see part of the 219 spans trace in <a href="https://www.comet.com/site/?utm_source=newsletter&amp;utm_medium=partner&amp;utm_campaign=paul&amp;utm_content=coding_agent_course">Opik</a>, clearly monitoring the LLM tool calls, token counts, and latency of the harness and LLM calls:</p><div class="native-video-embed" data-component-name="VideoPlaceholder" data-attrs="{&quot;mediaUploadId&quot;:&quot;764baba6-361a-4c1f-9249-14735e9987cc&quot;,&quot;duration&quot;:null}"></div><p>Every component in this lifecycle has specific mechanics: memory, skills, the LSP server, and compaction. Let&#8217;s explore each.</p><h2>Memory: Stop repeating your instructions</h2><p>In my early agent runs, the agent kept writing naive datetime objects instead of timezone-aware ones and added type hints inconsistently, forcing me to retype the same corrections session after session. The fix was to write the preference down once into the <code>AGENTS.md</code>, where the agent reads it every turn.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!mNNY!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5fa3410-408d-4668-a13b-5bdeb47650f5_1200x600.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!mNNY!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5fa3410-408d-4668-a13b-5bdeb47650f5_1200x600.png 424w, https://substackcdn.com/image/fetch/$s_!mNNY!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5fa3410-408d-4668-a13b-5bdeb47650f5_1200x600.png 848w, https://substackcdn.com/image/fetch/$s_!mNNY!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5fa3410-408d-4668-a13b-5bdeb47650f5_1200x600.png 1272w, https://substackcdn.com/image/fetch/$s_!mNNY!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5fa3410-408d-4668-a13b-5bdeb47650f5_1200x600.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!mNNY!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5fa3410-408d-4668-a13b-5bdeb47650f5_1200x600.png" width="1200" height="600" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a5fa3410-408d-4668-a13b-5bdeb47650f5_1200x600.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:600,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;The two memory files &#8212; one you write by hand, one that writes itself.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="The two memory files &#8212; one you write by hand, one that writes itself." title="The two memory files &#8212; one you write by hand, one that writes itself." srcset="https://substackcdn.com/image/fetch/$s_!mNNY!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5fa3410-408d-4668-a13b-5bdeb47650f5_1200x600.png 424w, https://substackcdn.com/image/fetch/$s_!mNNY!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5fa3410-408d-4668-a13b-5bdeb47650f5_1200x600.png 848w, https://substackcdn.com/image/fetch/$s_!mNNY!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5fa3410-408d-4668-a13b-5bdeb47650f5_1200x600.png 1272w, https://substackcdn.com/image/fetch/$s_!mNNY!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5fa3410-408d-4668-a13b-5bdeb47650f5_1200x600.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><code>AGENTS.md</code><em> (the one you write by hand) vs. </em><code>.decode/MEMORY.md</code><em> (the one the agent extracts from each session).</em></figcaption></figure></div><p><code>AGENTS.md</code> injects project context: business logic, why components exist, the tech stack, and the processes around it (docs, deploy, review, testing). The code is the source of truth, so avoid duplicating it. Add metadata and references the agent can discover without heavy reasoning.</p><p>Keep it under 300 lines, with a guardrail of around 600 lines. Write each line in response to an observed mistake so the agent avoids repeating it, following <a href="https://mitchellh.com/writing/my-ai-adoption-journey">Mitchell Hashimoto&#8217;s rule</a>.</p><p>Decode recursively looks within all the project directories for <code>AGENTS.md</code> files (root-most first, so the nearest file takes precedence), appends <code>.decode/MEMORY.md</code> last, stamps each with a <code># From &lt;path&gt;</code> provenance header, and dumps the result into the system prompt.</p><p>If <code>AGENTS.md</code> is what you manually define, <code>.decode/MEMORY.md</code> is what the agent automatically extracts from your conversations, replicating Claude Code&#8217;s auto-memory</p><p>At the end of each session &#8212; on quit and on <code>/clear</code> &#8212; one cheap LLM call summarizes the session into a single plain sentence, appended as a dated bullet (<code>- 2026-06-26: &#8230;</code>), as an append-only log. As this can grow big fast, the file has a hard cap of 200 lines or 25,000 bytes, dropping the oldest lines first.</p><p><em>From <a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course/blob/main/src/decode/memory/extract.py">src/decode/memory/extract.py</a>:</em></p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">async def extract_on_exit(messages: list[ModelMessage], cwd: Path) -&gt; None:
    summary = await summarize_session(messages, model_or_settings=settings)
    append_session_summary(cwd, summary, now=_utc_now())

    if settings.memory_compression_enabled:
        await compress_memory_file(cwd, model_or_settings=settings)</code></pre></div><p><code>summarize_session</code> is the single LLM call that distills the conversation into one sentence (or <code>None</code> if it&#8217;s not worth saving). <code>append_session_summary</code> writes that sentence into <code>.decode/MEMORY.md</code> and enforces the hard cap.</p><p><code>compress_memory_file</code> runs <strong>Memory Compression</strong> to rewrite the file in place, merging duplicate or superseded notes while preserving dated bullets.</p><h2>Skills: Never load what you can reference</h2><p>My Python testing and PR conventions used to live directly in my memory file, bloating the context of every session. Moving them into skills left behind just a few lines, as references, that specify when to access each one.</p><p>Skills prevent context rot from 2 directions. On the tools side, upfront schemas burn budget: <a href="https://mariozechner.at/posts/2025-11-30-pi-coding-agent/">Mario Zechner measured that popular MCP servers consume 7&#8211;9% of the context window</a> before any work begins. On the memory side, stuffing review guides and workflow templates into <code>AGENTS.md</code> pollutes every turn. Skills solve both: each phase-specific behavior lives in its own skill, referenced from a one-line catalog entry, and loads only when that workflow phase runs.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!zEr0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d0163ba-5206-4477-a774-4a2593499b42_1200x600.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!zEr0!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d0163ba-5206-4477-a774-4a2593499b42_1200x600.png 424w, https://substackcdn.com/image/fetch/$s_!zEr0!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d0163ba-5206-4477-a774-4a2593499b42_1200x600.png 848w, https://substackcdn.com/image/fetch/$s_!zEr0!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d0163ba-5206-4477-a774-4a2593499b42_1200x600.png 1272w, https://substackcdn.com/image/fetch/$s_!zEr0!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d0163ba-5206-4477-a774-4a2593499b42_1200x600.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!zEr0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d0163ba-5206-4477-a774-4a2593499b42_1200x600.png" width="1200" height="600" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6d0163ba-5206-4477-a774-4a2593499b42_1200x600.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:600,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;The three tiers of progressive disclosure, seen inside the context window.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="The three tiers of progressive disclosure, seen inside the context window." title="The three tiers of progressive disclosure, seen inside the context window." srcset="https://substackcdn.com/image/fetch/$s_!zEr0!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d0163ba-5206-4477-a774-4a2593499b42_1200x600.png 424w, https://substackcdn.com/image/fetch/$s_!zEr0!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d0163ba-5206-4477-a774-4a2593499b42_1200x600.png 848w, https://substackcdn.com/image/fetch/$s_!zEr0!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d0163ba-5206-4477-a774-4a2593499b42_1200x600.png 1272w, https://substackcdn.com/image/fetch/$s_!zEr0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d0163ba-5206-4477-a774-4a2593499b42_1200x600.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption">The 3 tiers of loading a skill and its bundled files into the context window</figcaption></figure></div><p>Skills follow the <a href="https://agentskills.io/home">Agent Skills standard</a>. In Decode, skills live in <code>.decode/skills/</code>, or you can open the TUI, type <code>/</code>, and pick one. A separate public registry lives at <a href="https://www.skills.sh/">skills.sh</a> (<code>npx skills install &lt;skill&gt;</code>):</p><pre><code><code>my-skill/
&#9500;&#9472;&#9472; SKILL.md          # Required: metadata + instructions
&#9500;&#9472;&#9472; scripts/          # Optional: executable code
&#9500;&#9472;&#9472; references/       # Optional: documentation
&#9500;&#9472;&#9472; assets/           # Optional: templates, resources
&#9492;&#9472;&#9472; ...               # Any additional files or directories</code></code></pre><p><strong>Progressive disclosure</strong> operates across <strong>3 tiers</strong>. In <strong>tier 1</strong>, only the skills catalog stays in context: one <code>name + description</code> line per skill. As your library grows, an optional guard can cap the catalog at ~1% of the context window.</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!xhAh!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd4e626a-873a-40a9-8ca8-9255652381cb_1200x292.png 424w, https://substackcdn.com/image/fetch/$s_!xhAh!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd4e626a-873a-40a9-8ca8-9255652381cb_1200x292.png 848w, https://substackcdn.com/image/fetch/$s_!xhAh!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd4e626a-873a-40a9-8ca8-9255652381cb_1200x292.png 1272w, https://substackcdn.com/image/fetch/$s_!xhAh!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd4e626a-873a-40a9-8ca8-9255652381cb_1200x292.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!xhAh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd4e626a-873a-40a9-8ca8-9255652381cb_1200x292.png" width="1200" height="292" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/dd4e626a-873a-40a9-8ca8-9255652381cb_1200x292.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:292,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;The tier-1 skills pipeline &#8212; descriptions gathered into a catalog, optionally capped, wrapped into the system prompt.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="The tier-1 skills pipeline &#8212; descriptions gathered into a catalog, optionally capped, wrapped into the system prompt." title="The tier-1 skills pipeline &#8212; descriptions gathered into a catalog, optionally capped, wrapped into the system prompt." srcset="https://substackcdn.com/image/fetch/$s_!xhAh!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd4e626a-873a-40a9-8ca8-9255652381cb_1200x292.png 424w, https://substackcdn.com/image/fetch/$s_!xhAh!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd4e626a-873a-40a9-8ca8-9255652381cb_1200x292.png 848w, https://substackcdn.com/image/fetch/$s_!xhAh!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd4e626a-873a-40a9-8ca8-9255652381cb_1200x292.png 1272w, https://substackcdn.com/image/fetch/$s_!xhAh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd4e626a-873a-40a9-8ca8-9255652381cb_1200x292.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div><figcaption class="image-caption"><em>Loading the skills catalog into the system prompt.</em></figcaption></figure></div><p>A common strategy Decode doesn&#8217;t have yet is user-invocable-only skills, where you flag a skill as callable only. This means you can remove its name and description from the catalog, leaving it with zero context until explicitly invoked by the user.</p><p>In <strong>tier 2</strong>, invoking a skill via the <code>skill</code><strong> dispatcher tool</strong> or <code>/&lt;skill-name&gt;</code> loads only its <code>SKILL.md</code> body and any other files packed within the skill.</p><p><em>From <a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course/blob/main/src/decode/tools/skills.py">src/decode/tools/skills.py</a>:</em></p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">async def skill(ctx: RunContext[AgentDeps], name: str) -&gt; str:
    home = ctx.deps.harness_home or ctx.deps.cwd
    catalog = load_skills(home)
    found = catalog.get(name)

    return format_skill_payload(found, cwd=home)</code></pre></div><p>In <strong>tier 3</strong>, because within <code>format_skill_payload</code> we properly format and expose all the available resources (files, scripts, docs, assets) from a skill to the agent, if it considers them necessary, it will load them via its read tool or execute the containing scripts via the bash tool.</p><p>This is the core idea of progressive disclosure. It&#8217;s mostly just exposing a manifest of bundled files with exact cwd-relative paths, making it super clear to the agent how to access them. The key here is that the LLM is properly trained for tool calling to make the right decisions about whether to call read or bash tools.</p><p><em>From <a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course/blob/main/src/decode/skills/payload.py">src/decode/skills/payload.py</a>:</em></p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">def format_skill_payload(skill: SkillDef, *, cwd: Path) -&gt; str:
    if skill.resource_dir is None:
        return f"{skill.body}\n\n{_OUTPUTS_TRAILER}"
    rel_dir = os.path.relpath(skill.resource_dir, cwd)
    files = _bundled_files(skill.resource_dir)
    
    listing = "\n".join(f"- {rel_dir}/{name}" for name in files)
    trailer = (
        f"Bundled files for this skill (all under `{rel_dir}/` &#8212; use these EXACT paths):\n"
        f"{listing}\n"
        "Read them with the `read` tool; run `scripts/` files with `bash`."
    )

    return f"{skill.body}\n\n{trailer}\n\n{_OUTPUTS_TRAILER}"</code></pre></div><p>Now let&#8217;s look at the cheapest feedback loop in the whole coding agent.</p><h2>The LSP server: Replace guessing with precision</h2><p>In my multi-agent setup, each turn between the engineer and tester agents re-ran the linter, type checker, formatter, and test suite. My Prefect orchestrator integration tests took 15 minutes on their own, so I split them to speed up the feedback loop.</p><p>The takeaway was clear: the most important part of your agentic flow is to always give as many feedback loops as possible. <strong>The LSP server is the fastest way to feed in code-related signal.</strong></p><p>An LSP server is one of the most underrated components, particularly for coding harnesses. It maintains a live index of symbols across your codebase: variables, functions, classes, definitions, references, and type errors. Your IDE already runs one per language. You need one for each programming language. Decode uses <a href="https://github.com/astral-sh/ty">ty by Astral</a>, an extremely fast type checker and language server written in Rust, to support Python. Made by the same guys behind uv and ruff.</p><p>The server feeds the agent signal through 2 channels.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!N2P_!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffa5c0a8-ed47-4023-8ba1-6537bf9ba0a3_1200x515.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!N2P_!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffa5c0a8-ed47-4023-8ba1-6537bf9ba0a3_1200x515.png 424w, https://substackcdn.com/image/fetch/$s_!N2P_!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffa5c0a8-ed47-4023-8ba1-6537bf9ba0a3_1200x515.png 848w, https://substackcdn.com/image/fetch/$s_!N2P_!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffa5c0a8-ed47-4023-8ba1-6537bf9ba0a3_1200x515.png 1272w, https://substackcdn.com/image/fetch/$s_!N2P_!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffa5c0a8-ed47-4023-8ba1-6537bf9ba0a3_1200x515.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!N2P_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffa5c0a8-ed47-4023-8ba1-6537bf9ba0a3_1200x515.png" width="1200" height="515" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ffa5c0a8-ed47-4023-8ba1-6537bf9ba0a3_1200x515.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:515,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Two ways into one LSP server &#8212; the agent asks, or the edit asks on its behalf.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Two ways into one LSP server &#8212; the agent asks, or the edit asks on its behalf." title="Two ways into one LSP server &#8212; the agent asks, or the edit asks on its behalf." srcset="https://substackcdn.com/image/fetch/$s_!N2P_!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffa5c0a8-ed47-4023-8ba1-6537bf9ba0a3_1200x515.png 424w, https://substackcdn.com/image/fetch/$s_!N2P_!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffa5c0a8-ed47-4023-8ba1-6537bf9ba0a3_1200x515.png 848w, https://substackcdn.com/image/fetch/$s_!N2P_!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffa5c0a8-ed47-4023-8ba1-6537bf9ba0a3_1200x515.png 1272w, https://substackcdn.com/image/fetch/$s_!N2P_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffa5c0a8-ed47-4023-8ba1-6537bf9ba0a3_1200x515.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>The two LSP channels. 1. The agent queries the </em><code>lsp</code><em> tool on demand 2. Every Python edit/write passively pulls diagnostics.</em></figcaption></figure></div><p><strong>Channel 1</strong> is the <code>lsp</code><strong> tool</strong>, which handles active queries with 4 ops: <code>definition</code>, <code>references</code>, <code>hover</code>, and <code>diagnostics</code>. One call returns a precise <code>file:line:column</code> answer instead of 3 speculative file reads. It&#8217;s read-only, so the permission gate auto-allows it across all modes.</p><p><em>From <a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course/blob/main/src/decode/tools/lsp.py">src/decode/tools/lsp.py</a>:</em></p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">async def lsp(
    ctx: RunContext[AgentDeps],
    op: str,
    path: str,
    line: int | None = None,
    column: int | None = None,
) -&gt; str:
    if op == "definition":
        return await _run_definition(ctx, path, line, column)
    if op == "references":
        return await _run_references(ctx, path, line, column)
    if op == "hover":
        return await _run_hover(ctx, path, line, column)
        
    return await _run_diagnostics(ctx, path)

async def _run_definition(ctx: RunContext[AgentDeps], path: str, line: int, column: int) -&gt; str:
    result = await lsp_service.definition(ctx.deps.cwd, path, line, column)

    return _format_location(result)</code></pre></div><p>The server runs as a background process at each project root, communicating via JSON-RPC (a plain request/response protocol over standard input/output). Decode&#8217;s <code>LspClient</code> initializes the session, negotiates capabilities, and sends requests:</p><p><em>From <a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course/blob/main/src/decode/services/lsp/service.py">src/decode/services/lsp/service.py</a>:</em></p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">from decode.services.lsp.client import LspClient


process = await asyncio.create_subprocess_exec(
    "ty", "server",
    stdin=PIPE, stdout=PIPE, cwd=root,
)
client = LspClient(process, root)
await client.initialize()</code></pre></div><p>In the <code>demo-5</code> session, the agent resolves the entry point via <code>lsp("definition", "src/decode/cli.py", &lt;line&gt;, &lt;column&gt;)</code> over JSON-RPC <code>textDocument/definition</code>. On the next turn, the model targets its edit tool call at that exact location, rather than blindly exploring the codebase first.</p><p><strong>Channel 2</strong> is the <strong>Diagnostics Enricher</strong>, which runs passively on every successful <code>.py</code> write or edit to append an errors-only block to the tool result. It displays at most 10 errors, and stays silent on clean files or when the server is unavailable, matching the pattern in <a href="https://github.com/anomalyco/opencode">OpenCode</a>.</p><p><code>_enrich</code> wraps the return value of file modification tools without requiring extra turns or tools.</p><p><em>From <a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course/blob/main/src/decode/tools/files.py">src/decode/tools/files.py</a>:</em></p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">def _enrich(base: str, cwd: Path, path: str) -&gt; str:
    summary = _format_lsp_errors(lsp_service.diagnostics_on_edit(cwd, path))
    if summary is None:
        return base
    return f"{base}\n\n{summary}"

def _format_lsp_errors(diagnostics: list[Diagnostic] | None) -&gt; str | None:
    ...
    errors = [d for d in diagnostics if d.severity == _LSP_ERROR_SEVERITY]
    shown = errors[:_LSP_DIAGNOSTICS_LIMIT]
    lines = [f"LSP diagnostics ({settings.lsp_server_command}) &#8212; fix these:"]
    ...
    return "\n".join(lines)</code></pre></div><p>In the <code>demo-5</code> session, when the agent updates <code>src/decode/cli.py</code> with an unimported reference, the file writes successfully, but the enricher appends <code>LSP diagnostics (ty) &#8212; fix these: ...</code> with the error details. The model sees this feedback immediately and fixes the import on the next <code>edit</code> before running any tests.</p><p>In the video below, you can clearly see in <a href="https://www.comet.com/site/?utm_source=newsletter&amp;utm_medium=partner&amp;utm_campaign=paul&amp;utm_content=coding_agent_course">Opik</a> how the LLM outputs LSP tool calls and how they are executed in the harness:</p><div class="native-video-embed" data-component-name="VideoPlaceholder" data-attrs="{&quot;mediaUploadId&quot;:&quot;88759aa0-fa9a-469e-a237-03c62c9bb762&quot;,&quot;duration&quot;:null}"></div><p>Memory, skills, and the LSP all shape what enters the window. Now let&#8217;s see how we can trim it down.</p><h2>Compaction: Delete before the window rots</h2><p>Back in Nov 2025, when building the writing agent for my agent engineering course, requests started degrading around 180,000 input tokens on Gemini Pro, taking&gt;3 minutes per request or directly returning timeout errors and disconnections. Considering that on paper Gemini handles up to 1M input tokens.</p><p>A full window degrades model performance and reliability long before hitting the hard token ceiling, following the <a href="https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents">degradation curves documented by Anthropic</a>. That&#8217;s why you need compaction to continually reduce your context window while minimizing context loss.</p><p>Compaction handles this in 3 ways. The simplest is <code>/clear</code>, which wipes the entire window after running the on-exit memory write-back so key learnings persist in <code>.decode/MEMORY.md</code>.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!apDX!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63c3ab58-49a6-4264-a317-249b97680134_1200x815.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!apDX!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63c3ab58-49a6-4264-a317-249b97680134_1200x815.png 424w, https://substackcdn.com/image/fetch/$s_!apDX!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63c3ab58-49a6-4264-a317-249b97680134_1200x815.png 848w, https://substackcdn.com/image/fetch/$s_!apDX!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63c3ab58-49a6-4264-a317-249b97680134_1200x815.png 1272w, https://substackcdn.com/image/fetch/$s_!apDX!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63c3ab58-49a6-4264-a317-249b97680134_1200x815.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!apDX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63c3ab58-49a6-4264-a317-249b97680134_1200x815.png" width="1200" height="815" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/63c3ab58-49a6-4264-a317-249b97680134_1200x815.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:815,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;The three compaction modes and what each one leaves in the window.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="The three compaction modes and what each one leaves in the window." title="The three compaction modes and what each one leaves in the window." srcset="https://substackcdn.com/image/fetch/$s_!apDX!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63c3ab58-49a6-4264-a317-249b97680134_1200x815.png 424w, https://substackcdn.com/image/fetch/$s_!apDX!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63c3ab58-49a6-4264-a317-249b97680134_1200x815.png 848w, https://substackcdn.com/image/fetch/$s_!apDX!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63c3ab58-49a6-4264-a317-249b97680134_1200x815.png 1272w, https://substackcdn.com/image/fetch/$s_!apDX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63c3ab58-49a6-4264-a317-249b97680134_1200x815.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>The three compaction modes: </em><code>/clear</code><em> keeps only the system prompt, </em><code>/compaction</code><em> rebuilds it as summary plus tail, and </em><code>/microcompaction</code><em> swaps old tool outputs for placeholders in place.</em></figcaption></figure></div><p>The second option is <strong>full compaction</strong>, triggered automatically at 80% capacity or manually via <code>/compact</code>. An LLM summarizes the conversations into a six-part template (goal, constraints &amp; preferences, progress, key decisions, next steps, critical context), and older messages are dropped. The window becomes <code>[system prompt] + [summary] + [recent tail]</code>, where the tail retains &#8776;20,000 tokens of recent messages snapped cleanly to a <strong>Compaction Boundary</strong> so tool calls remain paired with their results, matching <a href="https://github.com/earendil-works/pi">Pi&#8217;s implementation</a>.</p><p>Both tiers evaluate <code>should_compact</code> using the provider&#8217;s reported token window against reserve thresholds (80% full compaction -&gt;20% empty, 60% microcompaction -&gt; 40% empty):</p><p><em>From <a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course/blob/main/src/decode/context/compaction.py">src/decode/context/compaction.py</a>:</em></p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">def should_compact(usage: RunUsage, *, window: int, reserve: float, enabled: bool) -&gt; bool:
    if not enabled:
        return False
    if usage.input_tokens &lt;= 0:
        return False
    return usage.input_tokens &gt;= reserve_threshold(window, reserve)</code></pre></div><p>Everything happens within the <code>compact()</code> method from <code>AgentTurnHandler</code>. <code>split_tail</code> walks backward through message history estimating token counts to locate the Compaction Boundary. <code>summarize_for_compaction</code> generates the summary, <code>build_summary_message</code> wraps it as a synthetic user message that is itself part of the history the next compaction summarizes (so successive compactions merge for free), and the handler sends <code>[summary_message, *tail]</code> on the next loop iteration. The harness owns the list it feeds the model, so replacing the list IS the compaction:</p><p><em>From <a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course/blob/main/src/decode/agent/loop.py">src/decode/agent/loop.py</a>:</em></p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">class AgentTurnHandler:
    ...

    async def compact(self) -&gt; CompactOutcome:
        split = split_tail(
            self.message_history, keep_recent_tokens=settings.compaction_keep_recent_tokens
        )
        skeleton = await summarize_for_compaction(
            self.message_history, model=self._compaction_model
        )

        before_tokens = self._last_input_tokens
        summary_message = build_summary_message(skeleton)
        tail = self.message_history[split:]

        self.message_history = [summary_message, *tail]

        return CompactOutcome.COMPACTED</code></pre></div><p>The 3rd and last option is <strong>microcompaction</strong>, which runs without LLM calls at 60% capacity. It replaces tool outputs outside the recent tail with a placeholder string by inspecting each <code>ToolReturnPart</code> (the message part that holds a tool&#8217;s output). Because tool outputs are consumed each turn, conclusions live on in subsequent messages. Nothing is lost because the tool input remains available in the messages, allowing the agent to rerun the tool if necessary. That is why <a href="https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents">Anthropic calls tool-result clearing the safest, lightest touch of compaction</a>.</p><p>After every completed turn, the handler checks the same number against both thresholds: full compaction first, then <code>microcompact</code>, replacing <code>message_history</code> through the same reassignment.</p><p><em>From <a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course/blob/main/src/decode/context/compaction.py">src/decode/context/compaction.py</a>:</em></p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">_MICRO_PLACEHOLDER = "[tool output elided by microcompaction]"

def microcompact(
    messages: list[ModelMessage],
    *,
    keep_recent_tokens: int,
    placeholder: str = _MICRO_PLACEHOLDER,
) -&gt; list[ModelMessage]:
    boundary = split_tail(messages, keep_recent_tokens=keep_recent_tokens)

    new_messages: list[ModelMessage] = []
    for index, message in enumerate(messages):
        if index &gt;= boundary or not isinstance(message, ModelRequest):
            new_messages.append(message)
            continue

        new_parts = list(message.parts)
        changed = False
        for position, part in enumerate(message.parts):
            if not isinstance(part, ToolReturnPart | RetryPromptPart):
                continue
            new_parts[position] = dataclasses.replace(part, content=placeholder)

        new_messages.append(dataclasses.replace(message, parts=new_parts))

    return new_messages</code></pre></div><p>When saving the session to JSONL files, there is no compaction. The file is a simple snapshot of the entire message history. To save a compacted session, you either have to run it before exiting the session or resume, run it and then exit.</p><p>In the image below, you can see how the <code>/compact</code> command reduced the context window from <code>&#9681; 57%</code> (~149539) to 8% of the context window.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!_ExA!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa16b6e09-7ab9-48e7-a208-c20bb0ac32e4_1173x445.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!_ExA!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa16b6e09-7ab9-48e7-a208-c20bb0ac32e4_1173x445.png 424w, https://substackcdn.com/image/fetch/$s_!_ExA!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa16b6e09-7ab9-48e7-a208-c20bb0ac32e4_1173x445.png 848w, https://substackcdn.com/image/fetch/$s_!_ExA!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa16b6e09-7ab9-48e7-a208-c20bb0ac32e4_1173x445.png 1272w, https://substackcdn.com/image/fetch/$s_!_ExA!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa16b6e09-7ab9-48e7-a208-c20bb0ac32e4_1173x445.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!_ExA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa16b6e09-7ab9-48e7-a208-c20bb0ac32e4_1173x445.png" width="1173" height="445" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a16b6e09-7ab9-48e7-a208-c20bb0ac32e4_1173x445.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:445,&quot;width&quot;:1173,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!_ExA!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa16b6e09-7ab9-48e7-a208-c20bb0ac32e4_1173x445.png 424w, https://substackcdn.com/image/fetch/$s_!_ExA!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa16b6e09-7ab9-48e7-a208-c20bb0ac32e4_1173x445.png 848w, https://substackcdn.com/image/fetch/$s_!_ExA!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa16b6e09-7ab9-48e7-a208-c20bb0ac32e4_1173x445.png 1272w, https://substackcdn.com/image/fetch/$s_!_ExA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa16b6e09-7ab9-48e7-a208-c20bb0ac32e4_1173x445.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><h2>Next steps</h2><p>There are other components we haven&#8217;t touched on in this article, such as an MCP client or an auto-mode permission layer. Still, these are the 4 harness components that are omnipresent in every coding harness you will use. Maybe Pi, with its minimalist design, is the only exception.</p><div class="callout-block" data-callout="true"><p>&#129489;&#8205;&#128187; <span>We encourage you to&nbsp;</span><strong>clone our&nbsp;<a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course">course repo</a></strong><span>, open your terminal, type </span><strong><span data-color="#38761d" style="color: rgb(56, 118, 29);">&#8221;decode&#8221;</span></strong>,<strong> </strong>and test out the coding agent.</p></div><p>Within the <a href="https://www.decodingai.com/p/subagents-are-context-engineering">next lesson</a>, we will add the final harness piece to the puzzle: creating an agent&#8217;s catalog used to fan out subagents whose work never pollutes your window.</p><p><span>Here is the</span><strong> course roadmap, </strong><span>lesson by lesson </span><em><span>(</span><a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course#-course-outline">see all in GitHub</a></em><span>):</span></p><ol><li><p><a href="https://www.decodingai.com/p/building-a-coding-agent-from-scratch-system-design">Building a Coding Agent From Scratch</a></p></li><li><p><a href="https://www.decodingai.com/p/the-coding-agent-loop">The Bare-Bones Coding Agent Loop</a></p></li><li><p><a href="https://www.decodingai.com/p/run-coding-agents-safely">From a Raw Shell to a Sandboxed Coding Agent</a></p></li><li><p><strong>Context Engineering for Coding Agents &#8592; You are here</strong></p></li><li><p><a href="https://www.decodingai.com/p/subagents-are-context-engineering">Subagents Are Context Engineering</a></p></li><li><p><a href="https://www.decodingai.com/p/coding-agents-in-remote-headless">Swarm of Remote Agents</a></p></li><li><p><a href="https://www.decodingai.com/p/evaluate-ai-agents-benchmarks-regression-tests">Agent Evals 101</a></p></li><li><p><a href="https://www.decodingai.com/p/transform-agent-traces-into-regression-cases">Turn Your Agent&#8217;s Failures Into a Regression Suite</a></p></li></ol><p>Or watch the <strong>video version</strong> of the lesson:</p><div id="youtube2-dx77BRFZ0_M" class="youtube-wrap" data-attrs="{&quot;videoId&quot;:&quot;dx77BRFZ0_M&quot;,&quot;startTime&quot;:null,&quot;endTime&quot;:null}" data-component-name="Youtube2ToDOM"><div class="youtube-inner"><iframe src="https://www.youtube-nocookie.com/embed/dx77BRFZ0_M?rel=0&amp;autoplay=0&amp;showinfo=0&amp;enablejsapi=0" frameborder="0" loading="lazy" gesture="media" allow="autoplay; fullscreen" allowautoplay="true" allowfullscreen="true" width="728" height="409"></iframe></div></div><p><em>But here is what I&#8217;m wondering:</em></p><blockquote><p><em><strong>When your coding agent&#8217;s window fills up mid-task, what do you actually do today: </strong></em><code>/clear</code><em><strong> and lose the thread, </strong></em><code>/compact</code><em><strong> and hope the summary gets the job done, or just keep going until it degrades?</strong></em></p></blockquote><p><em>Click the button below and tell me. I read every response.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://www.decodingai.com/p/context-engineering-for-coding-agents/comments&quot;,&quot;text&quot;:&quot;Leave a comment&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://www.decodingai.com/p/context-engineering-for-coding-agents/comments"><span>Leave a comment</span></a></p><div><hr></div><p><em>Enjoyed the article? The most sincere compliment is to restack this for your readers.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://www.decodingai.com/p/context-engineering-for-coding-agents?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;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://www.decodingai.com/p/context-engineering-for-coding-agents?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p><div><hr></div><p><em>Special thanks to <strong><a href="https://modal.com?source=decodingai&amp;campaign=harnesseng">Modal</a></strong>, <strong><a href="https://www.comet.com/site/?utm_source=newsletter&amp;utm_medium=partner&amp;utm_campaign=paul&amp;utm_content=coding_agent_course">Opik (by Comet)</a></strong>, and <strong><a href="https://www.zenml.io/product/kitaru?utm_source=decodingai&amp;utm_medium=referral&amp;utm_campaign=coding-agent-course&amp;utm_content=brand">Kitaru (by ZenML)</a></strong> for sponsoring this open-source course and keeping it free!</em></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Uq-1!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Uq-1!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 424w, https://substackcdn.com/image/fetch/$s_!Uq-1!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 848w, https://substackcdn.com/image/fetch/$s_!Uq-1!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 1272w, https://substackcdn.com/image/fetch/$s_!Uq-1!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!Uq-1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png" width="1200" height="400" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:400,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:69533,&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://www.decodingai.com/i/207400663?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.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_!Uq-1!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 424w, https://substackcdn.com/image/fetch/$s_!Uq-1!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 848w, https://substackcdn.com/image/fetch/$s_!Uq-1!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 1272w, https://substackcdn.com/image/fetch/$s_!Uq-1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><div><hr></div><div class="callout-block" data-callout="true"><h4>Whenever you&#8217;re ready, here is how I can help you</h4><p><em>Go from agent user to agent builder.</em> Master the foundations of AI agents and turn fragile demo code into reliable, production-ready systems with my course, <strong><a href="https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering">Agent Engineering: Building Multi-Agent Systems</a></strong> (made with Towards AI).</p><p>35 lessons. Pure foundations from scratch. 4 mini-projects. 2 production systems. A certificate and direct access to me &amp; industry experts in our Discord.</p><p>Built for software and data professionals transitioning into AI engineering. <em>Rated 5/5 with 300+ students. The first 7 lessons are free:</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering&quot;,&quot;text&quot;:&quot;Start here&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering"><span>Start here</span></a></p><p><em>Not ready to commit?</em> Start with our <strong><a href="https://email-course.towardsai.net/?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering">free Agent AI Engineering Guide</a></strong>, a 6-day email course on the mistakes that silently break AI agents in production.</p></div><div><hr></div><h2>Images &amp; videos</h2><p>If not otherwise stated, all images are created by the author.</p>]]></content:encoded></item><item><title><![CDATA[From a Raw Shell to a Sandboxed Coding Agent]]></title><description><![CDATA[The guide to isolating your harness and safely executing its commands, locally or remotely.]]></description><link>https://www.decodingai.com/p/run-coding-agents-safely</link><guid isPermaLink="false">https://www.decodingai.com/p/run-coding-agents-safely</guid><dc:creator><![CDATA[Paul Iusztin]]></dc:creator><pubDate>Tue, 18 Aug 2026 11:02:59 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!k1Xr!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97e3b938-fb2a-462c-923f-fbd591667a65_1376x768.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="callout-block" data-callout="true"><p>In LangChain&#8217;s Terminal-Bench experiment, changing only the harness (with the same model) moved a coding agent from ~30th place into the top 5: the harness, not the model, is what makes a coding agent good.</p><p>In the&nbsp;<strong>open-source course</strong>&nbsp;<strong><a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course">Building a Coding Agent From Scratch</a></strong>, you&#8217;ll build that harness from scratch in Python:&nbsp;<strong>Decode</strong>, a complete coding agent that grows lesson by lesson from a bare agent loop into a swarm of remote agents running in parallel in the cloud.</p><p><strong>Why?</strong>&nbsp;You&#8217;ll be able to engineer custom harnesses for your own AI products (the skill behind that leaderboard jump), and you&#8217;ll understand what Claude Code and Codex actually do under the hood, turning you into a power user.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ge05!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ge05!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 424w, https://substackcdn.com/image/fetch/$s_!ge05!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 848w, https://substackcdn.com/image/fetch/$s_!ge05!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 1272w, https://substackcdn.com/image/fetch/$s_!ge05!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ge05!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif" width="1200" height="630" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:630,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1446989,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/gif&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://www.decodingai.com/i/207400663?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ge05!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 424w, https://substackcdn.com/image/fetch/$s_!ge05!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 848w, https://substackcdn.com/image/fetch/$s_!ge05!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 1272w, https://substackcdn.com/image/fetch/$s_!ge05!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><strong>Lessons:</strong></p><ol><li><p><a href="https://www.decodingai.com/p/building-a-coding-agent-from-scratch-system-design">Building a Coding Agent From Scratch</a><strong> </strong></p></li><li><p><a href="https://www.decodingai.com/p/the-coding-agent-loop">The Bare-Bones Coding Agent Loop </a></p></li><li><p><strong>From a Raw Shell to a Sandboxed Coding Agent</strong> <strong>&#8592; </strong><em><strong>you are here</strong></em></p></li><li><p><a href="https://www.decodingai.com/p/context-engineering-for-coding-agents">Context Engineering for Coding Agents</a></p></li><li><p><a href="https://www.decodingai.com/p/subagents-are-context-engineering">Subagents Are Context Engineering</a></p></li><li><p><a href="https://www.decodingai.com/p/coding-agents-in-remote-headless">Swarm of Remote Agents</a></p></li><li><p><a href="https://www.decodingai.com/p/evaluate-ai-agents-benchmarks-regression-tests">Agent Evals 101</a></p></li><li><p><a href="https://www.decodingai.com/p/transform-agent-traces-into-regression-cases">Turn Your Agent&#8217;s Failures Into a Regression Suite</a></p></li></ol><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course&quot;,&quot;text&quot;:&quot;Full open-source course&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course"><span>Full open-source course</span></a></p><p><em>Special thanks to <strong><a href="https://modal.com/?source=decodingai&amp;campaign=harnesseng">Modal</a></strong>, <strong><a href="https://www.comet.com/site/?utm_source=workshop&amp;utm_medium=partner&amp;utm_campaign=paul&amp;utm_content=coding_agent_course">Opik (by Comet)</a></strong>, and <strong><a href="https://www.zenml.io/product/kitaru?utm_source=decodingai&amp;utm_medium=referral&amp;utm_campaign=coding-agent-course&amp;utm_content=brand">Kitaru (by ZenML)</a></strong> for sponsoring this open-source course and keeping it free!</em></p></div><h1>Lesson 3: From Raw Shell to a Sandboxed Coding Agent<em>.</em></h1><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!k1Xr!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97e3b938-fb2a-462c-923f-fbd591667a65_1376x768.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!k1Xr!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97e3b938-fb2a-462c-923f-fbd591667a65_1376x768.png 424w, https://substackcdn.com/image/fetch/$s_!k1Xr!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97e3b938-fb2a-462c-923f-fbd591667a65_1376x768.png 848w, https://substackcdn.com/image/fetch/$s_!k1Xr!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97e3b938-fb2a-462c-923f-fbd591667a65_1376x768.png 1272w, https://substackcdn.com/image/fetch/$s_!k1Xr!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97e3b938-fb2a-462c-923f-fbd591667a65_1376x768.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!k1Xr!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97e3b938-fb2a-462c-923f-fbd591667a65_1376x768.png" width="1376" height="768" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/97e3b938-fb2a-462c-923f-fbd591667a65_1376x768.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:768,&quot;width&quot;:1376,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;The agent keeps all of its power. The room is what changes.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="The agent keeps all of its power. The room is what changes." title="The agent keeps all of its power. The room is what changes." srcset="https://substackcdn.com/image/fetch/$s_!k1Xr!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97e3b938-fb2a-462c-923f-fbd591667a65_1376x768.png 424w, https://substackcdn.com/image/fetch/$s_!k1Xr!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97e3b938-fb2a-462c-923f-fbd591667a65_1376x768.png 848w, https://substackcdn.com/image/fetch/$s_!k1Xr!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97e3b938-fb2a-462c-923f-fbd591667a65_1376x768.png 1272w, https://substackcdn.com/image/fetch/$s_!k1Xr!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97e3b938-fb2a-462c-923f-fbd591667a65_1376x768.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>Mid-session, Claude Code was running inside my Obsidian Second Brain when it fired off a cleanup command that deleted half my notes. If I hadn&#8217;t been backing them up with Obsidian Sync, two years of work would have been gone.</p><p>Even if you carefully isolate your agent, it can still reach the internet and go off the rails. In July 2026, <a href="https://www.scientificamerican.com/article/openai-admits-its-agent-went-rogue-and-hacked-ai-startup-hugging-face/">OpenAI&#8217;s agents</a> hacked Hugging Face. A week later, Anthropic <a href="https://www.anthropic.com/news/investigating-incidents-cybersecurity-evals">disclosed</a> that, after analyzing 141,006 eval runs from an isolated harness, their Claude models had gained unauthorized access to production infrastructure across 3 real organizations.</p><p>Still, for normal people who care about protecting their data, sandboxing is THE containment solution.</p><p>In Lesson 2, we saw how to implement an agent loop that controls your computer through 4 core tools: <code>read</code>, <code>write</code>, <code>edit</code>, and <code>bash</code>. In this article, we will learn how to isolate every computer-use tool from the rest of your system inside a <strong>sandbox</strong>.</p><p>We will hook it to two types of sandbox backends &#8212; local Docker and remote Modal &#8212; plus explore the other options and their trade-offs.</p><p>The cherry on top? GPU compute and scaling out of the box, plugged straight into your harness as a control center.</p><p>By the end, you will run:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;plaintext&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-plaintext">SANDBOX_MODE=modal decode --repo https://github.com/&lt;your-repo&gt;.git "Swap from Gemini to Kimi K3."</code></pre></div><p>Which will spin up a remote Modal sandbox hooked to Decode &#8212; the educational harness we are building throughout this course &#8212; set up the given repo, implement the requested feature, and end with a PR for review as the final artifact.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course&quot;,&quot;text&quot;:&quot;Try it yourself&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course"><span>Try it yourself</span></a></p><h2>The tools you love already use a sandbox</h2><p>Locally, every <code>bash</code> command Claude Code or <a href="https://github.com/openai/codex">Codex CLI</a> runs is wrapped in an OS-level jail &#8212; Seatbelt on macOS, bubblewrap on Linux (kernel features that block a process&#8217;s filesystem reach and syscalls).</p><p>In the cloud, Codex isolates <a href="https://blog.bytebytego.com/p/how-openai-codex-works">every task in its own environment (aka sandbox) preloaded with your repo</a>.</p><p><strong>In that case, what&#8217;s a sandbox?</strong> It&#8217;s an execution boundary: the agent runs every tool that can alter the host inside a &#8220;jail&#8221;, so a wrong command runs inside a container, not your host.</p><p>Ok&#8230; That&#8217;s abstract. So how does a harness actually run its tools in this &#8220;jail&#8221;?</p><h2>How do sandboxes actually work?</h2><p>In <a href="https://www.decodingai.com/p/the-coding-agent-loop">Lesson 2</a>, we learned that the core tools the agent uses to interact with your computer are <code>read</code>, <code>write</code>, <code>edit</code>, and <code>bash</code>. The rest (<code>web_fetch</code>, <code>todo_write</code>, <code>ask_user</code>, plan mode) never touch the filesystem &#8212; they are meta tools for fetching context and planning. That&#8217;s why, following Pi&#8217;s philosophy, they are optional.</p><p>Thus, our problem reduces to isolating the execution of the core tools from the rest of the harness. There are two main approaches.</p><p>In <strong>option 1,</strong> we run the whole harness in a Docker container or a remote Modal sandbox. It is straightforward and gives complete isolation, but it forces you to work in an environment different from your machine, with little flexibility to isolate specific tasks.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!7A90!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a626466-af9c-4245-a046-b7b1c11819cf_1200x498.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!7A90!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a626466-af9c-4245-a046-b7b1c11819cf_1200x498.png 424w, https://substackcdn.com/image/fetch/$s_!7A90!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a626466-af9c-4245-a046-b7b1c11819cf_1200x498.png 848w, https://substackcdn.com/image/fetch/$s_!7A90!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a626466-af9c-4245-a046-b7b1c11819cf_1200x498.png 1272w, https://substackcdn.com/image/fetch/$s_!7A90!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a626466-af9c-4245-a046-b7b1c11819cf_1200x498.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!7A90!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a626466-af9c-4245-a046-b7b1c11819cf_1200x498.png" width="1200" height="498" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0a626466-af9c-4245-a046-b7b1c11819cf_1200x498.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:498,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;The one decision that defines the architecture &#8212; put the whole harness in the box, or keep it home and send only its tools across.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="The one decision that defines the architecture &#8212; put the whole harness in the box, or keep it home and send only its tools across." title="The one decision that defines the architecture &#8212; put the whole harness in the box, or keep it home and send only its tools across." srcset="https://substackcdn.com/image/fetch/$s_!7A90!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a626466-af9c-4245-a046-b7b1c11819cf_1200x498.png 424w, https://substackcdn.com/image/fetch/$s_!7A90!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a626466-af9c-4245-a046-b7b1c11819cf_1200x498.png 848w, https://substackcdn.com/image/fetch/$s_!7A90!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a626466-af9c-4245-a046-b7b1c11819cf_1200x498.png 1272w, https://substackcdn.com/image/fetch/$s_!7A90!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a626466-af9c-4245-a046-b7b1c11819cf_1200x498.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>The one decision that defines the architecture: Put the whole harness in the sandbox, or keep it local and only execute tools inside the sandbox.</em></figcaption></figure></div><p>In <strong>option 2</strong>, we run the computer-use tools in a sandbox while the harness and the rest of the tools stay on the host. You keep your harness as your control center while executing tools inside the sandbox.</p><p>Option 1 is as simple as SSH-ing into a remote machine and running <code>claude</code>. Option 2 is where the real harness engineering happens.</p><p>The second dimension we have to think about is where the sandbox runs: locally in Docker or remotely on Modal.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!7aEX!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde23dee8-a770-4dd1-9d50-4ea4dfb6a1e9_1200x484.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!7aEX!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde23dee8-a770-4dd1-9d50-4ea4dfb6a1e9_1200x484.png 424w, https://substackcdn.com/image/fetch/$s_!7aEX!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde23dee8-a770-4dd1-9d50-4ea4dfb6a1e9_1200x484.png 848w, https://substackcdn.com/image/fetch/$s_!7aEX!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde23dee8-a770-4dd1-9d50-4ea4dfb6a1e9_1200x484.png 1272w, https://substackcdn.com/image/fetch/$s_!7aEX!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde23dee8-a770-4dd1-9d50-4ea4dfb6a1e9_1200x484.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!7aEX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde23dee8-a770-4dd1-9d50-4ea4dfb6a1e9_1200x484.png" width="1200" height="484" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/de23dee8-a770-4dd1-9d50-4ea4dfb6a1e9_1200x484.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:484,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Where a bash tool call actually runs &#8212; remote on Modal, locally in Docker, or raw on the host.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Where a bash tool call actually runs &#8212; remote on Modal, locally in Docker, or raw on the host." title="Where a bash tool call actually runs &#8212; remote on Modal, locally in Docker, or raw on the host." srcset="https://substackcdn.com/image/fetch/$s_!7aEX!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde23dee8-a770-4dd1-9d50-4ea4dfb6a1e9_1200x484.png 424w, https://substackcdn.com/image/fetch/$s_!7aEX!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde23dee8-a770-4dd1-9d50-4ea4dfb6a1e9_1200x484.png 848w, https://substackcdn.com/image/fetch/$s_!7aEX!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde23dee8-a770-4dd1-9d50-4ea4dfb6a1e9_1200x484.png 1272w, https://substackcdn.com/image/fetch/$s_!7aEX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde23dee8-a770-4dd1-9d50-4ea4dfb6a1e9_1200x484.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>The core idea behind sandboxing computer-use tools such as bash.</em></figcaption></figure></div><p>Regardless of where the sandbox runs, every computer-use tool call gets wrapped in an <code>inSandbox(command)</code> call. In our educational coding harness, Decode, we defined a <code>CommandExecutor</code> interface with 2 implementations (<code>LocalExecutor</code> for the host, <code>SandboxExecutor</code> for a backend), powered by 2 <strong>sandbox backends</strong>: <code>DockerBackend</code> or <code>ModalBackend</code>.</p><p><em>From <a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course/blob/main/src/decode/sandbox/__init__.py">src/decode/sandbox/__init__.py</a>:</em></p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">def select_executor(mode: str) -&gt; CommandExecutor:
    if mode == "docker":
        return SandboxExecutor(DockerBackend())
    if mode == "modal":
        return SandboxExecutor(ModalBackend())
    from decode.tools.exec import LocalExecutor

    return LocalExecutor()</code></pre></div><p>The tool never knows where the command runs. The LLM emits the command, while the harness takes care of executing it in the selected environment. Once we build the right executor, we just call <code>executor.run(command)</code>, completely abstracted away from the sandbox &#8212; which means we can extend it with sandboxes beyond Docker or Modal.</p><p><em>From <a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course/blob/main/src/decode/tools/bash.py">src/decode/tools/bash.py</a>:</em></p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">async def bash(
    ctx: RunContext[AgentDeps],
    command: str,
    timeout: float | None = None,
) -&gt; str:
    if needs_approval(ctx):
        raise ApprovalRequired  # Permission gate &#8212; before anything runs

    if not command.strip():
        raise ModelRetry("command is empty; provide a shell command to run.")
    timeout_s = _resolve_timeout(timeout)

    executor = await _get_executor() # sandbox (powered by Docker or Modal) or local
    result = await executor.run(command, cwd=ctx.deps.cwd, timeout_s=timeout_s)

    return _render(result, timeout_s=timeout_s)</code></pre></div><p>We adopt a similar strategy for the <code>read</code>, <code>write</code>, and <code>edit</code> tools, plus optional ones such as <code>glob</code> and <code>ls</code>. That way the agent sees a single filesystem: when <code>write</code> creates a file, <code>bash</code> sees it immediately.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!uAaO!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1215db45-22b7-45ea-a80d-ce91ae11cda2_1200x592.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!uAaO!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1215db45-22b7-45ea-a80d-ce91ae11cda2_1200x592.png 424w, https://substackcdn.com/image/fetch/$s_!uAaO!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1215db45-22b7-45ea-a80d-ce91ae11cda2_1200x592.png 848w, https://substackcdn.com/image/fetch/$s_!uAaO!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1215db45-22b7-45ea-a80d-ce91ae11cda2_1200x592.png 1272w, https://substackcdn.com/image/fetch/$s_!uAaO!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1215db45-22b7-45ea-a80d-ce91ae11cda2_1200x592.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!uAaO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1215db45-22b7-45ea-a80d-ce91ae11cda2_1200x592.png" width="1200" height="592" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1215db45-22b7-45ea-a80d-ce91ae11cda2_1200x592.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:592,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;The executor seam in motion &#8212; the agent loop keeps emitting bash calls on your machine, and each one runs as a command inside the sandbox.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="The executor seam in motion &#8212; the agent loop keeps emitting bash calls on your machine, and each one runs as a command inside the sandbox." title="The executor seam in motion &#8212; the agent loop keeps emitting bash calls on your machine, and each one runs as a command inside the sandbox." srcset="https://substackcdn.com/image/fetch/$s_!uAaO!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1215db45-22b7-45ea-a80d-ce91ae11cda2_1200x592.png 424w, https://substackcdn.com/image/fetch/$s_!uAaO!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1215db45-22b7-45ea-a80d-ce91ae11cda2_1200x592.png 848w, https://substackcdn.com/image/fetch/$s_!uAaO!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1215db45-22b7-45ea-a80d-ce91ae11cda2_1200x592.png 1272w, https://substackcdn.com/image/fetch/$s_!uAaO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1215db45-22b7-45ea-a80d-ce91ae11cda2_1200x592.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>The executor logic: The agent loop keeps emitting bash calls on your machine, and each one runs as a command inside the sandbox.</em></figcaption></figure></div><p>Now, let&#8217;s zoom in on how local sandboxes work via Docker.</p><h2>Local sandboxes via Docker</h2><p>Run &#8220;<code>SANDBOX_MODE=docker decode --repo git@github.com:you/project.git"</code> to start a new Decode session inside a Docker sandbox, which contains 5 main steps:</p><ol><li><p><code>DockerBackend</code> launches one long-lived <strong>keeper container</strong> running <code>sleep infinity</code>.</p></li><li><p>Injects all the environment variables from <code>.env</code> into the container.</p></li><li><p>Attaches a local volume at <code>.decode/sandbox</code>.</p></li><li><p>Prepares <strong>the Workspace</strong> by cloning <code>--repo</code> into <code>.decode/sandbox</code> at HEAD.</p></li><li><p>Installs the dependencies by running <code>uv sync</code> on the given <code>--repo</code>.</p></li></ol><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!gae9!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd37a1cb-ef55-4cf9-b5e4-8d823e392358_1200x309.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!gae9!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd37a1cb-ef55-4cf9-b5e4-8d823e392358_1200x309.png 424w, https://substackcdn.com/image/fetch/$s_!gae9!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd37a1cb-ef55-4cf9-b5e4-8d823e392358_1200x309.png 848w, https://substackcdn.com/image/fetch/$s_!gae9!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd37a1cb-ef55-4cf9-b5e4-8d823e392358_1200x309.png 1272w, https://substackcdn.com/image/fetch/$s_!gae9!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd37a1cb-ef55-4cf9-b5e4-8d823e392358_1200x309.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!gae9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd37a1cb-ef55-4cf9-b5e4-8d823e392358_1200x309.png" width="1200" height="309" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/bd37a1cb-ef55-4cf9-b5e4-8d823e392358_1200x309.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:309,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Session start in Docker mode is a straight line &#8212; create the container, inject the env vars, bind the Workspace volume, download the repo, install dependencies.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Session start in Docker mode is a straight line &#8212; create the container, inject the env vars, bind the Workspace volume, download the repo, install dependencies." title="Session start in Docker mode is a straight line &#8212; create the container, inject the env vars, bind the Workspace volume, download the repo, install dependencies." srcset="https://substackcdn.com/image/fetch/$s_!gae9!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd37a1cb-ef55-4cf9-b5e4-8d823e392358_1200x309.png 424w, https://substackcdn.com/image/fetch/$s_!gae9!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd37a1cb-ef55-4cf9-b5e4-8d823e392358_1200x309.png 848w, https://substackcdn.com/image/fetch/$s_!gae9!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd37a1cb-ef55-4cf9-b5e4-8d823e392358_1200x309.png 1272w, https://substackcdn.com/image/fetch/$s_!gae9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd37a1cb-ef55-4cf9-b5e4-8d823e392358_1200x309.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Docker sandbox lifecycle: Create the container, inject the env vars, bind the Workspace volume, download the repo, install dependencies.</em></figcaption></figure></div><p>Within the <code>DockerBackend</code> class, plugged into <code>SandboxExecutor</code>, we have 2 functions to implement: <code>create</code> and <code>exec</code>. <code>create</code> mostly goes through the 5 steps outlined above. In <code>exec</code>, each <code>bash</code> call translates to a <code>docker exec &lt;command&gt;</code> against its associated container.</p><p><em>From <a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course/blob/main/src/decode/sandbox/docker_backend.py">src/decode/sandbox/docker_backend.py</a>:</em></p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">_WORKSPACE = "/workspace"  # container-side path of the Workspace

class DockerBackend:
    async def create(self, workspace: Path) -&gt; None:
        # once, at session start
        # `workspace` is the host-side clone of your
        # --repo at .decode/sandbox

        args = ["run", "-d", "--rm", "-v", f"{workspace}:{_WORKSPACE}", "-w", _WORKSPACE]
        if sandbox_git_token():
            args += ["-e", GIT_TOKEN_ENV]
        args += ["ghcr.io/astral-sh/uv:python3.12-bookworm-slim", "sleep", "infinity"]
        proc = await asyncio.create_subprocess_exec(
            "docker", *args,
            stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE,
            env=_run_env(), 
        )
        stdout, _ = await proc.communicate()
        container_id = stdout.decode().strip()  # `docker run -d` prints the container id

    async def exec(self, *args: str, timeout_s: float) -&gt; ExecResult:
        # for every bash tool call &#8212; a fresh exec
        proc = await asyncio.create_subprocess_exec(
            "docker", "exec", "-w", _WORKSPACE, container_id, *args,
            stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE,
            start_new_session=True,  # own process group &#8594; kill as a unit on timeout
        )
        ...  # gather stdout/stderr &#8594; ExecResult</code></pre></div><p>Docker is easy to set up, works out of the box with container tooling, and the same containers can later be hosted remotely via Kubernetes or other orchestrators. As good as that sounds, it isn&#8217;t truly secure. Container processes are <a href="https://www.youtube.com/watch?v=wsFd22SL1s8">native processes on your kernel</a>. As Abhishek Bhardwaj, on OpenAI&#8217;s RL and agent-infrastructure team, puts it, a container process can exploit that boundary and take the host &#8212; a kernel exploit is <a href="https://www.youtube.com/watch?v=OqM67QG_Ikk">&#8220;a New York Times article waiting to happen&#8221;</a>.</p><p>Docker sits on a spectrum:</p><ol><li><p><strong>fork/exec</strong> &#8212; straightforward to implement, no boundary. The command talks straight to your kernel.</p></li><li><p><strong>Containers</strong> &#8592; <strong>we are here.</strong> A namespace-and-cgroup boundary. Shared kernel. Another option is Podman, which doesn&#8217;t use a daemon, saving latency.</p></li><li><p><strong>gVisor</strong> &#8212; a user-space &#8220;sentry&#8221; kernel answers the syscalls, turning a direct kernel exploit into a two-hop chain (sentry &#8594; host kernel). Costs little: near-container performance. It&#8217;s what <a href="https://modal.com/docs/guide/security?source=decodingai&amp;campaign=harnesseng">Modal runs underneath its sandboxes</a>. Not perfect. If the agent gets past the sentry, you&#8217;re back on the shared kernel.</p></li><li><p><strong>microVMs</strong> &#8212; <a href="https://github.com/firecracker-microvm/firecracker">Firecracker</a> or <a href="https://www.cloudhypervisor.org/">Cloud Hypervisor</a> on KVM, the Linux kernel&#8217;s own hypervisor (Linux hosts only). The guest kernel runs in a separate CPU execution context from the host, so even if the agent fully compromises it, it can&#8217;t reach yours. Cheaper than it sounds: <a href="https://github.com/abshkbh/arrakis">Arrakis</a> boots one in under 7s, against ~40s for a traditional VM.</p></li></ol><p><strong>Seatbelt and bubblewrap sit on the same layer as containers.</strong> They are OS jails. They wrap one command instead of the whole machine, deriving the filesystem profile from the permission rules the agent already uses. No image, no daemon. Still sharing your host&#8217;s kernel. That&#8217;s what Claude Code and Codex CLI run locally. Cheaper than Docker, not stronger.</p><p>So which one? If you trust the code and just want your own files safe, go with <strong>containers</strong> (as we did in Decode). Otherwise, for full isolation, go with <strong>microVMs</strong>. Bhardwaj&#8217;s verdict, after building OpenAI&#8217;s sandbox cloud: <a href="https://www.youtube.com/watch?v=OqM67QG_Ikk">&#8220;in the end, everyone always wants a VM&#8230; let me save you the story and two years of grief, just please use microVMs from the start&#8221;</a>.</p><p>To run it on your own machine, follow the <a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course#-running-the-code">&#8220;Running the Code&#8221; setup steps</a> in the course repo, then launch:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;plaintext&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-plaintext">SANDBOX_MODE=docker decode --repo https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course.git</code></pre></div><p>This clones the repo into the isolated Workspace (<code>/workspace</code> &#8801; host <code>.decode/sandbox</code>) and opens a new TUI session wired to the Docker container. To test it out, pick any feature, plan it, ask for a PR, and let Decode do the rest.</p><p>For a quick test, we prepared a demo wrapped as the <code>/demo-5-sandbox-feature-pr</code> skill. It uses Decode to spin up a new sandboxed Decode session and instructs it to implement a small feature from a pool of available ones (e.g. a <code>decode --version</code> CLI command), then open a PR with it. Creating feature PRs is essential when working in sandboxes, as you have no direct access to where the code actually runs.</p><p>The real win, though, is when the box isn&#8217;t on your machine at all.</p><h2>Remote sandboxes via Modal</h2><p><a href="https://modal.com/?source=decodingai&amp;campaign=harnesseng">Modal</a>&#8216;s core primitive is <a href="https://modal.com/docs/guide/sandboxes?source=decodingai&amp;campaign=harnesseng">the sandbox</a> &#8212; an isolated, serverless runtime that starts in under half a second.</p><p>Run &#8220;<code>SANDBOX_MODE=modal decode --repo git@github.com:you/project.git"</code> and here is what happens through Modal&#8217;s 5-event lifecycle:</p><ol><li><p><strong>Created</strong>: <code>ModalBackend</code> requests a sandbox under <code>decode-sandbox-&lt;env&gt;</code>.</p></li><li><p><strong>Scheduled</strong>: Modal finds capacity on its infra.</p></li><li><p><strong>Started</strong>: the container is live and can execute commands (but the app is not ready yet).</p></li><li><p><strong>Ready</strong>: the tar containing the app files is uploaded into <code>/workspace</code> (making the app env ready).</p></li><li><p><strong>In use</strong>: <code>bash</code> and the other computer-use tools exec successfully against the remote.</p></li></ol><p>Modal&#8217;s sandbox infra boots fast. Preparing the app dependencies is what takes a while.</p><p>That&#8217;s why, as you can see in the image below, we mount a volume that already contains the app dependencies, so they are ready when the container starts. On top of that, to avoid the cold start problem &#8212; you want the sandbox ready as soon as the harness starts &#8212; we prepare a sandbox pool modeled as a queue. We populate it with application-agnostic sandboxes and turn them into application-specific ones by attaching a volume. This combination of sandbox pool plus volume mounting gives us application-ready sandboxes on demand. More on this <a href="https://modal.com/blog/unpacking-sandbox-startup-latency?source=decodingai&amp;campaign=harnesseng">here</a>.</p><blockquote><p>Check <a href="https://modal.com/blog/scaling-to-1-million-concurrent-sandboxes-in-seconds?source=decodingai&amp;campaign=harnesseng">this blog post</a> if you want to learn more about how Modal dropped Kubernetes and built its sandbox architecture from scratch to start 1 million concurrent sandboxes in under a minute.</p></blockquote><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Uvba!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fbbf5d8-c0e6-45ff-95c3-5c9555da65a2_1200x618.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Uvba!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fbbf5d8-c0e6-45ff-95c3-5c9555da65a2_1200x618.png 424w, https://substackcdn.com/image/fetch/$s_!Uvba!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fbbf5d8-c0e6-45ff-95c3-5c9555da65a2_1200x618.png 848w, https://substackcdn.com/image/fetch/$s_!Uvba!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fbbf5d8-c0e6-45ff-95c3-5c9555da65a2_1200x618.png 1272w, https://substackcdn.com/image/fetch/$s_!Uvba!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fbbf5d8-c0e6-45ff-95c3-5c9555da65a2_1200x618.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!Uvba!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fbbf5d8-c0e6-45ff-95c3-5c9555da65a2_1200x618.png" width="1200" height="618" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6fbbf5d8-c0e6-45ff-95c3-5c9555da65a2_1200x618.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:618,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;The Modal backend &#8212; the harness stays local, every tool call crosses into a remote sandbox that mounts its repository volume, and sandboxes come pre-provisioned from a pool.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="The Modal backend &#8212; the harness stays local, every tool call crosses into a remote sandbox that mounts its repository volume, and sandboxes come pre-provisioned from a pool." title="The Modal backend &#8212; the harness stays local, every tool call crosses into a remote sandbox that mounts its repository volume, and sandboxes come pre-provisioned from a pool." srcset="https://substackcdn.com/image/fetch/$s_!Uvba!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fbbf5d8-c0e6-45ff-95c3-5c9555da65a2_1200x618.png 424w, https://substackcdn.com/image/fetch/$s_!Uvba!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fbbf5d8-c0e6-45ff-95c3-5c9555da65a2_1200x618.png 848w, https://substackcdn.com/image/fetch/$s_!Uvba!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fbbf5d8-c0e6-45ff-95c3-5c9555da65a2_1200x618.png 1272w, https://substackcdn.com/image/fetch/$s_!Uvba!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fbbf5d8-c0e6-45ff-95c3-5c9555da65a2_1200x618.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>The Modal backend: The harness stays local, every tool call crosses into a remote sandbox that mounts its repository volume, and sandboxes come pre-provisioned from a pool.</em></figcaption></figure></div><p>The <code>ModalBackend</code> class looks similar to the <code>DockerBackend</code> one. Inside <code>create</code>, we create the sandbox from a pre-built <code>uv</code> Docker image. We inject a git token to get access to our private repositories. Finally, we launch it with the <code>sleep infinity</code> command to keep it running &#8212; now on Modal&#8217;s infrastructure, which takes care of our security concerns.</p><p><strong>Modal puts zero risk on your host.</strong> It&#8217;s remote, and it runs gVisor to intercept syscalls before they reach the kernel. Even when OpenAI&#8217;s agents hacked Hugging Face, as reported <a href="https://www.aljazeera.com/news/2026/7/29/openais-rogue-agent-hacked-an-account-at-a-second-technology-firm-report">here</a>, their code was running on one of Modal&#8217;s sandboxes &#8212; the agent exploited Hugging Face&#8217;s code running there, not the Modal infrastructure itself.</p><p>Within the <code>exec</code> method, we execute the command that comes from the LLM and return the output and exit code.</p><p><em>From <a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course/blob/main/src/decode/sandbox/modal_backend.py">src/decode/sandbox/modal_backend.py</a>:</em></p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">class ModalBackend:
    async def create(self, workspace: Path) -&gt; None:
        app = await modal.App.lookup.aio(_app_name(), create_if_missing=True)
        image = modal.Image.from_registry(
            "ghcr.io/astral-sh/uv:python3.12-bookworm-slim"
        ).apt_install("git", "curl", "ca-certificates")

        secrets = []
        if token := sandbox_git_token():
            image = image.run_commands(GIT_CREDENTIAL_HELPER)
            secrets = [modal.Secret.from_dict({GIT_TOKEN_ENV: token})]

        sandbox = await modal.Sandbox.create.aio(
            "sleep", "infinity",
            app=app, image=image,
            timeout=int(settings.sandbox_timeout_s),
            secrets=secrets,
        )

        ...  # tar-upload the Workspace into /workspace &#8212; the "Ready" step

    async def exec(self, *args: str, timeout_s: float) -&gt; ExecResult:
        proc = await sandbox.exec.aio(*args, workdir=workdir, timeout=timeout, text=False)
        stdout, stderr = await asyncio.gather(proc.stdout.read.aio(), proc.stderr.read.aio())
        exit_code = await proc.wait.aio()

        ...  # &#8594; ExecResult</code></pre></div><p>From <a href="https://modal.com/pricing?source=decodingai&amp;campaign=harnesseng">Modal&#8217;s pricing page</a> at the time of writing: a CPU sandbox at 2 cores + 4 GiB runs &#8776; 0.38/<em>hr</em>, <em>a</em> <em>B</em>200 <em>GPU</em> <em>bills</em> &#8776;6.25/hr, and an H200 &#8776; $4.54/hr. For pure agentic work, the CPU sandbox gets the job done, while the GPU ones let you run inference or fine-tuning jobs directly from your harness.</p><p>The default is using the CPU sandbox. To configure it with x4 H200 we would do:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;plaintext&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-plaintext">sandbox = await modal.Sandbox.create.aio(
    ...,              # Same parameters as the CPU sandbox
    gpu="H200:4",     # 4&#215; H200 attached to this sandbox
)</code></pre></div><p>As discussed in <a href="https://www.decodingai.com/i/208432780/the-llm-providers">Lesson 2</a> on pay-per-token vs. serverless, for ad-hoc data processing serverless can come out ~80-90% cheaper.</p><p>The trade-offs of a remote sandbox over a local one: network latency, sandbox management, and extra costs.</p><p>You can run the same test as for the Docker sandbox by following the <a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course#-running-the-code">&#8220;Running the Code&#8221; Modal extra setup steps</a> and swapping <code>SANDBOX_MODE=docker</code> for <code>modal</code>:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;plaintext&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-plaintext">SANDBOX_MODE=modal decode --repo https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course.git</code></pre></div><p>After running it, Modal&#8217;s dashboard shows how many sandboxes are live (5 in our case):</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!5yvV!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb61bc42-9973-4655-8108-40308b5a9a8c_3288x978.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!5yvV!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb61bc42-9973-4655-8108-40308b5a9a8c_3288x978.png 424w, https://substackcdn.com/image/fetch/$s_!5yvV!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb61bc42-9973-4655-8108-40308b5a9a8c_3288x978.png 848w, https://substackcdn.com/image/fetch/$s_!5yvV!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb61bc42-9973-4655-8108-40308b5a9a8c_3288x978.png 1272w, https://substackcdn.com/image/fetch/$s_!5yvV!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb61bc42-9973-4655-8108-40308b5a9a8c_3288x978.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!5yvV!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb61bc42-9973-4655-8108-40308b5a9a8c_3288x978.png" width="1456" height="433" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/db61bc42-9973-4655-8108-40308b5a9a8c_3288x978.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:433,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Number of running sandboxes in Modal&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Number of running sandboxes in Modal" title="Number of running sandboxes in Modal" srcset="https://substackcdn.com/image/fetch/$s_!5yvV!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb61bc42-9973-4655-8108-40308b5a9a8c_3288x978.png 424w, https://substackcdn.com/image/fetch/$s_!5yvV!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb61bc42-9973-4655-8108-40308b5a9a8c_3288x978.png 848w, https://substackcdn.com/image/fetch/$s_!5yvV!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb61bc42-9973-4655-8108-40308b5a9a8c_3288x978.png 1272w, https://substackcdn.com/image/fetch/$s_!5yvV!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb61bc42-9973-4655-8108-40308b5a9a8c_3288x978.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>And if you open the sandbox app and click &#8220;Sandboxes&#8221;, you get the full list:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!0AC-!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fccdaad8d-8c2a-4918-9513-5cd9abb6c812_3088x1086.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!0AC-!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fccdaad8d-8c2a-4918-9513-5cd9abb6c812_3088x1086.png 424w, https://substackcdn.com/image/fetch/$s_!0AC-!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fccdaad8d-8c2a-4918-9513-5cd9abb6c812_3088x1086.png 848w, https://substackcdn.com/image/fetch/$s_!0AC-!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fccdaad8d-8c2a-4918-9513-5cd9abb6c812_3088x1086.png 1272w, https://substackcdn.com/image/fetch/$s_!0AC-!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fccdaad8d-8c2a-4918-9513-5cd9abb6c812_3088x1086.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!0AC-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fccdaad8d-8c2a-4918-9513-5cd9abb6c812_3088x1086.png" width="1456" height="512" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ccdaad8d-8c2a-4918-9513-5cd9abb6c812_3088x1086.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:512,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;The list of running sandboxes inside the Modal sandbox app&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="The list of running sandboxes inside the Modal sandbox app" title="The list of running sandboxes inside the Modal sandbox app" srcset="https://substackcdn.com/image/fetch/$s_!0AC-!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fccdaad8d-8c2a-4918-9513-5cd9abb6c812_3088x1086.png 424w, https://substackcdn.com/image/fetch/$s_!0AC-!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fccdaad8d-8c2a-4918-9513-5cd9abb6c812_3088x1086.png 848w, https://substackcdn.com/image/fetch/$s_!0AC-!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fccdaad8d-8c2a-4918-9513-5cd9abb6c812_3088x1086.png 1272w, https://substackcdn.com/image/fetch/$s_!0AC-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fccdaad8d-8c2a-4918-9513-5cd9abb6c812_3088x1086.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>These sandboxes are created when you enter a new Decode session and automatically cleaned up when you exit via the <code>/quit</code> command.</p><h2>The wanted side effects of remote sandboxes</h2><p>Remote sandboxes give you 2 powerful side effects beyond safety.</p><p><strong>The first is compute.</strong> Modal sandboxes accept a <a href="https://modal.com/blog/how-to-price-serverless?source=decodingai&amp;campaign=harnesseng">GPU spec like </a><code>gpu="B200:8"</code><a href="https://modal.com/blog/how-to-price-serverless?source=decodingai&amp;campaign=harnesseng"> at creation</a>, letting you agentically fine-tune models or process large datasets (eg extracting knowledge graphs from 1000+ documents) with open-weight LLMs such as Qwen3.6, Gemma 4, K3, or GLM5.2.</p><p><strong>The second is scale.</strong> An orchestrator agent running directly on the host (no sandbox) can hand work to background agents running on Modal remote sandboxes. Put them on a CPU if you just need a bunch of parallel agents hitting an LLM API to pull tickets from your Linear backlog, or on a GPU if you need to squeeze out more juice.</p><p>In <a href="https://modal.com/blog/how-ramp-built-a-full-context-background-coding-agent-on-modal?source=decodingai&amp;campaign=harnesseng">this case study</a>, Ramp, a fintech company, runs every agent session in its own Modal sandbox with a full dev environment inside. Modal&#8217;s own conclusion from the case study is that with cheap isolation, the bottleneck shifts from &#8220;can the agent write correct code&#8221; to &#8220;how many agents can you run in parallel&#8221;.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Vi-q!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e446570-e1bb-4559-a85a-e95d6bcb4795_1200x551.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Vi-q!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e446570-e1bb-4559-a85a-e95d6bcb4795_1200x551.png 424w, https://substackcdn.com/image/fetch/$s_!Vi-q!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e446570-e1bb-4559-a85a-e95d6bcb4795_1200x551.png 848w, https://substackcdn.com/image/fetch/$s_!Vi-q!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e446570-e1bb-4559-a85a-e95d6bcb4795_1200x551.png 1272w, https://substackcdn.com/image/fetch/$s_!Vi-q!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e446570-e1bb-4559-a85a-e95d6bcb4795_1200x551.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!Vi-q!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e446570-e1bb-4559-a85a-e95d6bcb4795_1200x551.png" width="1200" height="551" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4e446570-e1bb-4559-a85a-e95d6bcb4795_1200x551.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:551,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;The scaling shape the seam makes possible &#8212; an unsandboxed orchestrator on your machine fans work out to N background agents, each contained in its own sandbox.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="The scaling shape the seam makes possible &#8212; an unsandboxed orchestrator on your machine fans work out to N background agents, each contained in its own sandbox." title="The scaling shape the seam makes possible &#8212; an unsandboxed orchestrator on your machine fans work out to N background agents, each contained in its own sandbox." srcset="https://substackcdn.com/image/fetch/$s_!Vi-q!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e446570-e1bb-4559-a85a-e95d6bcb4795_1200x551.png 424w, https://substackcdn.com/image/fetch/$s_!Vi-q!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e446570-e1bb-4559-a85a-e95d6bcb4795_1200x551.png 848w, https://substackcdn.com/image/fetch/$s_!Vi-q!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e446570-e1bb-4559-a85a-e95d6bcb4795_1200x551.png 1272w, https://substackcdn.com/image/fetch/$s_!Vi-q!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e446570-e1bb-4559-a85a-e95d6bcb4795_1200x551.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Scaling: An unsandboxed orchestrator on your machine fans work out to N background agents, each contained in its own sandbox.</em></figcaption></figure></div><h2>Next steps</h2><p>Should you sandbox all the time? No. As a Claude Code power user, to keep it simple, I still run directly on my machine in folders versioned by git or Obsidian Sync.</p><p>Sandboxes are non-negotiable for:</p><ul><li><p>24/7 personal assistants that control your whole computer like <a href="https://openclaw.ai/">OpenClaw</a> or Hermes;</p></li><li><p>non-engineers using tools like <a href="https://www.anthropic.com/product/claude-cowork">Claude Cowork</a>;</p></li><li><p>unmonitored remote jobs like <a href="https://openai.com/research/codex">Codex</a>;</p></li><li><p>or when chasing GPUs and parallel scale.</p></li></ul><p>Is this the only way to add sandboxes to your harness? As we are just getting started, surely not. For another perspective, <a href="https://www.youtube.com/watch?v=OqM67QG_Ikk">here is Abhishek Bhardwaj&#8217;s talk</a>, explaining how OpenAI runs agent workloads in a cloud of microVM sandboxes instead of containers.</p><div class="callout-block" data-callout="true"><p>&#129489;&#8205;&#128187; <span>We encourage you to&nbsp;</span><strong>clone our&nbsp;<a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course">course repo</a></strong><span>, open your terminal, type </span><strong><span data-color="#38761d" style="color: rgb(56, 118, 29);">&#8221;decode&#8221;</span></strong>,<strong> </strong>and test out the coding agent.</p></div><p>In the <a href="https://www.decodingai.com/p/context-engineering-for-coding-agents">next lesson</a>, we will explore the key context-engineering techniques that coding harnesses use: memory, compaction, skills, and LSP servers.</p><p>Here is the<strong> course roadmap, </strong>lesson by lesson <em>(<a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course#-course-outline">see all in GitHub</a></em>):</p><ol><li><p><a href="https://www.decodingai.com/p/building-a-coding-agent-from-scratch-system-design">Building a Coding Agent From Scratch</a><strong> </strong></p></li><li><p><a href="https://www.decodingai.com/p/the-coding-agent-loop">The Bare-Bones Coding Agent Loop </a></p></li><li><p><strong>From a Raw Shell to a Sandboxed Coding Agent</strong> <strong>&#8592; </strong><em><strong>you are here</strong></em></p></li><li><p><a href="https://www.decodingai.com/p/context-engineering-for-coding-agents">Context Engineering for Coding Agents</a></p></li><li><p><a href="https://www.decodingai.com/p/subagents-are-context-engineering">Subagents Are Context Engineering</a></p></li><li><p><a href="https://www.decodingai.com/p/coding-agents-in-remote-headless">Swarm of Remote Agents</a></p></li><li><p><a href="https://www.decodingai.com/p/evaluate-ai-agents-benchmarks-regression-tests">Agent Evals 101</a></p></li><li><p><a href="https://www.decodingai.com/p/transform-agent-traces-into-regression-cases">Turn Your Agent&#8217;s Failures Into a Regression Suite</a></p></li></ol><p><span>Or watch the </span><strong><span>video version</span></strong><span> of the lesson:</span></p><div id="youtube2-7CHMb8jWs6A" class="youtube-wrap" data-attrs="{&quot;videoId&quot;:&quot;7CHMb8jWs6A&quot;,&quot;startTime&quot;:null,&quot;endTime&quot;:null}" data-component-name="Youtube2ToDOM"><div class="youtube-inner"><iframe src="https://www.youtube-nocookie.com/embed/7CHMb8jWs6A?rel=0&amp;autoplay=0&amp;showinfo=0&amp;enablejsapi=0" frameborder="0" loading="lazy" gesture="media" allow="autoplay; fullscreen" allowautoplay="true" allowfullscreen="true" width="728" height="409"></iframe></div></div><p><em>But here is what I&#8217;m wondering:</em></p><blockquote><p><em><strong>Do you run your coding agent raw on your machine, or sandboxed?</strong></em></p></blockquote><p><em>Click the button below and tell me. I read every response.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://www.decodingai.com/p/run-coding-agents-safely/comments&quot;,&quot;text&quot;:&quot;Leave a comment&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://www.decodingai.com/p/run-coding-agents-safely/comments"><span>Leave a comment</span></a></p><div><hr></div><p><em>Enjoyed the article? The most sincere compliment is to restack this for your readers.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://www.decodingai.com/p/run-coding-agents-safely?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;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://www.decodingai.com/p/run-coding-agents-safely?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p><div><hr></div><p><em>Special thanks to <strong><a href="https://modal.com?source=decodingai&amp;campaign=harnesseng">Modal</a></strong>, <strong><a href="https://www.comet.com/site/?utm_source=newsletter&amp;utm_medium=partner&amp;utm_campaign=paul&amp;utm_content=coding_agent_course">Opik (by Comet)</a></strong>, and <strong><a href="https://www.zenml.io/product/kitaru?utm_source=decodingai&amp;utm_medium=referral&amp;utm_campaign=coding-agent-course&amp;utm_content=brand">Kitaru (by ZenML)</a></strong> for sponsoring this open-source course and keeping it free!</em></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Uq-1!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Uq-1!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 424w, https://substackcdn.com/image/fetch/$s_!Uq-1!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 848w, https://substackcdn.com/image/fetch/$s_!Uq-1!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 1272w, https://substackcdn.com/image/fetch/$s_!Uq-1!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!Uq-1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png" width="1200" height="400" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:400,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:69533,&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://www.decodingai.com/i/207400663?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.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_!Uq-1!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 424w, https://substackcdn.com/image/fetch/$s_!Uq-1!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 848w, https://substackcdn.com/image/fetch/$s_!Uq-1!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 1272w, https://substackcdn.com/image/fetch/$s_!Uq-1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><div><hr></div><div class="callout-block" data-callout="true"><h4>Whenever you&#8217;re ready, here is how I can help you</h4><p><em>Go from agent user to agent builder.</em> Master the foundations of AI agents and turn fragile demo code into reliable, production-ready systems with my course, <strong><a href="https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering">Agent Engineering: Building Multi-Agent Systems</a></strong> (made with Towards AI).</p><p>35 lessons. Pure foundations from scratch. 4 mini-projects. 2 production systems. A certificate and direct access to me &amp; industry experts in our Discord.</p><p>Built for software and data professionals transitioning into AI engineering. <em>Rated 5/5 with 300+ students. The first 7 lessons are free:</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering&quot;,&quot;text&quot;:&quot;Start here&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering"><span>Start here</span></a></p><p><em>Not ready to commit?</em> Start with our <strong><a href="https://email-course.towardsai.net/?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering">free Agent AI Engineering Guide</a></strong>, a 6-day email course on the mistakes that silently break AI agents in production.</p></div><div><hr></div><h2>Images &amp; videos</h2><p>If not otherwise stated, all images are created by the author.</p>]]></content:encoded></item><item><title><![CDATA[11 Tips to Run Coding Agents 24/7 on One Subscription]]></title><description><![CDATA[Context engineering techniques to avoid wasting tokens on what doesn't matter]]></description><link>https://www.decodingai.com/p/11-context-engineering-tips-cut-coding-agent-tokens</link><guid isPermaLink="false">https://www.decodingai.com/p/11-context-engineering-tips-cut-coding-agent-tokens</guid><dc:creator><![CDATA[Paul Iusztin]]></dc:creator><pubDate>Tue, 04 Aug 2026 11:04:10 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!-mAQ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff89ec8d0-4fe0-4c4e-be76-04cb2528a742_1376x768.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_!-mAQ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff89ec8d0-4fe0-4c4e-be76-04cb2528a742_1376x768.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!-mAQ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff89ec8d0-4fe0-4c4e-be76-04cb2528a742_1376x768.png 424w, https://substackcdn.com/image/fetch/$s_!-mAQ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff89ec8d0-4fe0-4c4e-be76-04cb2528a742_1376x768.png 848w, https://substackcdn.com/image/fetch/$s_!-mAQ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff89ec8d0-4fe0-4c4e-be76-04cb2528a742_1376x768.png 1272w, https://substackcdn.com/image/fetch/$s_!-mAQ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff89ec8d0-4fe0-4c4e-be76-04cb2528a742_1376x768.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!-mAQ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff89ec8d0-4fe0-4c4e-be76-04cb2528a742_1376x768.png" width="1376" height="768" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f89ec8d0-4fe0-4c4e-be76-04cb2528a742_1376x768.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:768,&quot;width&quot;:1376,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;The archive is enormous. What sits under the lamp is three cards.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="The archive is enormous. What sits under the lamp is three cards." title="The archive is enormous. What sits under the lamp is three cards." srcset="https://substackcdn.com/image/fetch/$s_!-mAQ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff89ec8d0-4fe0-4c4e-be76-04cb2528a742_1376x768.png 424w, https://substackcdn.com/image/fetch/$s_!-mAQ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff89ec8d0-4fe0-4c4e-be76-04cb2528a742_1376x768.png 848w, https://substackcdn.com/image/fetch/$s_!-mAQ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff89ec8d0-4fe0-4c4e-be76-04cb2528a742_1376x768.png 1272w, https://substackcdn.com/image/fetch/$s_!-mAQ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff89ec8d0-4fe0-4c4e-be76-04cb2528a742_1376x768.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>I&#8217;m on vacation, so today I will keep it short.</p><p>Since February 2026, when I got my $200 Anthropic subscription, I maxed it out only once. It happened when Fable was released, and I started using it the way I used previous models such as Opus. After 4-5 queries through my content and software factories, I was running out of tokens.</p><p>Since then, I still use Fable, but only where it&#8217;s worth it. Never hitting my weekly token limit. At least not by surprise. I still have those moments where I am aware that if I press Enter, it will cost me tokens. But sometimes it&#8217;s worth it.</p><p>Anyway, I wanted to share with you 11 context/harness engineering tips that I use in my daily workflows and that work like a charm for me.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Pwe9!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F974dd521-5303-4f87-8903-73775563f70a_1200x626.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Pwe9!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F974dd521-5303-4f87-8903-73775563f70a_1200x626.png 424w, https://substackcdn.com/image/fetch/$s_!Pwe9!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F974dd521-5303-4f87-8903-73775563f70a_1200x626.png 848w, https://substackcdn.com/image/fetch/$s_!Pwe9!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F974dd521-5303-4f87-8903-73775563f70a_1200x626.png 1272w, https://substackcdn.com/image/fetch/$s_!Pwe9!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F974dd521-5303-4f87-8903-73775563f70a_1200x626.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Pwe9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F974dd521-5303-4f87-8903-73775563f70a_1200x626.png" width="1200" height="626" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/974dd521-5303-4f87-8903-73775563f70a_1200x626.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:626,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;The 11 tips at a glance.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="The 11 tips at a glance." title="The 11 tips at a glance." srcset="https://substackcdn.com/image/fetch/$s_!Pwe9!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F974dd521-5303-4f87-8903-73775563f70a_1200x626.png 424w, https://substackcdn.com/image/fetch/$s_!Pwe9!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F974dd521-5303-4f87-8903-73775563f70a_1200x626.png 848w, https://substackcdn.com/image/fetch/$s_!Pwe9!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F974dd521-5303-4f87-8903-73775563f70a_1200x626.png 1272w, https://substackcdn.com/image/fetch/$s_!Pwe9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F974dd521-5303-4f87-8903-73775563f70a_1200x626.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><h2>1. Progressive disclosure is the foundation everything else sits on</h2><p>I use references in my <code>AGENTS.md</code> files, LLM wikis, and Obsidian to build hierarchies, so the model walks a table of contents and pulls a file only when something resolves to it. Anthropic frames it as a finite <a href="https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents">attention budget</a>: every token you add competes with every other one.</p><p>OpenAI rebuilt its <code>AGENTS.md</code> into a roughly 100-line table of contents pointing into a linted docs tree, and shipped about a million lines of Codex-written code that way. Quote: <em><a href="https://openai.com/index/harness-engineering-leveraging-codex-in-an-agent-first-world/">&#8220;give Codex a map, not a 1,000-page instruction manual&#8221;</a>.</em></p><h2>2. Plan like crazy, then let a cheaper model execute</h2><p>Token-wise, planning is cheaper than executing. I use the most powerful model available (currently Fable) to produce a plan, then hand it to a cheaper one. I never say &#8220;implement X&#8221;. Instead, I build an extremely detailed plan going through the system design, architecture, components, interfaces and data flow. When a smaller model executes that, it&#8217;s hard to make a mistake.</p><p>I work the plan through 4 dimensions (known knowns, known unknowns, unknown knowns, unknown unknowns) and let the model grill me with questions to surface blind spots.</p><h2>3. For greenfield work, an LLM wiki is the context you point at</h2><p>A wiki lets a plan reference 30 documents without loading 30 documents. When I start working on a new project, I always build one first: a light context layer built via files instead of a database. The plan cites the index that describes the documents, not the corpus, so it stays grounded at near-zero cost. I wrote a <a href="https://www.decodingai.com/p/llm-wiki-agent-memory">full piece</a> on this.</p><h2>4. Send a cheap subagent to read the whole thing</h2><p>The subagent pays the reading cost. You only receive the summary. When I&#8217;m parsing data, I spin up Haiku or Sonnet subagents that hand back only an executive summary to Opus or Fable. A subagent can <a href="https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents">burn tens of thousands of tokens</a> and return a distilled 1,000-2,000. I clustered my entire Decoding AI archive this way and my main agent&#8217;s context barely grew.</p><h2>5. An ADR and a glossary per feature</h2><p>For every new feature my planning step outputs a task list, an architecture decision record (ADR), and a glossary update. The ADR caches the why behind each decision; the glossary pins down what each term means. Both act as context for later features. OpenAI recommends the same artifact &#8212; <em><a href="https://openai.com/index/harness-engineering-leveraging-codex-in-an-agent-first-world/">&#8220;exec-plans checked into the repo&#8221;</a></em> with progress and decision logs.</p><h2>6. I don&#8217;t graph-index my codebase</h2><p>I don&#8217;t build graphs to index my codebase. The code and the docs drift apart almost immediately, and then you burn tokens keeping an artifact in sync with the thing it describes. That violates clean code principles before it&#8217;s a token problem.</p><p>Note that keeping a glossary and a log of ADRs is different from building a graph out of your code. The glossary and ADRs are orthogonal to the codebase, tracking your domain conventions and design decisions over time. If you change the code, the ADR log doesn&#8217;t need to be changed. It just gets a new entry.</p><p>Worth being precise, because Cursor is a live counterexample: it <a href="https://read.engineerscodex.com/p/how-cursor-indexes-codebases-fast">diffs its embedding index against file hashes every few minutes</a> and re-uploads only what changed. A strategy that adds a lot of complexity. Meanwhile, Claude Code and Codex just parse the codebase at runtime via glob and grep.</p><h2>7. Your modules are already the graph</h2><p>Instead of indexing, I think hard about how to modularize my code, how to shape the interfaces, and how data moves between components. That is your graph, and progressive disclosure parses it really well.</p><p>My sanity check: can I paste this module into another project and have it work?</p><h2>8. Trim the payload you never see</h2><p>Tools like Claude Code become a Swiss army knife that puts a ton of stuff into the system prompt that you never use. They fill it with references to all their features, such as push notifications, remote triggers, scheduling, etc. The logic is simple: for the harness to work with all those features, they need to be mentioned in the system prompt.</p><p>The solution is either to go with a minimalistic approach such as Pi, which ships a bare-bones coding agent you can extend via plugins, or to trim down your Claude Code/Codex harness via a <code>settings.json</code> like this:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!cFex!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb0b2baeb-57ed-43bc-95b9-689611b7a519_2360x2163.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!cFex!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb0b2baeb-57ed-43bc-95b9-689611b7a519_2360x2163.png 424w, https://substackcdn.com/image/fetch/$s_!cFex!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb0b2baeb-57ed-43bc-95b9-689611b7a519_2360x2163.png 848w, https://substackcdn.com/image/fetch/$s_!cFex!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb0b2baeb-57ed-43bc-95b9-689611b7a519_2360x2163.png 1272w, https://substackcdn.com/image/fetch/$s_!cFex!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb0b2baeb-57ed-43bc-95b9-689611b7a519_2360x2163.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!cFex!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb0b2baeb-57ed-43bc-95b9-689611b7a519_2360x2163.png" width="1456" height="1334" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b0b2baeb-57ed-43bc-95b9-689611b7a519_2360x2163.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1334,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;code&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="code" title="code" srcset="https://substackcdn.com/image/fetch/$s_!cFex!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb0b2baeb-57ed-43bc-95b9-689611b7a519_2360x2163.png 424w, https://substackcdn.com/image/fetch/$s_!cFex!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb0b2baeb-57ed-43bc-95b9-689611b7a519_2360x2163.png 848w, https://substackcdn.com/image/fetch/$s_!cFex!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb0b2baeb-57ed-43bc-95b9-689611b7a519_2360x2163.png 1272w, https://substackcdn.com/image/fetch/$s_!cFex!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb0b2baeb-57ed-43bc-95b9-689611b7a519_2360x2163.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption">Inspired by Matt Pocock&#8217;s <a href="https://www.aihero.dev/how-to-kill-the-bloat-in-claude-codes-system-prompt">aihero.dev guide</a></figcaption></figure></div><p>Here is how my context window looks now. Hooked into my content &amp; software factory on a 1M-token window, my payload is 21.4k tokens: 4.3k system prompt, 11.6k system tools, 2.7k across 17 skills, and 46 MCP tools costing literally zero because they load on demand.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!X3z4!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3402bf29-a721-4cda-9880-bebe63e085af_493x490.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!X3z4!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3402bf29-a721-4cda-9880-bebe63e085af_493x490.png 424w, https://substackcdn.com/image/fetch/$s_!X3z4!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3402bf29-a721-4cda-9880-bebe63e085af_493x490.png 848w, https://substackcdn.com/image/fetch/$s_!X3z4!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3402bf29-a721-4cda-9880-bebe63e085af_493x490.png 1272w, https://substackcdn.com/image/fetch/$s_!X3z4!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3402bf29-a721-4cda-9880-bebe63e085af_493x490.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!X3z4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3402bf29-a721-4cda-9880-bebe63e085af_493x490.png" width="493" height="490" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3402bf29-a721-4cda-9880-bebe63e085af_493x490.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:490,&quot;width&quot;:493,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;My /context breakdown after trimming &#8212; 21.4k tokens of standing payload, 46 MCP tools at 0 tokens.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="My /context breakdown after trimming &#8212; 21.4k tokens of standing payload, 46 MCP tools at 0 tokens." title="My /context breakdown after trimming &#8212; 21.4k tokens of standing payload, 46 MCP tools at 0 tokens." srcset="https://substackcdn.com/image/fetch/$s_!X3z4!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3402bf29-a721-4cda-9880-bebe63e085af_493x490.png 424w, https://substackcdn.com/image/fetch/$s_!X3z4!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3402bf29-a721-4cda-9880-bebe63e085af_493x490.png 848w, https://substackcdn.com/image/fetch/$s_!X3z4!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3402bf29-a721-4cda-9880-bebe63e085af_493x490.png 1272w, https://substackcdn.com/image/fetch/$s_!X3z4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3402bf29-a721-4cda-9880-bebe63e085af_493x490.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><h2>9. Turn auto-memory off &#8212; under one condition</h2><p>Auto-memory files, like <code>MEMORY.md</code>, reload into the system prompt every session.</p><p>I set Claude Code&#8217;s auto-memory to false.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!HODb!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba175013-89f9-434c-ab1e-02613800a8dc_684x251.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!HODb!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba175013-89f9-434c-ab1e-02613800a8dc_684x251.png 424w, https://substackcdn.com/image/fetch/$s_!HODb!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba175013-89f9-434c-ab1e-02613800a8dc_684x251.png 848w, https://substackcdn.com/image/fetch/$s_!HODb!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba175013-89f9-434c-ab1e-02613800a8dc_684x251.png 1272w, https://substackcdn.com/image/fetch/$s_!HODb!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba175013-89f9-434c-ab1e-02613800a8dc_684x251.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!HODb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba175013-89f9-434c-ab1e-02613800a8dc_684x251.png" width="684" height="251" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ba175013-89f9-434c-ab1e-02613800a8dc_684x251.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:251,&quot;width&quot;:684,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Auto-memory switched off in Claude Code's memory panel.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Auto-memory switched off in Claude Code's memory panel." title="Auto-memory switched off in Claude Code's memory panel." srcset="https://substackcdn.com/image/fetch/$s_!HODb!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba175013-89f9-434c-ab1e-02613800a8dc_684x251.png 424w, https://substackcdn.com/image/fetch/$s_!HODb!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba175013-89f9-434c-ab1e-02613800a8dc_684x251.png 848w, https://substackcdn.com/image/fetch/$s_!HODb!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba175013-89f9-434c-ab1e-02613800a8dc_684x251.png 1272w, https://substackcdn.com/image/fetch/$s_!HODb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba175013-89f9-434c-ab1e-02613800a8dc_684x251.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>Turning memory off is correct when your continuity already comes from committed artifacts you control (<code>AGENTS.md</code>, ADRs, glossaries, LLM wikis).</p><h2>10. The Caveman plugin</h2><p>I also use the Caveman plugin to cut token usage. LLMs tend to be overly verbose. This plugin transforms the messages from full sentences into &#8220;caveman talk.&#8221;</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!8Xec!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21063347-30a0-436a-92ba-afb5eeb716c5_1750x1276.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!8Xec!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21063347-30a0-436a-92ba-afb5eeb716c5_1750x1276.png 424w, https://substackcdn.com/image/fetch/$s_!8Xec!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21063347-30a0-436a-92ba-afb5eeb716c5_1750x1276.png 848w, https://substackcdn.com/image/fetch/$s_!8Xec!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21063347-30a0-436a-92ba-afb5eeb716c5_1750x1276.png 1272w, https://substackcdn.com/image/fetch/$s_!8Xec!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21063347-30a0-436a-92ba-afb5eeb716c5_1750x1276.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!8Xec!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21063347-30a0-436a-92ba-afb5eeb716c5_1750x1276.png" width="1456" height="1062" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/21063347-30a0-436a-92ba-afb5eeb716c5_1750x1276.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1062,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Caveman plugin in action.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Caveman plugin in action." title="Caveman plugin in action." srcset="https://substackcdn.com/image/fetch/$s_!8Xec!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21063347-30a0-436a-92ba-afb5eeb716c5_1750x1276.png 424w, https://substackcdn.com/image/fetch/$s_!8Xec!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21063347-30a0-436a-92ba-afb5eeb716c5_1750x1276.png 848w, https://substackcdn.com/image/fetch/$s_!8Xec!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21063347-30a0-436a-92ba-afb5eeb716c5_1750x1276.png 1272w, https://substackcdn.com/image/fetch/$s_!8Xec!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21063347-30a0-436a-92ba-afb5eeb716c5_1750x1276.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Caveman plugin in action. Screenshot from their <a href="https://github.com/juliusbrussee/caveman">GitHub repository</a>.</em></figcaption></figure></div><h2>11. The principles that keep every AGENTS.md small</h2><p>Again, to keep the LLM from being overly verbose and to make it support each instruction with examples, I keep these 3 rules in every <code>AGENTS.md</code> file:</p><blockquote><ul><li><p>Always prefer removing instructions over adding more.</p></li><li><p>Always use minimum words that still achieve goal &#8212; explanations, docs, code.</p></li><li><p>New rule in memory (such as AGENTS.md), resources, skills or other files &#8594; always support with clear, concise explanation + good and bad examples. Good examples: &#8220;a 200-token chunk size&#8221;, &#8220;sub-100ms latency&#8221;. Bad examples: &#8220;a powerful architecture&#8221;, &#8220;a robust pipeline&#8221;.</p></li></ul></blockquote><p><em>But here is what I&#8217;m wondering:</em></p><blockquote><p><em><strong>What technique are you using that is not on this list?</strong></em></p></blockquote><p><em>Click the button below and tell me. I read every response.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://www.decodingai.com/p/11-context-engineering-tips-cut-coding-agent-tokens/comments&quot;,&quot;text&quot;:&quot;Leave a comment&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://www.decodingai.com/p/11-context-engineering-tips-cut-coding-agent-tokens/comments"><span>Leave a comment</span></a></p><div><hr></div><p><em>Enjoyed the article? The most sincere compliment is to restack this for your readers.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://www.decodingai.com/p/11-context-engineering-tips-cut-coding-agent-tokens?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;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://www.decodingai.com/p/11-context-engineering-tips-cut-coding-agent-tokens?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p><div><hr></div><div class="callout-block" data-callout="true"><h4>Whenever you&#8217;re ready, here is how I can help you</h4><p><em>Go from agent user to agent builder.</em> Master the foundations of AI agents and turn fragile demo code into reliable, production-ready systems with my course, <strong><a href="https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering">Agent Engineering: Building Multi-Agent Systems</a></strong> (made with Towards AI).</p><p>35 lessons. Pure foundations from scratch. 4 mini-projects. 2 production systems. A certificate and direct access to me &amp; industry experts in our Discord.</p><p>Built for software and data professionals transitioning into AI engineering. <em>Rated 5/5 with 300+ students. The first 7 lessons are free:</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering&quot;,&quot;text&quot;:&quot;Start here&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering"><span>Start here</span></a></p><p><em>Not ready to commit?</em> Start with our <strong><a href="https://email-course.towardsai.net/?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering">free Agent AI Engineering Guide</a></strong>, a 6-day email course on the mistakes that silently break AI agents in production.</p></div><div><hr></div><h2>Images</h2><p>If not otherwise stated, all images are created by the author.</p>]]></content:encoded></item><item><title><![CDATA[The Bare-Bones Coding Agent Loop]]></title><description><![CDATA[One agent loop, 9 tools, and a terminal you can steer.]]></description><link>https://www.decodingai.com/p/the-coding-agent-loop</link><guid isPermaLink="false">https://www.decodingai.com/p/the-coding-agent-loop</guid><dc:creator><![CDATA[Paul Iusztin]]></dc:creator><pubDate>Tue, 28 Jul 2026 13:54:35 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!jhJo!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72c58efe-e07c-42af-9fbe-e8a231384e46_1376x768.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="callout-block" data-callout="true"><p>In LangChain&#8217;s Terminal-Bench experiment, changing only the harness (with the same model) moved a coding agent from ~30th place into the top 5: the harness, not the model, is what makes a coding agent good.</p><p>In the&nbsp;<strong>open-source course</strong>&nbsp;<strong><a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course">Building a Coding Agent From Scratch</a></strong>, you&#8217;ll build that harness from scratch in Python:&nbsp;<strong>Decode</strong>, a complete coding agent that grows lesson by lesson from a bare agent loop into a swarm of remote agents running in parallel in the cloud.</p><p><strong>Why?</strong>&nbsp;You&#8217;ll be able to engineer custom harnesses for your own AI products (the skill behind that leaderboard jump), and you&#8217;ll understand what Claude Code and Codex actually do under the hood, turning you into a power user.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ge05!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ge05!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 424w, https://substackcdn.com/image/fetch/$s_!ge05!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 848w, https://substackcdn.com/image/fetch/$s_!ge05!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 1272w, https://substackcdn.com/image/fetch/$s_!ge05!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ge05!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif" width="1200" height="630" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:630,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1446989,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/gif&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://www.decodingai.com/i/207400663?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ge05!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 424w, https://substackcdn.com/image/fetch/$s_!ge05!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 848w, https://substackcdn.com/image/fetch/$s_!ge05!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 1272w, https://substackcdn.com/image/fetch/$s_!ge05!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27ba7d81-6547-41ad-9370-e9df2dd960e1_1200x630.gif 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><strong>Lessons:</strong></p><ol><li><p><a href="https://www.decodingai.com/p/building-a-coding-agent-from-scratch-system-design">Building a Coding Agent From Scratch</a><strong> </strong></p></li><li><p><strong>The Bare-Bones Coding Agent Loop</strong> <strong>&#8592; </strong><em><strong>you are here</strong></em></p></li><li><p><a href="https://www.decodingai.com/p/run-coding-agents-safely">From a Raw Shell to a Sandboxed Coding Agent</a></p></li><li><p><a href="https://www.decodingai.com/p/context-engineering-for-coding-agents">Context Engineering for Coding Agents</a></p></li><li><p><a href="https://www.decodingai.com/p/subagents-are-context-engineering">Subagents Are Context Engineering</a></p></li><li><p><a href="https://www.decodingai.com/p/coding-agents-in-remote-headless">Swarm of Remote Agents</a></p></li><li><p><a href="https://www.decodingai.com/p/evaluate-ai-agents-benchmarks-regression-tests">Agent Evals 101</a></p></li><li><p><a href="https://www.decodingai.com/p/transform-agent-traces-into-regression-cases">Turn Your Agent&#8217;s Failures Into a Regression Suite</a></p></li></ol><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course&quot;,&quot;text&quot;:&quot;Full open-source course&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course"><span>Full open-source course</span></a></p><p><em>Special thanks to <strong><a href="https://modal.com/?source=decodingai&amp;campaign=harnesseng">Modal</a></strong>, <strong><a href="https://www.comet.com/site/?utm_source=workshop&amp;utm_medium=partner&amp;utm_campaign=paul&amp;utm_content=coding_agent_course">Opik (by Comet)</a></strong>, and <strong><a href="https://www.zenml.io/product/kitaru?utm_source=decodingai&amp;utm_medium=referral&amp;utm_campaign=coding-agent-course&amp;utm_content=brand">Kitaru (by ZenML)</a></strong> for sponsoring this open-source course and keeping it free!</em></p></div><h1>Lesson 2: The Bare-Bones Coding Agent Loop</h1><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!jhJo!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72c58efe-e07c-42af-9fbe-e8a231384e46_1376x768.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!jhJo!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72c58efe-e07c-42af-9fbe-e8a231384e46_1376x768.png 424w, https://substackcdn.com/image/fetch/$s_!jhJo!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72c58efe-e07c-42af-9fbe-e8a231384e46_1376x768.png 848w, https://substackcdn.com/image/fetch/$s_!jhJo!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72c58efe-e07c-42af-9fbe-e8a231384e46_1376x768.png 1272w, https://substackcdn.com/image/fetch/$s_!jhJo!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72c58efe-e07c-42af-9fbe-e8a231384e46_1376x768.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!jhJo!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72c58efe-e07c-42af-9fbe-e8a231384e46_1376x768.png" width="1376" height="768" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/72c58efe-e07c-42af-9fbe-e8a231384e46_1376x768.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:768,&quot;width&quot;:1376,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;The loop runs on its own. The whole trick is staying able to steer it.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="The loop runs on its own. The whole trick is staying able to steer it." title="The loop runs on its own. The whole trick is staying able to steer it." srcset="https://substackcdn.com/image/fetch/$s_!jhJo!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72c58efe-e07c-42af-9fbe-e8a231384e46_1376x768.png 424w, https://substackcdn.com/image/fetch/$s_!jhJo!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72c58efe-e07c-42af-9fbe-e8a231384e46_1376x768.png 848w, https://substackcdn.com/image/fetch/$s_!jhJo!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72c58efe-e07c-42af-9fbe-e8a231384e46_1376x768.png 1272w, https://substackcdn.com/image/fetch/$s_!jhJo!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72c58efe-e07c-42af-9fbe-e8a231384e46_1376x768.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>When I first tried to implement the code for this course I got greedy. I tried to one-shot the harness in Python: a TUI, an agent, and a handful of tools like bash, read, write, and edit. It worked, until I started adding skills, memory, and compaction. That&#8217;s when everything started to fall apart. No &#8220;fix this &#8220; prompt could have saved it. That&#8217;s when I realized that building a harness for a coding agent is a lot more strategic than just: <em>&#8220;Hey, look at OpenCode&#8217;s open-source code and build a replica for me.&#8221;</em></p><p>So, I took a step back, deleted everything and started researching how Claude Code, OpenCode, Aider and Pi work. Only after I pinned down the whole architecture, with its components, interfaces and data flow I started to build Decode. The coding agent I will teach you how to build in this series.</p><p>In this article, lesson 2 from the <strong>open-source course Building a Coding Agent From Scratch</strong>, we will learn <strong>how to build a bare-bones coding agent from scratch</strong>. At feature parity with the popular <a href="https://github.com/earendil-works/pi">Pi</a> agent harness.</p><p>We will build the coding agent loop. See how the loop decomposes a goal into a plan and executes it. Understand which tools are critical for a coding agent, and which ones are nice to have. Build a TUI. See why naively sending messages from the terminal to the agent can corrupt the loop. For the full architecture of <code>Decode</code>, what we will build throughout this series, we recommend reading <a href="https://www.decodingai.com/p/building-a-coding-agent-from-scratch-system-design">Lesson 1</a>.</p><p>On top of that, we will plug in 3 LLM providers (Modal, OpenRouter, and Gemini) and understand when serverless computing such as <a href="https://modal.com/?source=decodingai&amp;campaign=harnesseng">Modal</a> beats token-based APIs. Also, to easily debug the agent, we will integrate trace monitoring via <a href="https://www.comet.com/site/?utm_source=workshop&amp;utm_medium=partner&amp;utm_campaign=paul&amp;utm_content=coding_agent_course">Opik</a>.</p><p><em>Example of running Decode (our coding agent) powered by Qwen 3.6 35B:</em></p><div class="native-video-embed" data-component-name="VideoPlaceholder" data-attrs="{&quot;mediaUploadId&quot;:&quot;0042fe85-84be-40a0-ae28-397aa76ee582&quot;,&quot;duration&quot;:null}"></div><p>Let&#8217;s start with an end-to-end walkthrough of the coding agent harness.</p><h2>One Turn, End to End</h2><p>Our expectations from Decode&#8217;s coding agent loop are similar to any other coding agent you&#8217;re already used to: Claude Code, Codex, Pi, OpenCode, etc. You open it in a repository or any other folder, give it a goal, and let it loop until it completes the goal.</p><p>In our <code>.decode/skills/demo-6-article-kg</code> demo, managed as a skill, we ask Decode to pull data from multiple sources, extract key entities and concepts and render a KG in HTML.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!WjR5!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c7cbb63-1eb0-41f3-8479-ea984adb9f4a_1816x855.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!WjR5!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c7cbb63-1eb0-41f3-8479-ea984adb9f4a_1816x855.png 424w, https://substackcdn.com/image/fetch/$s_!WjR5!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c7cbb63-1eb0-41f3-8479-ea984adb9f4a_1816x855.png 848w, https://substackcdn.com/image/fetch/$s_!WjR5!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c7cbb63-1eb0-41f3-8479-ea984adb9f4a_1816x855.png 1272w, https://substackcdn.com/image/fetch/$s_!WjR5!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c7cbb63-1eb0-41f3-8479-ea984adb9f4a_1816x855.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!WjR5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c7cbb63-1eb0-41f3-8479-ea984adb9f4a_1816x855.png" width="1456" height="686" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5c7cbb63-1eb0-41f3-8479-ea984adb9f4a_1816x855.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:686,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;TUI&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="TUI" title="TUI" srcset="https://substackcdn.com/image/fetch/$s_!WjR5!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c7cbb63-1eb0-41f3-8479-ea984adb9f4a_1816x855.png 424w, https://substackcdn.com/image/fetch/$s_!WjR5!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c7cbb63-1eb0-41f3-8479-ea984adb9f4a_1816x855.png 848w, https://substackcdn.com/image/fetch/$s_!WjR5!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c7cbb63-1eb0-41f3-8479-ea984adb9f4a_1816x855.png 1272w, https://substackcdn.com/image/fetch/$s_!WjR5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c7cbb63-1eb0-41f3-8479-ea984adb9f4a_1816x855.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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 agent kept looping until we got the graph below. Pretty cool, right?</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!N80t!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F164c2b96-6e40-42f2-bd83-9f546e9195fc_3324x1934.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!N80t!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F164c2b96-6e40-42f2-bd83-9f546e9195fc_3324x1934.png 424w, https://substackcdn.com/image/fetch/$s_!N80t!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F164c2b96-6e40-42f2-bd83-9f546e9195fc_3324x1934.png 848w, https://substackcdn.com/image/fetch/$s_!N80t!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F164c2b96-6e40-42f2-bd83-9f546e9195fc_3324x1934.png 1272w, https://substackcdn.com/image/fetch/$s_!N80t!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F164c2b96-6e40-42f2-bd83-9f546e9195fc_3324x1934.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!N80t!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F164c2b96-6e40-42f2-bd83-9f546e9195fc_3324x1934.png" width="1456" height="847" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/164c2b96-6e40-42f2-bd83-9f546e9195fc_3324x1934.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:847,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;The knowledge graph Decode built from three live articles, rendered as one HTML page.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="The knowledge graph Decode built from three live articles, rendered as one HTML page." title="The knowledge graph Decode built from three live articles, rendered as one HTML page." srcset="https://substackcdn.com/image/fetch/$s_!N80t!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F164c2b96-6e40-42f2-bd83-9f546e9195fc_3324x1934.png 424w, https://substackcdn.com/image/fetch/$s_!N80t!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F164c2b96-6e40-42f2-bd83-9f546e9195fc_3324x1934.png 848w, https://substackcdn.com/image/fetch/$s_!N80t!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F164c2b96-6e40-42f2-bd83-9f546e9195fc_3324x1934.png 1272w, https://substackcdn.com/image/fetch/$s_!N80t!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F164c2b96-6e40-42f2-bd83-9f546e9195fc_3324x1934.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>This is a great example where the agent had to break a goal into multiple steps and execute each one independently until the goal is reached.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!OA6z!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1428edd7-7b87-45c8-9d55-149a682ab5c2_1200x686.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!OA6z!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1428edd7-7b87-45c8-9d55-149a682ab5c2_1200x686.png 424w, https://substackcdn.com/image/fetch/$s_!OA6z!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1428edd7-7b87-45c8-9d55-149a682ab5c2_1200x686.png 848w, https://substackcdn.com/image/fetch/$s_!OA6z!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1428edd7-7b87-45c8-9d55-149a682ab5c2_1200x686.png 1272w, https://substackcdn.com/image/fetch/$s_!OA6z!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1428edd7-7b87-45c8-9d55-149a682ab5c2_1200x686.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!OA6z!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1428edd7-7b87-45c8-9d55-149a682ab5c2_1200x686.png" width="1200" height="686" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1428edd7-7b87-45c8-9d55-149a682ab5c2_1200x686.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:686,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;The interactive mode: one turn's machinery, end to end.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="The interactive mode: one turn's machinery, end to end." title="The interactive mode: one turn's machinery, end to end." srcset="https://substackcdn.com/image/fetch/$s_!OA6z!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1428edd7-7b87-45c8-9d55-149a682ab5c2_1200x686.png 424w, https://substackcdn.com/image/fetch/$s_!OA6z!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1428edd7-7b87-45c8-9d55-149a682ab5c2_1200x686.png 848w, https://substackcdn.com/image/fetch/$s_!OA6z!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1428edd7-7b87-45c8-9d55-149a682ab5c2_1200x686.png 1272w, https://substackcdn.com/image/fetch/$s_!OA6z!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1428edd7-7b87-45c8-9d55-149a682ab5c2_1200x686.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>The interactive mode</em></figcaption></figure></div><p>More concretely, this is the agent&#8217;s whole lifecycle: <strong>plan &#8594; explore &#8594; apply &#8594; execute &#8594; observe &#8594; next task</strong>, repeated until the goal is met.</p><p>Everything starts with you typing your goal into the TUI and pressing Enter. The request goes into the steering queue and then into a fresh turn, and the loop sends the prompt and tools to the model, a Qwen3.6 served on Modal. It kicks off planning. Via <code>todo_write</code> it records 4 tasks (fetch &#8594; extract &#8594; render &#8594; verify). Via <code>web_fetch</code> Decode fans out in one step and scrapes all the sources. The model reads the scraped output and extracts the KG triplets into a <code>graph.json</code> file via its <code>write</code> tool &#8212; the first call that can change your disk, so the run stops and asks. You type <code>y</code>. Ultimately it generates the HTML code that loads the data from the JSON files and beautifully renders it by calling the <code>write</code> tool to create the <code>kg.html</code> file. Finally, it calls <code>todo_write</code> to update the TODO list and mark the goal as done.</p><p>Based on our <a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course">open-source GitHub</a>, here are all the components of the agent loop that transform a simple Pydantic AI agent into the foundations of any coding agent you are using out there:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;plaintext&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-plaintext">src/decode/
&#9500;&#9472;&#9472; agent/          # loop.py (the agent loop), factory.py
&#9500;&#9472;&#9472; harness/        # runner.py (single-flight turns), queue.py (steering/follow-up)
&#9500;&#9472;&#9472; tools/          # registry.py, files.py (read/write/edit/glob/grep), bash.py, askuser.py
&#9500;&#9472;&#9472; context/        # session_log.py (append-only JSONL)
&#9500;&#9472;&#9472; observability/  # tracing.py (Opik via OTLP)
&#9492;&#9472;&#9472; tui/            # app.py (prompt_toolkit input), render.py (Rich output)</code></pre></div><p>In this course, we will mostly follow Claude Code/OpenCode&#8217;s design, where we have a larger set of tools, memory and agent features built into the harness. Mostly for educational reasons, to explore all the options out there. But there is also a beautiful, minimalist approach to this, based on the philosophy of Mario Zechner, creator of the Pi harness: strip the agent loop back to its bare bones, keeping only the essential logic, to avoid adding noise into the context window and keep everything observable and in control. If you want more features, you add them explicitly as plugins, instead of getting new &#8220;space ship&#8221; cool-but-useless features with every version. Thus, to understand both perspectives, we will keep drawing parallels to Pi&#8217;s architecture.</p><h2>The Agent Loop</h2><p>In Lesson 1, we said that the agent loop is <em>the good old ReAct pattern</em>. The model reasons, picks a tool, the harness executes it, and the observation feeds the next step &#8212; an agent is just <a href="https://www.anthropic.com/research/building-effective-agents">an LLM using tools on environmental feedback in a loop</a>.</p><p>ReAct in the abstract is reason &#8594; act &#8594; observe. Give it a set of tools it can operate on a codebase and voil&#224;, it becomes a coding agent.</p><p><strong>Plan</strong>: <code>todo_write</code> the task list before touching anything.<br><strong>Explore</strong>: <code>read</code>, <code>glob</code>, <code>grep</code> the codebase.<br><strong>Apply</strong>: <code>write</code> and <code>edit</code>, stopping for your verdict.<br><strong>Execute</strong>: <code>bash</code> the tests, the linter.<br><strong>Observe</strong>: a failure is the next observation, and the repair is another Apply &#8594; Execute pass on the same task. Tick it off, re-enter.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!KVlk!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92b11633-a282-4fec-9129-e573664754a4_1200x1200.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!KVlk!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92b11633-a282-4fec-9129-e573664754a4_1200x1200.png 424w, https://substackcdn.com/image/fetch/$s_!KVlk!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92b11633-a282-4fec-9129-e573664754a4_1200x1200.png 848w, https://substackcdn.com/image/fetch/$s_!KVlk!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92b11633-a282-4fec-9129-e573664754a4_1200x1200.png 1272w, https://substackcdn.com/image/fetch/$s_!KVlk!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92b11633-a282-4fec-9129-e573664754a4_1200x1200.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!KVlk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92b11633-a282-4fec-9129-e573664754a4_1200x1200.png" width="1200" height="1200" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/92b11633-a282-4fec-9129-e573664754a4_1200x1200.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1200,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;The coding agent loop: one goal, one repeating cycle, until the goal is achieved.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="The coding agent loop: one goal, one repeating cycle, until the goal is achieved." title="The coding agent loop: one goal, one repeating cycle, until the goal is achieved." srcset="https://substackcdn.com/image/fetch/$s_!KVlk!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92b11633-a282-4fec-9129-e573664754a4_1200x1200.png 424w, https://substackcdn.com/image/fetch/$s_!KVlk!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92b11633-a282-4fec-9129-e573664754a4_1200x1200.png 848w, https://substackcdn.com/image/fetch/$s_!KVlk!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92b11633-a282-4fec-9129-e573664754a4_1200x1200.png 1272w, https://substackcdn.com/image/fetch/$s_!KVlk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92b11633-a282-4fec-9129-e573664754a4_1200x1200.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>In Claude Code&#8217;s leaked source the core loop is ~150 lines. To emphasize the harness around the agent, we will use Pydantic AI for the &#8220;core agent&#8221; and focus on everything around it (from <code>build_agent</code> in <code>src/decode/agent/factory.py</code>):</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">def build_agent(*, model: str | None = None) -&gt; Agent[AgentDeps, str | DeferredToolRequests]:
    built_model = _build_model(model=model)
    agent = Agent(
        built_model,
        deps_type=AgentDeps,                       # cwd, task store, event emitter &#8212; the harness state
        output_type=[str, DeferredToolRequests],   # a step ends in text &#8212; or pauses on approvals
        output_retries=3,                          # empty / thinking-only turns get another attempt
        tool_retries=5,                            # only resets on success &#8212; the plan-survival budget
    )
    register_tools(agent)                          # the coding tool set
    _register_instructions(agent)                  # ONE merged system prompt

    return agent</code></pre></div><p>The <code>Agent</code> owns one step: one model request, the tool executions it triggers as &#8220;actions&#8221;, and the results it gets back as &#8220;observations&#8221;, ending in either text or <code>DeferredToolRequests</code>. <strong>The agent loop</strong> is operated by the <code>AgentTurnHandler</code> (<code>src/decode/agent/loop.py</code>) class chaining steps together through <code>agent.iter</code>.</p><p><code>AgentTurnHandler.__call__</code> is an async generator that streams tokens in real time via Python generators. It runs a <code>while True</code> loop with two boundaries: <code>yield Boundary.MODEL_REQUEST</code> and <code>yield Boundary.WOULD_STOP</code>. Via <code>Boundary.MODEL_REQUEST</code>, we can inject (steer) new messages into the loop before it finishes reaching its goals.</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">class AgentTurnHandler:

    ...                 # ONE instance per session; owns the turn + history

    async def __call__(self, ctx: TurnContext) -&gt; AsyncGenerator[Boundary, list[str]]:
        while True:
            steering = yield Boundary.MODEL_REQUEST
            if pending_results is not None:
                self._append_steering(steering)
                output = await self._run_turn(ctx, deferred_results=pending_results)
                pending_results = None
            else:
                output = await self._run_turn(
                    ctx, prompt=self._compose_prompt(next_prompt, steering)
                )
            if isinstance(output, DeferredToolRequests):
                pending_results = await self._resolve_deferred(ctx, output)
                continue
            self._persist_turn()
            follow_ups = yield Boundary.WOULD_STOP
            if not follow_ups: return
            next_prompt = "\n".join(follow_ups)</code></pre></div><p>The whole action happens inside the <code>self._run_turn</code> method, which makes the actual model call, and based on the results from the model, via the <code>run</code> object, it either emits answers from the model or executes a tool request.</p><p>In more detail, this is what happens:</p><ol><li><p>A fresh step passes <code>prompt</code>, a resumed step passes <code>deferred_tool_results</code>, never both.</p></li><li><p>The <code>async for</code> streams each node to the TUI as an event, so you watch tokens arrive live.</p></li><li><p>The <code>finally</code> carries <code>run.all_messages()</code> forward, so a step that dies keeps everything it accomplished in memory.</p></li></ol><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">class AgentTurnHandler:

    ...                         # ...same class as above

    async def _run_turn(self, ctx, *, prompt=None, deferred_results=None) -&gt; str | DeferredToolRequests:
        async with self._agent.iter(
            prompt,
            deps=self._deps,
            message_history=self.message_history,
            deferred_tool_results=deferred_results,
        ) as run:
            try:
                async for node in run:
                    if Agent.is_model_request_node(node):
                        await self._stream_model_node(ctx, node, run)
                    elif Agent.is_call_tools_node(node):
                        await self._stream_tool_node(ctx, node, run)
            finally:
                self.message_history = run.all_messages()
                self._last_input_tokens = _leg_input_tokens(self.message_history)
        return run.result.output</code></pre></div><blockquote><p>&#128161; The loop has no max-steps knob, based on Pi&#8217;s principles: <em>&#8220;the loop just loops until the agent says it&#8217;s done.&#8221;</em> A cap is a guess about how many steps a task needs, and the model already signals completion by returning text instead of a tool call. The signal you should be careful about is the context window.</p></blockquote><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!qpse!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca03aacb-f307-4302-b341-d40d28b90b6c_1200x725.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!qpse!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca03aacb-f307-4302-b341-d40d28b90b6c_1200x725.png 424w, https://substackcdn.com/image/fetch/$s_!qpse!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca03aacb-f307-4302-b341-d40d28b90b6c_1200x725.png 848w, https://substackcdn.com/image/fetch/$s_!qpse!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca03aacb-f307-4302-b341-d40d28b90b6c_1200x725.png 1272w, https://substackcdn.com/image/fetch/$s_!qpse!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca03aacb-f307-4302-b341-d40d28b90b6c_1200x725.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!qpse!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca03aacb-f307-4302-b341-d40d28b90b6c_1200x725.png" width="1200" height="725" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ca03aacb-f307-4302-b341-d40d28b90b6c_1200x725.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:725,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;One turn's lifecycle: steps, pauses, and the two boundaries.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="One turn's lifecycle: steps, pauses, and the two boundaries." title="One turn's lifecycle: steps, pauses, and the two boundaries." srcset="https://substackcdn.com/image/fetch/$s_!qpse!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca03aacb-f307-4302-b341-d40d28b90b6c_1200x725.png 424w, https://substackcdn.com/image/fetch/$s_!qpse!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca03aacb-f307-4302-b341-d40d28b90b6c_1200x725.png 848w, https://substackcdn.com/image/fetch/$s_!qpse!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca03aacb-f307-4302-b341-d40d28b90b6c_1200x725.png 1272w, https://substackcdn.com/image/fetch/$s_!qpse!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca03aacb-f307-4302-b341-d40d28b90b6c_1200x725.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>A turn as a chain of steps</em></figcaption></figure></div><p>The first thing every step does is call a model, and picking that model should always be a one-line config choice.</p><h2>The LLM Providers</h2><p>It&#8217;s an architectural mistake to couple your design to a single provider. The loop shouldn&#8217;t know whether it talks to Gemini, <a href="https://openrouter.ai/">OpenRouter</a>, <a href="https://modal.com/?source=decodingai&amp;campaign=harnesseng">Modal</a>, or whatever comes next.</p><p>All provider knowledge lives in <code>_build_model()</code> in <code>src/decode/agent/factory.py</code>. You pick the provider by setting the <code>LLM_PROVIDER</code> environment variable, which is picked by your Pydantic settings object from <code>src/decode/config/settings.py</code>.</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">def _build_model(*, model: str | None = None) -&gt; Model:
    provider = settings.llm_provider                     # explicit LLM_PROVIDER env var
    if provider == "gemini":
        return GoogleModel(
            model or settings.gemini_model,
            provider=GoogleProvider(api_key=_provider_api_key("gemini"))
        )
    if provider == "openrouter":
        return OpenAIChatModel(
            model or settings.openrouter_model,
            provider=OpenRouterProvider(api_key=_provider_api_key("openrouter"))
        )
    if provider == "modal":
        client = AsyncOpenAI(
            base_url=f"{settings.modal_endpoint_url}/v1",
            api_key=token_secret,
            default_headers={"Modal-Key": token_id, "Modal-Secret": token_secret}
        )
        return OpenAIChatModel(
            model or settings.modal_endpoint_model,
            provider=OpenAIProvider(openai_client=client)
        )
        
    raise ValueError(f"unsupported llm_provider: {provider!r}")</code></pre></div><p>So from all the options out there (we know there are tons), why these 3? And no OpenAI or Anthropic. Because between them they cover the three tiers of the build vs. buy decision: Gemini is proprietary (you buy the model), OpenRouter is open weights bought as a service (you buy the serving), and Modal is open weights you serve yourself.</p><p>We choose <strong><a href="https://modal.com/?source=decodingai&amp;campaign=harnesseng">Modal</a></strong> as our default option for 3 reasons. <strong>You pay for GPU compute, not tokens</strong>: agentic bursts fit <a href="https://modal.com/blog/how-to-price-serverless?source=decodingai&amp;campaign=harnesseng">GPU-time pricing</a>. Serverless open-source models supported by Modal that we deployed are Qwen3.6 35B, Kimi K3, and GLM-5.2 via <a href="https://modal.com/blog/introducing-auto-endpoints?source=decodingai&amp;campaign=harnesseng">Modal Endpoints</a>. If you want to use a fine-tuned model, you can easily swap it in with 0 changes on the harness side. Because it&#8217;s serverless, it <strong>scales to zero</strong>: you pay only when the agent is working.</p><p>This combination makes it ideal for intermittent periods of extremely high compute demand. For example, if you want to process 1000 documents, instead of paying for each token, which is what&#8217;s typical of all the APIs out there, you just pay for the compute time. To make testing Decode extremely affordable, for most of our tests we used <code>Qwen3.6 35B</code>, which runs on a single <code>H200</code> GPU at <code>$4.54 / h</code>.</p><p>But going back to our 1000 documents example, if these 1000 documents translate to 1000 * 30000 tokens, that's 30M input tokens, plus ~500 output tokens per document. If we wanted to process all these tokens with Sonnet, that would translate to: <code>30M / 1M x 3 (input) + 500k / 1M x 15 (output) ~= $97</code>. And prompt caching doesn't save us here &#8212; every document is a different prefix, so there's nothing to reuse across calls. Considering we could process this data with Modal at ~3000 tokens/second batched, that's under 3 hours of GPU time, which would have cost only ~$13. Modal <a href="https://modal.com/blog/how-to-price-serverless?source=decodingai&amp;campaign=harnesseng">benchmarked the same tradeoff</a> and found that giving up interactivity, from ~200ms to ~4s end-to-end, provided an x8 throughput increase on identical hardware. If we do this multiple times per day, it quickly adds up. This is just napkin math, but you get the idea.</p><p>Now, on the other side of the spectrum, let's assume Decode sits idle while it waits on a &#8220;y&#8221; confirmation the agent asked for. If that happens overnight, you can easily add 10 hours of idle time to your GPU billing, an extra ~$45.</p><p>Alongside the pay-per-token model, which quickly becomes inefficient at high <span>volumes,&nbsp;</span><strong><span>another dimension to</span> consider is serverless vs. reserved GPU time</strong>. When you reserve GPUs, you have to reserve your peak. If your peak needs 40 GPUs on Friday afternoon and 2 on Sunday night, you sign for 40 &#8212; and you keep paying for 40 all weekend, all month, all year. With serverless, the meter follows the demand curve, so the total cost is just the rate <code>R_s</code> times whatever you actually used at each moment. The reservation instead charges you rate <code>R_r</code> times the peak, times the entire length of the contract <code>T</code>.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!2Fua!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9c92b0f8-5161-491d-adf4-59d5a5538f04_1498x578.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!2Fua!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9c92b0f8-5161-491d-adf4-59d5a5538f04_1498x578.png 424w, https://substackcdn.com/image/fetch/$s_!2Fua!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9c92b0f8-5161-491d-adf4-59d5a5538f04_1498x578.png 848w, https://substackcdn.com/image/fetch/$s_!2Fua!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9c92b0f8-5161-491d-adf4-59d5a5538f04_1498x578.png 1272w, https://substackcdn.com/image/fetch/$s_!2Fua!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9c92b0f8-5161-491d-adf4-59d5a5538f04_1498x578.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!2Fua!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9c92b0f8-5161-491d-adf4-59d5a5538f04_1498x578.png" width="1456" height="562" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9c92b0f8-5161-491d-adf4-59d5a5538f04_1498x578.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:562,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Serverless vs. reserved GPU cost&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Serverless vs. reserved GPU cost" title="Serverless vs. reserved GPU cost" srcset="https://substackcdn.com/image/fetch/$s_!2Fua!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9c92b0f8-5161-491d-adf4-59d5a5538f04_1498x578.png 424w, https://substackcdn.com/image/fetch/$s_!2Fua!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9c92b0f8-5161-491d-adf4-59d5a5538f04_1498x578.png 848w, https://substackcdn.com/image/fetch/$s_!2Fua!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9c92b0f8-5161-491d-adf4-59d5a5538f04_1498x578.png 1272w, https://substackcdn.com/image/fetch/$s_!2Fua!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9c92b0f8-5161-491d-adf4-59d5a5538f04_1498x578.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption">Formula to check the costs of serverless vs. reserved infrastructure (<a href="https://modal.com/blog/how-to-price-serverless?source=decodingai&amp;campaign=harnesseng">source</a>)</figcaption></figure></div><p>In other words, if reserving is <code>5x</code> cheaper than serverless, but your peak is <code>5x</code> higher than your average, then you break even. And the further your peak climbs above that price advantage, the better off you are paying for serverless. For the full math, <a href="https://modal.com/blog/how-to-price-serverless?source=decodingai&amp;campaign=harnesseng">see this blog post</a>.</p><p><strong>OpenRouter</strong> is the most popular gateway to every hosted model: closed source (Claude, OpenAI, Gemini) or open-source (Kimi K3, Z GLM-5.2, Gemma 4, etc.) behind one key. Thanks to their huge aggregated pool of models, they also have some free defaults, such as <code>qwen/qwen3-coder:free</code>, which we used in this course. Having them integrated into your app is a powerful way to easily experiment with different models without worrying about the underlying infrastructure.</p><p>We picked <strong>Gemini</strong> mostly due to their generous free tier, to provide you a third option to run Decode without any cost. Their models are rarely the best, but relative to other API-based models, especially OpenAI &amp; Anthropic, they&#8217;re cheap and good enough to get most jobs done.</p><p>We recommend starting with <a href="https://modal.com/blog/introducing-auto-endpoints?source=decodingai&amp;campaign=harnesseng">Modal Endpoints</a>, powered by <code>Qwen3.6 35B</code> by default, that spins up in a couple of minutes a configurable <code>SGLangEndpoint</code>. <code>SGLang</code> is the right default here because it and <code>vLLM</code> land in <a href="https://modal.com/llm-almanac/summary?source=decodingai&amp;campaign=harnesseng">roughly the same place on throughput</a>, but <code>SGLang</code> boots in ~1 minute against vLLM&#8217;s ~5 for small models, which is everything when your endpoint scales to zero. Modal&#8217;s $30 in free credits each month covers ~6.5 hours of <code>H200</code> time, enough to run the whole course at no cost. And while <code>Qwen3.6 35B</code> is small next to GLM-5.2 740B or even GPT OSS 120B, it&#8217;s well tested with Decode and works well enough for our examples.</p><p>After you&#8217;ve completed the basic setup on Modal, you can start a new endpoint just by running:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;bash&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-bash">modal endpoint create --model Qwen/Qwen3.6-35B-A3B-FP8 --env main</code></pre></div><p>While trying it out, to avoid the cold start problem, we recommend setting the autoscaling limits to a minimum of 1 container:</p><div class="native-video-embed" data-component-name="VideoPlaceholder" data-attrs="{&quot;mediaUploadId&quot;:&quot;c4cab325-9438-4644-8a2f-8422259d4991&quot;,&quot;duration&quot;:null}"></div><blockquote><p>&#129489;&#8205;&#128187; Find the full setup docs in our <a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course">GitHub repo</a>.</p></blockquote><p>But between Modal and OpenRouter, you can easily swap between hundreds of models. You can try out whatever you&#8217;re interested in. The only requirement is that it supports tool calling.</p><h2>The System Prompt</h2><p>The entire base system prompt is one paragraph:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;plaintext&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-plaintext">You are Decode, a terminal coding agent that helps a developer in their working
directory. You are concise and precise: answer directly, prefer running the work
over describing it, and never invent file contents or command output you have not
seen. When you do not have a tool for something yet, say so plainly rather than
pretending.</code></pre></div><p>The team behind Pi started this minimalist mentality, where you keep your system prompts, tools, and features to a minimum, to avoid filling your context window with noise that confuses the model more than it helps. This also makes maintaining and understanding the prompts, for us as humans, a lot easier. In the past months, OpenAI and Anthropic followed, trimming their system prompts by up to 70%, as more and more functionality around coding gets baked directly into the model&#8217;s weights.</p><p>Still, this paragraph is only the baseline. Pydantic AI builds a schema from every tool&#8217;s signature, which is added to the system prompt. Thus, each tool comes with a cost, meaning that the more tools you use, the more context window you consume, and the model becomes more confused about which one to pick. This becomes even more problematic when we start adding memory and skills into the mix, as we will see in future lessons.</p><p>Whichever model answers, it can only touch your repo through the tools.</p><h2>The Core Tools</h2><p>In reality, the tools are 90% of why this is a coding agent and not any other kind of AI agent. The agent needs to <a href="https://mitchellh.com/writing/my-ai-adoption-journey">read files, execute programs, make HTTP requests</a>. <a href="https://github.com/earendil-works/pi">Pi</a> ships exactly <code>read</code>, <code>write</code>, <code>edit</code>, and <code>bash</code> &#8212; under 1,000 tokens of prompt plus definitions, <a href="https://mariozechner.at/posts/2025-11-30-pi-coding-agent/">still respectable &#8212; top 10 on Terminal-Bench 2.0</a>.</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;plaintext&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-plaintext">read   path, offset?, limit?   &#8594; file contents; first 2,000 lines by default
write  path, content           &#8594; create or overwrite; makes parent dirs
edit   path, oldText, newText  &#8594; exact-match surgical replace (whitespace included)
bash   command, timeout?       &#8594; run it in the cwd; returns stdout + stderr</code></pre></div><p>On top of these 4 core tools, we have more specialized I/O tools such as <code>glob</code> and <code>grep</code>. Then there&#8217;s <code>todo_write</code>, used to decompose the goal into a plan of TODOs, <code>web_fetch</code> to fetch web pages, and <code>ask_user</code> to interact with the user.</p><blockquote><p>&#128161; Pi doesn&#8217;t have a <code>todo_write</code> tool because it considers that the best way to store your plan is directly in a Markdown file, not in an in-memory TODO list the agent has to keep track of &#8212; <a href="https://mariozechner.at/posts/2025-11-30-pi-coding-agent/">a PLAN.md on disk beats an in-memory list</a>.</p></blockquote><p>Every snippet below opens with <code>ctx: RunContext[AgentDeps]</code>. <code>RunContext</code> is Pydantic AI&#8217;s per-run context object: the framework injects it as every tool&#8217;s first parameter and hides it from the model&#8217;s tool schema. The model calls <code>edit(path, old_string, new_string)</code> and never knows <code>ctx</code> exists.</p><p><code>AgentDeps</code> is in our harness. We declare it once as <code>deps_type=AgentDeps</code> in <code>build_agent</code>, pass it into <code>agent.iter(deps=...)</code>, and Pydantic AI hands it to every tool call. <code>RunContext[AgentDeps]</code> reads as &#8220;this run&#8217;s context, whose <code>.deps</code> is an <code>AgentDeps</code>.&#8221; It is the harness state, arriving by injection (from <code>src/decode/agent/deps.py</code>):</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">@dataclass(slots=True)
class AgentDeps:                                   # every tool's ctx.deps &#8212; the harness, injected
    cwd: Path                                      # the jail: file tools + bash resolve paths here
    emit: EventSink                                # push an event &#8594; the TUI renders it
    gate: PermissionGate                           # the allow / ask / deny policy (Section 6)
    resolve_permission: PermissionResolver         # a gate "ask" &#8594; the human's verdict, awaited
    resolve_user_question: UserQuestionResolver    # ask_user's answer, on the SAME channel
    task_store: list[Task] = field(default_factory=list)      # what todo_write rewrites in place</code></pre></div><p><code>emit</code>, <code>resolve_permission</code>, and <code>resolve_user_question</code> are used for dependency injection, so tools reach the terminal without importing the TUI, and they make this code easily testable by swapping in a different <code>AgentDeps</code>.</p><p>To keep things short and sweet, I will skip how <code>read</code> and <code>write</code> work and go straight to <code>edit</code> (see them at <code>src/decode/tools/files.py</code>). <code>edit</code> is a find-and-replace with one rule: load the file&#8217;s text, find <code>old_string</code> inside it, dump <code>new_string</code> into that exact spot, write the file back. But the devil is in the details. To make this replace work, it first needs to normalize away the invisible formatting the model was never shown &#8212; a file&#8217;s line-ending convention, a leading byte-order mark &#8212; so a match never fails on characters the model had no way to guess. Then it looks for <code>old_string</code>, and only when that misses does it retry with whitespace collapsed on both sides. Either way, the match must be <strong>unique</strong>: 0 hits returns <code>not found</code>, 2+ returns <code>ambiguous, N matches</code>, and both end up with <code>ModelRetry</code>:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">def edit(ctx: RunContext[AgentDeps], path: str, old_string: str, new_string: str) -&gt; str:
    if needs_approval(ctx):
        raise ApprovalRequired
    target = _resolve_in_cwd(ctx.deps.cwd, path)
    raw = target.read_bytes().decode("utf-8")
    final = _apply_edit(raw, old_string, new_string)
    _atomic_write_bytes(target, final.encode())

    return f"Edited {path!r} (replaced 1 occurrence)."</code></pre></div><p>Within <code>todo_write</code>, the model sends the <strong>full</strong> desired list on every call and the tool overwrites the whole list &#8212; which is exactly what stops the plan from drifting out of the context window. The overwrite is in place (<code>[:] = tasks</code>, not a rebind) so the loop and the TUI keep pointing at the same list object, and every item is validated by the <code>Task</code> Pydantic model on the way in. It then emits one <code>TaskListUpdated</code> event carrying pre-rendered checklist lines: the tool maps <code>pending / in_progress / completed</code> to <code>[ ] / [~] / [x]</code> itself, so the renderer never has to learn the status vocabulary. The store is in-memory and per-run &#8212; nothing about the task list outlives the process (from <code>src/decode/tools/tasks.py</code>):</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">def todo_write(ctx: RunContext[AgentDeps], tasks: list[Task]) -&gt; str:
    if needs_approval(ctx):
        raise ApprovalRequired
    ctx.deps.task_store[:] = tasks
    ctx.deps.emit(events.TaskListUpdated(tasks=_checklist_lines(tasks)))

    return f"Updated task list ({len(tasks)} task(s))."</code></pre></div><p>That <code>emit</code> line is the harness&#8217;s entire UI protocol. <code>events</code> is the <code>decode.entities.events</code> module of frozen dataclasses (<code>TurnStarted</code>, <code>ToolCallStarted</code>, <code>ToolResult</code>, <code>TaskListUpdated</code>, ...) joined into one union known by the renderer.</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">Event = (
    TurnStarted
    | TurnFinished
    | AssistantTextDelta
    | ThinkingDelta
    | ToolCallStarted
    | ToolResult
    | PermissionRequested
    | AskUserRequested
    | TaskListUpdated
    | ContextCompacted
    | ContextMicrocompacted
    | AgentError
)</code></pre></div><p><code>ctx.deps.emit</code> is a synchronous event-based sink, injected into the harness to communicate with outer layers, in this case the TUI. This is clean architecture 101. The tool describes what happened as a typed value, and the TUI decides how to draw it.</p><p><code>web_fetch</code> makes an async httpx GET request. What comes back is filtered twice before the model sees it &#8212; non-text content types are refused outright, and the decoded body is hard-capped at 2 MB, so an enormous page can never eat your entire context window. HTML is then mapped to Markdown keeping mostly the body and other metadata such as the title. Every failure path &#8212; non-2xx, timeout, connection error, wrong content type, HTML nested too deep to parse &#8212; throws a <code>ModelRetry</code> error, so a bad fetch is an observation the model has to handle explicitly and not ignore (from <code>src/decode/tools/web.py</code>):</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">async def web_fetch(ctx: RunContext[AgentDeps], url: str) -&gt; str:
    if needs_approval(ctx):
        raise ApprovalRequired
    _validate_url(url)
    response = await _get(url)
    body = _render_body(response, _decode_body(response))

    return f"HTTP {response.status_code} {response.url}\n\n{body}"</code></pre></div><p><code>ask_user</code> lets the agent request input from the user. It emits <code>AskUserRequested</code> so the TUI renders the question, then awaits <code>ctx.deps.resolve_user_question</code>. Two things can go wrong: the agent loop can run in headless mode, where there is no interactive user at all, or the question can be dismissed (turn aborted, REPL shutting down). Both become <code>ModelRetry</code> text telling the model plainly to proceed without an answer (from <code>src/decode/tools/askuser.py</code>):</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">async def ask_user(ctx: RunContext[AgentDeps], question: str) -&gt; str:
    ctx.deps.emit(events.AskUserRequested(question=question))
    try:
        return await ctx.deps.resolve_user_question(question)
    except NoInteractiveUserError as exc:
        raise ModelRetry(str(exc)) from exc</code></pre></div><p><code>bash</code> is the most powerful. Via <code>bash</code> the agent can execute any shell command such as <code>ls</code>, <code>cd</code>, <code>mkdir</code>, <code>rm</code>, <code>cp</code>, <code>mv</code>, and <code>echo</code>. Plus, piping and everything else you can run in a terminal. Which means that via <code>bash</code> the agent can run Python, TypeScript, Rust, or any other language. Via <code>bash</code> it can manipulate all the CLIs you give it access to.</p><blockquote><p><em>Via </em><code>bash</code><em> it gets that magical feeling of being able to interact with the operating system and run any command.</em></p></blockquote><p>But this also makes it the most dangerous one. <code>rm -rf ~/</code> is always <a href="https://modal.com/llm-almanac/summary?source=decodingai&amp;campaign=harnesseng">only a few tokens away</a>. That&#8217;s why running your agent in a sandbox environment becomes so important. In a future lesson, we will get into the executor and how to run commands in local Docker and remote <a href="https://modal.com/docs/guide/sandboxes?source=decodingai&amp;campaign=harnesseng">Modal containers</a>.</p><p>Bash plus code execution is a big step toward <a href="https://blog.langchain.com/the-anatomy-of-an-agent-harness/">giving the model a computer</a> (from <code>src/decode/tools/bash.py</code>):</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">async def bash(ctx: RunContext[AgentDeps], command: str, timeout: float | None = None) -&gt; str:
    if needs_approval(ctx):
        raise ApprovalRequired
    timeout_s = _resolve_timeout(timeout)
    result = await _get_executor().run(command, cwd=ctx.deps.cwd, timeout_s=timeout_s)

    return _render(result, timeout_s=timeout_s)</code></pre></div><p>As we&#8217;ve seen at the beginning, the lifecycle of the agent is based on running these tools in order: <code>todo_write</code> plans, <code>read</code> / <code>glob</code> / <code>grep</code> explore, <code>write</code> / <code>edit</code> apply, <code>bash</code> executes (<code>bash</code>&#8216;s exit code is the observation that starts the next pass).</p><p>When running <code>.decode/skills/demo-6-article-kg</code> that asks the agent to scrape 3 web pages and build a knowledge graph, the agent creates a 4-step plan, keeps track of it via <code>todo_write</code>, fetches the data via <code>web_fetch</code>, extracts the KG triplets directly, then via <code>write</code> saves them to <code>graph.json</code>. Next, it writes the HTML and CSS code that displays the KG triplets into <code>kg.html</code>. Ultimately, via <code>bash</code> it checks that the HTML code renders correctly. If not, the model <code>edit</code>s the code and retries.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!h25c!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F794bbda3-92ab-43cf-9988-b5680507589f_2874x1732.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!h25c!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F794bbda3-92ab-43cf-9988-b5680507589f_2874x1732.png 424w, https://substackcdn.com/image/fetch/$s_!h25c!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F794bbda3-92ab-43cf-9988-b5680507589f_2874x1732.png 848w, https://substackcdn.com/image/fetch/$s_!h25c!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F794bbda3-92ab-43cf-9988-b5680507589f_2874x1732.png 1272w, https://substackcdn.com/image/fetch/$s_!h25c!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F794bbda3-92ab-43cf-9988-b5680507589f_2874x1732.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!h25c!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F794bbda3-92ab-43cf-9988-b5680507589f_2874x1732.png" width="1456" height="877" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/794bbda3-92ab-43cf-9988-b5680507589f_2874x1732.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:877,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Opik Plan&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Opik Plan" title="Opik Plan" srcset="https://substackcdn.com/image/fetch/$s_!h25c!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F794bbda3-92ab-43cf-9988-b5680507589f_2874x1732.png 424w, https://substackcdn.com/image/fetch/$s_!h25c!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F794bbda3-92ab-43cf-9988-b5680507589f_2874x1732.png 848w, https://substackcdn.com/image/fetch/$s_!h25c!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F794bbda3-92ab-43cf-9988-b5680507589f_2874x1732.png 1272w, https://substackcdn.com/image/fetch/$s_!h25c!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F794bbda3-92ab-43cf-9988-b5680507589f_2874x1732.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><h2>Adding Tracing to Understand What Is Going On</h2><p>We&#8217;ve seen above how the agent calls the <code>todo_write</code> tool to bake the plan into its state. The trace is logged via <a href="https://www.comet.com/site/?utm_source=workshop&amp;utm_medium=partner&amp;utm_campaign=paul&amp;utm_content=coding_agent_course">Opik</a>. Let&#8217;s see how easy it is to plug it into your own code.</p><p>Debugging your agent via the terminal is terrible. Not only is reading the full traces hard, sometimes it&#8217;s impossible, as you just don&#8217;t have access to all the spans, plus other essential metadata such as configs, token counts, tool inputs and outputs &#8212; and the list goes on. That&#8217;s why you need to plug in an observability tool like Opik from day 0 to get visibility into your agent&#8217;s behavior.</p><p>As we use Pydantic AI, it has native support for tracing via Logfire, the observability tool made by Pydantic. Logfire, like most observability tools, supports OpenTelemetry (OTLP) out of the box, which is the standard wire protocol for tracing. Thus, hooking up Opik is as easy as defining the <code>OTLPSpanExporter</code> to point to Opik&#8217;s managed servers via the <code>endpoint</code> parameter, plus authentication headers. As Opik is open-source, this would work exactly the same if you were hosting it yourself (from <code>src/decode/observability/tracing.py</code>).</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">def init_tracing() -&gt; bool:
    key = settings.opik_api_key.get_secret_value()
    if not key:
        return False

    exporter = OTLPSpanExporter(
        endpoint=f"{base}/v1/traces",
        headers={"Authorization": key, "Comet-Workspace": settings.opik_workspace,
                 "projectName": settings.opik_project_name})
    logfire.configure(send_to_logfire=False, console=False,
        additional_span_processors=[BatchSpanProcessor(CostAnnotatingExporter(exporter))])
    logfire.instrument_pydantic_ai()

    return True</code></pre></div><p>You can find the full setup on how to get started with Opik in our <a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course/blob/main/running_the_code/install_and_usage.md">GitHub repository</a>. Opik is optional to get through the course, but note that it has a generous freemium plan with 25k spans/month free. You can run the whole course for free.</p><p>In the GIF below, you can see an end-to-end trace of how the agent executed the <code>.decode/skills/demo-6-article-kg</code> skill that builds the KG from 3 articles. It consists of 47 spans, covering 6 steps, 15 model calls, and 18 tool executions over ~6m.</p><div class="native-video-embed" data-component-name="VideoPlaceholder" data-attrs="{&quot;mediaUploadId&quot;:&quot;e926026d-53d7-4f4f-b61e-fd291b72afe2&quot;,&quot;duration&quot;:null}"></div><p>With the following token usage (no cost per token as we ran it via Modal):</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;plaintext&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-plaintext">cache_read.input_tokens: 631424
completion_tokens: 19781
details.cache_read_tokens: 631424
details.reasoning_tokens: 2912
prompt_tokens: 655624
total_tokens: 675405</code></pre></div><h2>The TUI and the Queues</h2><p>You can build a TUI in <a href="https://mariozechner.at/posts/2025-11-30-pi-coding-agent/">2 ways</a>. <strong>Full-screen</strong> takes over the terminal&#8217;s viewport as a grid of cells (Amp, OpenCode): total layout control, but you lose scrollback, search and have to implement a bunch of features from scratch. <strong>Append-to-scrollback</strong> writes like an ordinary CLI (Claude Code, Codex, Pi). Decode takes the second approach.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!3VGC!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9441cf15-4eb2-4376-9ee6-3f6c6031b696_1815x986.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!3VGC!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9441cf15-4eb2-4376-9ee6-3f6c6031b696_1815x986.png 424w, https://substackcdn.com/image/fetch/$s_!3VGC!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9441cf15-4eb2-4376-9ee6-3f6c6031b696_1815x986.png 848w, https://substackcdn.com/image/fetch/$s_!3VGC!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9441cf15-4eb2-4376-9ee6-3f6c6031b696_1815x986.png 1272w, https://substackcdn.com/image/fetch/$s_!3VGC!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9441cf15-4eb2-4376-9ee6-3f6c6031b696_1815x986.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!3VGC!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9441cf15-4eb2-4376-9ee6-3f6c6031b696_1815x986.png" width="1456" height="791" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9441cf15-4eb2-4376-9ee6-3f6c6031b696_1815x986.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:791,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;TUI&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="TUI" title="TUI" srcset="https://substackcdn.com/image/fetch/$s_!3VGC!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9441cf15-4eb2-4376-9ee6-3f6c6031b696_1815x986.png 424w, https://substackcdn.com/image/fetch/$s_!3VGC!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9441cf15-4eb2-4376-9ee6-3f6c6031b696_1815x986.png 848w, https://substackcdn.com/image/fetch/$s_!3VGC!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9441cf15-4eb2-4376-9ee6-3f6c6031b696_1815x986.png 1272w, https://substackcdn.com/image/fetch/$s_!3VGC!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9441cf15-4eb2-4376-9ee6-3f6c6031b696_1815x986.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>As Python packages, we use <code>prompt_toolkit</code> to read the input and <code>Rich</code> to render output in append-style. Below you can see the loop that takes events from the harness and renders them on the TUI (from <code>src/decode/tui/app.py</code>).</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">with patch_stdout(raw=True):
    while True:
        submitted = await session.prompt_async(_PROMPT)   # one pinned input line
        intent, text = _interpret(submitted)              # Enter / Alt+Enter / Esc
        if decisions.pending:                             # mid-turn question? answer it
            decisions.resolve(text)
            continue
        await runner.submit(text, intent)</code></pre></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!sVk_!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67513ce7-f3d1-4d72-9116-d8965e52021e_1815x1033.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!sVk_!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67513ce7-f3d1-4d72-9116-d8965e52021e_1815x1033.png 424w, https://substackcdn.com/image/fetch/$s_!sVk_!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67513ce7-f3d1-4d72-9116-d8965e52021e_1815x1033.png 848w, https://substackcdn.com/image/fetch/$s_!sVk_!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67513ce7-f3d1-4d72-9116-d8965e52021e_1815x1033.png 1272w, https://substackcdn.com/image/fetch/$s_!sVk_!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67513ce7-f3d1-4d72-9116-d8965e52021e_1815x1033.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!sVk_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67513ce7-f3d1-4d72-9116-d8965e52021e_1815x1033.png" width="1456" height="829" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/67513ce7-f3d1-4d72-9116-d8965e52021e_1815x1033.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:829,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;The Decode TUI on startup &#8212; the Modal-served model in the banner, Opik tracing on, and the footer naming all three input modes.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="The Decode TUI on startup &#8212; the Modal-served model in the banner, Opik tracing on, and the footer naming all three input modes." title="The Decode TUI on startup &#8212; the Modal-served model in the banner, Opik tracing on, and the footer naming all three input modes." srcset="https://substackcdn.com/image/fetch/$s_!sVk_!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67513ce7-f3d1-4d72-9116-d8965e52021e_1815x1033.png 424w, https://substackcdn.com/image/fetch/$s_!sVk_!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67513ce7-f3d1-4d72-9116-d8965e52021e_1815x1033.png 848w, https://substackcdn.com/image/fetch/$s_!sVk_!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67513ce7-f3d1-4d72-9116-d8965e52021e_1815x1033.png 1272w, https://substackcdn.com/image/fetch/$s_!sVk_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67513ce7-f3d1-4d72-9116-d8965e52021e_1815x1033.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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>But what happens when you type a new command mid-turn, while the agent is still running your previous one? Injecting it instantly would corrupt the current tool call. Thus, you need to buffer your input on arrival and inject it only at boundaries, such as after a tool finishes running or a whole turn ends.</p><p>The input can arrive in 3 modes.</p><ul><li><p><strong>Steering</strong> (plain <code>Enter</code>): the Runner executes it within a model turn, between tool calls.</p></li><li><p><strong>Follow-up</strong> (<code>Alt+Enter</code>): the Runner holds it until the turn stops, then runs it as one more step.</p></li><li><p><strong>Cooperative abort</strong> (<code>Esc</code>): sets a flag to stop the agent turn at the next boundary. Next, it clears both queues. This avoids corrupting the history.</p></li></ul><p>As seen within the <code>InteractionQueues</code> class, for steering and follow-ups we use two different in-memory queues (from <code>src/decode/harness/queue.py</code>).</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">@dataclass(slots=True)
class InteractionQueues:
    steering: asyncio.Queue[str] = field(default_factory=asyncio.Queue)
    follow_up: asyncio.Queue[str] = field(default_factory=asyncio.Queue)
    def drain_steering(self) -&gt; list[str]:  return _drain(self.steering)
    def drain_follow_up(self) -&gt; list[str]: return _drain(self.follow_up)
    def clear(self) -&gt; None:                # on abort: drop everything pending
        _drain(self.steering)
        _drain(self.follow_up)</code></pre></div><p>This loop belongs to the <code>Runner</code>, which is the facade between the TUI and the agent. Its job is to keep the agent alive as long as the TUI session is running. It also takes care of draining the queues at the right moments and sending them to the agent (from <code>src/decode/harness/runner.py</code>).</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">class Runner:

    ...                 # single-flight: one turn in flight, ever

    async def _run_turn(self, turn_id: int, prompt: str) -&gt; None:
        agen = self._turn_handler(ctx)
        boundary = await agen.asend(None)
        while True:
            if self._abort:
                aborted = True
                break                                 # Esc: stop at the boundary, keep history
            if boundary is Boundary.MODEL_REQUEST:
                sent = self.queues.drain_steering()   # steering: before every model call
            elif boundary is Boundary.WOULD_STOP:
                sent = self.queues.drain_follow_up()  # follow-up: only when the turn would end
            try:
                boundary = await agen.asend(sent)     # resume the loop; get the next boundary
            except StopAsyncIteration:
                break</code></pre></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!vDAk!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F293cd381-1a60-4553-8c55-5a9b147f1815_1200x665.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!vDAk!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F293cd381-1a60-4553-8c55-5a9b147f1815_1200x665.png 424w, https://substackcdn.com/image/fetch/$s_!vDAk!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F293cd381-1a60-4553-8c55-5a9b147f1815_1200x665.png 848w, https://substackcdn.com/image/fetch/$s_!vDAk!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F293cd381-1a60-4553-8c55-5a9b147f1815_1200x665.png 1272w, https://substackcdn.com/image/fetch/$s_!vDAk!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F293cd381-1a60-4553-8c55-5a9b147f1815_1200x665.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!vDAk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F293cd381-1a60-4553-8c55-5a9b147f1815_1200x665.png" width="1200" height="665" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/293cd381-1a60-4553-8c55-5a9b147f1815_1200x665.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:665,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Two queues, two drain boundaries, one safe turn.&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Two queues, two drain boundaries, one safe turn." title="Two queues, two drain boundaries, one safe turn." srcset="https://substackcdn.com/image/fetch/$s_!vDAk!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F293cd381-1a60-4553-8c55-5a9b147f1815_1200x665.png 424w, https://substackcdn.com/image/fetch/$s_!vDAk!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F293cd381-1a60-4553-8c55-5a9b147f1815_1200x665.png 848w, https://substackcdn.com/image/fetch/$s_!vDAk!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F293cd381-1a60-4553-8c55-5a9b147f1815_1200x665.png 1272w, https://substackcdn.com/image/fetch/$s_!vDAk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F293cd381-1a60-4553-8c55-5a9b147f1815_1200x665.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><figcaption class="image-caption"><em>Buffer instantly, inject only at boundaries</em></figcaption></figure></div><p>This is the approach implemented in Pi. Another option, implemented in OpenCode, is to keep track of the session in your database, which means you can use your database as the queue as well. But that also means that you need to complicate your solution with a database. Which raises the question, how do we keep track of sessions?</p><h2>The Session Log</h2><p>In the interactive mode the conversation is the working state. To keep track of sessions, we create a <strong>session log</strong> &#8212; an append-only JSONL file per session under <code>.decode/sessions/</code>. This simple approach kills the need for a database entirely. This is how Claude Code implements their session management.</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;plaintext&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-plaintext">.decode/sessions/
&#9500;&#9472;&#9472; 20260620T132411Z_d710a5b9-28af-418b-9a15-936942a8db12.jsonl
&#9500;&#9472;&#9472; 20260620T132419Z_058cddc8-1d0f-406d-a754-098703c07cb5.jsonl
&#9500;&#9472;&#9472; 20260622T110408Z_7114fe38-d294-4c78-bbc3-c454be57082b.jsonl
&#9500;&#9472;&#9472; 20260622T111609Z_4bbf140e-3495-4d69-9a88-c7014fd77742.jsonl
&#9500;&#9472;&#9472; 20260625T152011Z_7594e9b0-6c62-421a-ad74-9918c4d0291e.jsonl
&#9492;&#9472;&#9472; ...</code></pre></div><p>Every completed turn appends one <code>messages</code> line to the log. An aborted or crashed turn persists what it finished (from <code>src/decode/context/session_log.py</code>).</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">def append_turn(self, new_messages: list[ModelMessage]) -&gt; None:
    if not new_messages:
        return

    payload = json.loads(ModelMessagesTypeAdapter.dump_json(new_messages))
    entry = {"type": "messages", "messages": payload}
    with self.path.open("a", encoding="utf-8") as handle:
        handle.write(json.dumps(entry) + "\n")</code></pre></div><p>Based on the knowledge-graph example, here is how the log entries look:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;plaintext&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-plaintext">{"type": "session", "version": 1, "session_id": "48900d84&#8230;", "cwd": "&#8230;/building-a-coding-agent-from-scratch-course", "created_at": "2026-07-16T19:32:01Z"}
{"type": "messages", "messages": [
    {"role": "user", "content": "The hardcore one: turn three live articles into a knowledge graph&#8230;"},
    {"role": "tool", "name": "web_fetch", "content": "HTTP 200 &#8230;/keep-knowledge-graph-clean\n\nHow to Keep a Knowledge Graph Clean&#8230;"},
    {"role": "tool", "name": "bash", "content": "Exit code: 0.\n\nstdout:\nNode count: 28 (should be 20-35)\nEdge count: 29&#8230;"},
    {"role": "assistant", "content": "## Knowledge Graph Visualization &#8212; Complete&#8230;"}]}</code></pre></div><p>To resume the state, you can run <code>decode --resume &lt;session_id&gt;</code> to kick off a new TUI from an existing session log.</p><h2>Next Steps</h2><p>In this lesson, we&#8217;ve implemented a bare-bones version of the coding agent, adding the right tools, a TUI, and a way to manage sessions. More or less, at this point, we are at feature parity with Pi.</p><p>But as a course on harness engineering, we want to push it further. Any agent needs a headless mode (along with running it from the terminal), essential context engineering features such as memory, compaction, skills and guardrails such as the permission layer and sandboxes. That&#8217;s essentially harness engineering. So far we&#8217;ve built the agent loop. Now the real harness engineering begins.</p><div class="callout-block" data-callout="true"><p>&#129489;&#8205;&#128187; <span>We encourage you to&nbsp;</span><strong>clone our&nbsp;<a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course">course repo</a></strong><span>, open your terminal, type </span><strong><span data-color="#38761d" style="color: rgb(56, 118, 29);">decode</span> </strong>and test out the coding agent.</p></div><p>In the <a href="https://www.decodingai.com/p/run-coding-agents-safely">next lesson</a>, we&#8217;ll build the sandbox layer locally via Docker and remotely via Modal.</p><p>Here is the<strong> course roadmap, </strong>lesson by lesson <em>(<a href="https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course#-course-outline">see all in GitHub</a></em>):</p><ol><li><p><a href="https://www.decodingai.com/p/building-a-coding-agent-from-scratch-system-design">Building a Coding Agent From Scratch</a></p></li><li><p><strong>The Bare-Bones Coding Agent Loop</strong> &#8592; <strong>You are here</strong></p></li><li><p><a href="https://www.decodingai.com/p/run-coding-agents-safely">From a Raw Shell to a Sandboxed Coding Agent</a></p></li><li><p><a href="https://www.decodingai.com/p/context-engineering-for-coding-agents">Context Engineering for Coding Agents</a></p></li><li><p><a href="https://www.decodingai.com/p/subagents-are-context-engineering">Subagents Are Context Engineering</a></p></li><li><p><a href="https://www.decodingai.com/p/coding-agents-in-remote-headless">Swarm of Remote Agents</a></p></li><li><p><a href="https://www.decodingai.com/p/evaluate-ai-agents-benchmarks-regression-tests">Agent Evals 101</a></p></li><li><p><a href="https://www.decodingai.com/p/transform-agent-traces-into-regression-cases">Turn Your Agent&#8217;s Failures Into a Regression Suite</a></p></li></ol><p>Or the <strong>video</strong> lecture <strong>supporting</strong> <strong>the</strong> <strong>first two lessons</strong>:</p><div id="youtube2-sJpop1juVBQ" class="youtube-wrap" data-attrs="{&quot;videoId&quot;:&quot;sJpop1juVBQ&quot;,&quot;startTime&quot;:null,&quot;endTime&quot;:null}" data-component-name="Youtube2ToDOM"><div class="youtube-inner"><iframe src="https://www.youtube-nocookie.com/embed/sJpop1juVBQ?rel=0&amp;autoplay=0&amp;showinfo=0&amp;enablejsapi=0" frameborder="0" loading="lazy" gesture="media" allow="autoplay; fullscreen" allowautoplay="true" allowfullscreen="true" width="728" height="409"></iframe></div></div><p><em>But here is what I&#8217;m wondering:</em></p><blockquote><p><strong>From your perspective, as we&#8217;ve been using Claude Code, Codex, etc. for general productivity stuff, what makes a general-purpose agent a coding agent?</strong></p></blockquote><p><em>Click the button below and tell me. I read every response.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://www.decodingai.com/p/the-coding-agent-loop/comments&quot;,&quot;text&quot;:&quot;Leave a comment&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://www.decodingai.com/p/the-coding-agent-loop/comments"><span>Leave a comment</span></a></p><div><hr></div><p><em>Enjoyed the article? The most sincere compliment is to restack this for your readers.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://www.decodingai.com/p/the-coding-agent-loop?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;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://www.decodingai.com/p/the-coding-agent-loop?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p><div><hr></div><p><em>Special thanks to <strong><a href="https://modal.com?source=decodingai&amp;campaign=harnesseng">Modal</a></strong>, <strong><a href="https://www.comet.com/site/?utm_source=newsletter&amp;utm_medium=partner&amp;utm_campaign=paul&amp;utm_content=coding_agent_course">Opik (by Comet)</a></strong>, and <strong><a href="https://www.zenml.io/product/kitaru?utm_source=decodingai&amp;utm_medium=referral&amp;utm_campaign=coding-agent-course&amp;utm_content=brand">Kitaru (by ZenML)</a></strong> for sponsoring this open-source course and keeping it free!</em></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Uq-1!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Uq-1!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 424w, https://substackcdn.com/image/fetch/$s_!Uq-1!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 848w, https://substackcdn.com/image/fetch/$s_!Uq-1!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 1272w, https://substackcdn.com/image/fetch/$s_!Uq-1!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!Uq-1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png" width="1200" height="400" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:400,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:69533,&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://www.decodingai.com/i/207400663?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.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_!Uq-1!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 424w, https://substackcdn.com/image/fetch/$s_!Uq-1!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 848w, https://substackcdn.com/image/fetch/$s_!Uq-1!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 1272w, https://substackcdn.com/image/fetch/$s_!Uq-1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98999460-8389-40b0-9dda-73f934bbf55a_1200x400.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button class="pencraft pc-reset pencraft icon-container restack-image buttonBase-tqxFUX" tabindex="0" type="button"><svg aria-hidden="true" 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" class="icon-noB79L"><g><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 class="pencraft pc-reset pencraft icon-container view-image buttonBase-tqxFUX" tabindex="0" type="button"><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 icon-noB79L"><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><div><hr></div><div class="callout-block" data-callout="true"><h4>Whenever you&#8217;re ready, here is how I can help you</h4><p><em>Go from agent user to agent builder.</em> Master the foundations of AI agents and turn fragile demo code into reliable, production-ready systems with my course, <strong><a href="https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering">Agent Engineering: Building Multi-Agent Systems</a></strong> (made with Towards AI).</p><p>35 lessons. Pure foundations from scratch. 4 mini-projects. 2 production systems. A certificate and direct access to me &amp; industry experts in our Discord.</p><p>Built for software and data professionals transitioning into AI engineering. <em>Rated 5/5 with 300+ students. The first 7 lessons are free:</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering&quot;,&quot;text&quot;:&quot;Start here&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://academy.towardsai.net/courses/agent-engineering?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering"><span>Start here</span></a></p><p><em>Not ready to commit?</em> Start with our <strong><a href="https://email-course.towardsai.net/?ref=b3ab31&amp;utm_source=decodingai&amp;utm_medium=partner&amp;utm_campaign=agent_engineering">free Agent AI Engineering Guide</a></strong>, a 6-day email course on the mistakes that silently break AI agents in production.</p></div><div><hr></div><h2>Images &amp; Videos</h2><p>If not otherwise stated, all images are created by the author.</p>]]></content:encoded></item></channel></rss>