<?xml version="1.0" encoding="UTF-8"?><rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>HumanLayer Blog</title><link>https://www.humanlayer.dev/blog</link><atom:link href="http://rss.144-124-237-35.sslip.io/humanlayer/blog" rel="self" type="application/rss+xml"></atom:link><description>HumanLayer Blog - Powered by AtomRSS</description><generator>AtomRSS</generator><webMaster>contact@atomgroup.dev (AtomRSS)</webMaster><language>en</language><lastBuildDate>Sat, 08 Aug 2026 07:36:08 GMT</lastBuildDate><ttl>5</ttl><item><title>Context Forking to Save Time, Tokens and Trouble</title><description>&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Context forking is a powerful coding agent primitive that allows you to build up high-quality context and then reuse it multiple times.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Lots of coding agents (OpenCode, Pi, Claude Code, and many others) support context forking, though they often give it different names: rewind, time traveling, or branching - but they&#39;re all variants of the same concept.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;This post is a tactical guide on how to use context forking to save you time, tokens, money, and/or a great deal of frustration&lt;/p&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;Context Windows as Operating System Stacks&lt;/h2&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;I like to conceptualize agent context windows as &lt;a href=&quot;https://wiki.osdev.org/Stack&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;downwards-growing stacks&lt;/a&gt;, inspired by stacks from operating systems:&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/context-forking-to-save-time-trouble-and-tokens/stack.png&quot; alt=&quot;Operating System Stack&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;In an OS stack, frames for new routines are appended to the bottom of the stack as routines are called. You can conceptualize a context window the same way, with each user message-assistant message turn as a new routine with a new stack frame:&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/context-forking-to-save-time-trouble-and-tokens/context-window-as-a-stack.png&quot; alt=&quot;Context Window as an Operating System Stack&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Like a stack, coding agent context windows usually &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;prevent random access&lt;/strong&gt;. You can &lt;a href=&quot;https://wiki.osdev.org/Stack&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;push&lt;/a&gt; things to the end of it by sending a user message, and you can &lt;a href=&quot;https://wiki.osdev.org/Stack&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;pop&lt;/a&gt; (remove) things from the end.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;But just like how an OS stack grows downwards as new routines are called &amp;amp; stack frames are pushed onto it, the context window only lets you push or pop from the newest end of the history. &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;You are stuck interacting with the end of it.&lt;/strong&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Random access isn&#39;t allowed for several reasons:&lt;/p&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ul class=&quot;list-disc space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;It can cause expensive cache misses against your inference API&lt;/li&gt;
&lt;li&gt;It can mangle important accumulated context&lt;/li&gt;
&lt;li&gt;It can interfere with your coding agent&#39;s internal state&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/context-forking-to-save-time-trouble-and-tokens/random-access-not-allowed.png&quot; alt=&quot;Random access not allowed&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Most coding agents have internal state that tracks which files the agent has read and/or written (among other things). When the agent tries to edit a file, this allows the harness to prompt &amp;amp; force the agent to read the file before attempting to modify it.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Erasing or adding tool calls into the middle of a context window would require surgical manipulation of the coding agent&#39;s context AND any internal state, and agents generally don&#39;t support that.&lt;/p&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;How does context forking work?&lt;/h2&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Context forking allows you to pop 1 or more messages off the bottom of the context window stack to restore the state to an earlier version.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Just like how an OS stacks pushes &amp;amp; pops entire frames at a time, you can usually only rewind your context window at user-message turn boundaries, not in the middle of a sequence of tool calls:&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/context-forking-to-save-time-trouble-and-tokens/rewind.png&quot; alt=&quot;forking to rewind the context window&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Usually, you can do this more than once - forking from the same context window in many different ways.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Interface and implementation details vary from agent to agent. Some agents allow you to rewind the state of the code &amp;amp; disk when you rewind the state of the conversation. Others may create a new branch or worktree when you do this.&lt;/p&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;When should you fork your context window?&lt;/h2&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;Rewinding to course-correct an agent&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;A popular use-case is for forking is to rewind a conversation while the agent is implementing a feature to account for something that was missed:&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/context-forking-to-save-time-trouble-and-tokens/rewinding-to-course-correct.png&quot; alt=&quot;Rewinding to course-correct your agent&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;Forking to explore different design paths&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;I often find myself forking sessions during the design phase of a task.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Once I have accumulated high-quality context about the codebase and problem I&#39;m trying to solve, I&#39;ll fork the conversation to explore different design &amp;amp; architectural paths.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Then I&#39;ll review the results and decide which session to proceed from - or that more research is necessary!&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/context-forking-to-save-time-trouble-and-tokens/forking-as-exploration.png&quot; alt=&quot;Context forking for exploration&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;Forking to preserve a context window from context-inefficient operations&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Another great use of forking is to rewind a conversation to preserve high-quality built-up context after the agent does something context-inefficient.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;An example of this is when the agent reads a large file or runs a command that generates a TON of output - tens of thousands of tokens worth. Most &lt;a href=&quot;https://www.humanlayer.dev/blog/skill-issue-harness-engineering-for-coding-agents&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;coding agent harnesses have hooks or other safeguards&lt;/a&gt; to prevent this by writing the output to a file and just showing the agent the filepath rather than the entire contents, and instructing the agent to search through it. But sometimes, the agent just reads all 40,000 tokens one chunk at a time and fills up the context window:&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/context-forking-to-save-time-trouble-and-tokens/context-inefficient-operations.png&quot; alt=&quot;Context inefficient operations can fill up your context window&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Fortunately, we can salvage the conversation with forking!&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/context-forking-to-save-time-trouble-and-tokens/forking-to-salvage-context.png&quot; alt=&quot;Forking to salvage context&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;Let&#39;s recap:&lt;/h2&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ol class=&quot;list-decimal space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;Coding agent context windows can be conceptualized as downwards-growing stacks. You can push to or pop from the bottom, but generally can&#39;t interactively mess with the middle or top of the stack&lt;/li&gt;
&lt;li&gt;Context forking can be used to rewind a context window to re-steer it when the agent missed something&lt;/li&gt;
&lt;li&gt;Context forking can be used to branch and explore multiple different design or implementation paths&lt;/li&gt;
&lt;li&gt;Context forking can be used to restore a context window to a state before a large volume of low-quality context was added.&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;</description><link>https://www.humanlayer.dev/blog/context-forking-to-save-time-trouble-and-tokens</link><guid isPermaLink="false">https://www.humanlayer.dev/blog/context-forking-to-save-time-trouble-and-tokens</guid><pubDate>Thu, 14 May 2026 16:00:00 GMT</pubDate><author>Kyle</author><category>agents</category><category>claudecode</category><category>context-engineering</category><category>best-practices</category></item><item><title>Long-Context Isn&#39;t the Answer</title><description>&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Anthropic just switched the default model in Claude Code to Opus 4.6 with a 1M context window. We tried it when it launched. But now we&#39;re switching back to Opus 4.5&lt;/p&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;How about some context?&lt;/h2&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Unlike previous Claude Opus models which have a ~ 200k context window, Opus 4.6 has as 1M context window. This was very exciting for us!&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;We spend a lot of time working on hard problems in large enterprise codebases, and if the model can reliably hold more of the codebase in its head at a time, so to speak, then that creates new possibilities for the scale of problem that can be solved in a single context window.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;It would mean less compaction (whether &lt;a href=&quot;https://www.humanlayer.dev/blog/advanced-context-engineering&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;frequent intentional compaction&lt;/a&gt; or auto-compact), and less &quot;context pressure&quot; to solve the problem before your context window fills up.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;As Calvin French-Owen, who helped launch Codex last year, &lt;a href=&quot;https://youtu.be/qwmmWzPnhog?si=ReRWTavUKTItIGGr&amp;amp;t=918&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;puts it in an episode of YC&#39;s Lightcone podcast&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote class=&quot;border-l-4 pl-4 my-4 italic&quot; style=&quot;border-color:var(--accent);color:var(--text-muted)&quot;&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;...imagine you&#39;re a college student. You&#39;re taking an exam. In the first five minutes of that exam, you&#39;re like, &quot;Oh, I have all the time in the world. I&#39;ll do a great job. I&#39;ll think through each of these problems.&quot;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Let&#39;s say you have like five minutes left and you still have half the exam left. You&#39;re like, &quot;Oh man, I just got to do whatever I can.&quot; Like, that&#39;s the LLM with a context window&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;More context, less instruction adherence&lt;/h2&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;While the context window is dramatically larger, we noticed over the course of a couple of weeks that instruction adherence was dramatically degraded, and not just at longer context lengths.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Even well-within what we would consider the &lt;a href=&quot;https://youtu.be/rmvDxxNubIg?si=O17nmS3SScaAkpp-&amp;amp;t=355&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;smart zone&lt;/a&gt; of a 200k-context frontier model, the model was less precise. It would ignore design documents and other inputs when writing a plan file. It would make trivial mistakes, or misunderstand simple instructions - or worse, directly disobey them.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;At longer context lengths, the degradation was even steeper - like the user instructions were getting drowned out by the intermediate tool results and mass of accumulated context.&lt;/p&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;What determines instruction adherence?&lt;/h2&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;We&#39;ve written about the concept of &lt;a href=&quot;https://www.humanlayer.dev/blog/skill-issue-harness-engineering-for-coding-agents&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;the instruction budget&lt;/a&gt; before - a measurable property of LLMs which describes how many instructions they can follow reasonably well before instruction adherence drops off.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;It&#39;s different for each model, but it&#39;s a function primarily of the quality of the model&#39;s instruction tuning, and more importantly for our purposes, it is &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;strongly correlated with the size of the model&lt;/strong&gt;.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/writing-a-good-claude-md/instructionfollowing.png&quot; alt=&quot;Instruction following&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;You can clearly see that the larger models from the &lt;a href=&quot;https://arxiv.org/pdf/2507.11538&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;study&lt;/a&gt; can follow dramatically more instructions before adherence drops off.&lt;/p&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;Instruction adherence at long context lengths&lt;/h2&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Why does this matter?&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;When a lab offers an extended-context version of a model, you&#39;re usually not getting a bigger model with more parameters and therefore a larger &quot;instruction budget&quot; to go with the larger context window - you&#39;re likely getting the same model with some clever math (e.g. &lt;a href=&quot;https://arxiv.org/pdf/2309.00071&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;YaRN&lt;/a&gt;) to extend the sequence length the model can attend to, and probably some more post-training to stabilize the model at the longer sequence lengths.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;This means that while the context window size increases, the instruction budget remains the same. You can fit more context and more instructions in the context window, but the model isn&#39;t actually better at attending to those instructions over the context length.&lt;/p&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;Instruction-following as needle in a haystack&lt;/h2&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;You can think of your context window as a haystack where all of your tool calls and documents and files are hay - every line in your CLAUDE.md file, every instruction in your tool descriptions, every tool result, every instruction in your system prompt, and every user message.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;The quality &amp;amp; correctness of the agent&#39;s next step depends on the LLM&#39;s ability to find a needle in there: namely, the instruction(s) in the context window that are most-relevant to the current state of the context window, which give it the information it needs to make the correct decision about its next action.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Now imagine we increase the size of the haystack by 500% - but the size of the needle remains the same. Unless our ability to find the needle also increases by 500%, we will have a dramatically harder time finding it. The extra context isn&#39;t really helping us - it&#39;s just digging us deeper into the dumb zone.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/skill-issue/long-context.jpg&quot; alt=&quot;long context&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;What Works Instead&lt;/h2&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Instead of trying to stuff as much information in a context window as possible and having the LLM reason over it, we found that the context management techniques we had been using had to be used even &lt;em style=&quot;color:var(--text-secondary)&quot;&gt;more&lt;/em&gt; aggressively to keep Opus 4.6 1M on track.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;In my post on &lt;a href=&quot;https://www.humanlayer.dev/blog/skill-issue-harness-engineering-for-coding-agents&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;harness engineering&lt;/a&gt;, I wrote about this as the limit case for using sub-agents:&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/skill-issue/limit-case.png&quot; alt=&quot;limit case&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;The day after I published it, I decided maybe it wasn&#39;t such a bad idea, and sat down and wrote this skill:&lt;/p&gt;
&lt;pre class=&quot;group&quot;&gt;&lt;pre class=&quot;prismjs rsh-code-block grid relative min-w-[250px] mb-6 bg-gray-400/5 p-4&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider border bg-transparent text-[var(--accent)] border-transparent hover:bg-[var(--accent)]/10 hover:border-[var(--accent)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-1 h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-10&quot; aria-label=&quot;Copy code&quot; title=&quot;Copy code&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-copy h-3 w-3&quot; aria-hidden=&quot;true&quot;&gt;&lt;rect width=&quot;14&quot; height=&quot;14&quot; x=&quot;8&quot; y=&quot;8&quot; rx=&quot;2&quot; ry=&quot;2&quot;&gt;&lt;/rect&gt;&lt;path d=&quot;M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;code class=&quot;overflow-x-auto&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;&quot;&gt;---
&lt;/span&gt;name: subagent-orchestrator
&lt;!-- --&gt;description: orchestrate sub-agents to accomplish complex long-horizon tasks without losing coherency by delegating to sub-agents
&lt;!-- --&gt;---
&lt;!-- --&gt;
&lt;!-- --&gt;This skill provides you with **CRITICAL** instructions that will help you to maintain coherency in long-horizon context-heavy tasks.
&lt;!-- --&gt;
&lt;!-- --&gt;You have a large number of tools available to you. The most important one is the one that allows you to dispatch sub-agents: either `Agent` or `Task`.
&lt;!-- --&gt;
&lt;!-- --&gt;All non-trivial operations should be delegated to sub-agents. You should delegate research and codebase understanding tasks to codebase-analyzer, codebase-locator and pattern-locator sub-agents.
&lt;!-- --&gt;
&lt;!-- --&gt;You should delegate running bash commands (particularly ones that are likely to produce lots of output) such as investigating with the `aws` CLI, using the `gh` CLI, digging through logs to `Bash` sub-agents.
&lt;!-- --&gt;
&lt;!-- --&gt;You should use separate sub-agents for separate tasks, and you may launch them in parallel - but do not delegate multiple tasks that are likely to have significant overlap to separate sub-agents.
&lt;!-- --&gt;
&lt;!-- --&gt;IMPORTANT: if the user has already given you a task, you should proceed with that task using this approach.
&lt;!-- --&gt;
&lt;!-- --&gt;If you have not already been explicitly given a taks, you should ask the user what task they would like for you to work on - do not assume or begin working on a ticket automatically.&lt;/code&gt;&lt;/pre&gt;&lt;/pre&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;I found that using this skill in combination with our existing workflow skills helped me keep Opus coherent at longer context lengths. Why?
As I wrote about in that post, sub-agents encapsulate context and ensure that only highly-relevant context (the prompt, and the focused sub-agent result) end up in the context window, avoiding &lt;a href=&quot;https://research.trychroma.com/context-rot&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;context rot&lt;/a&gt;:&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/skill-issue/context-firewall.png&quot; alt=&quot;context firewall&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;How we&#39;re incorporating this at HumanLayer&lt;/h2&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;We have had a feature in the tool for a while that warns the user when they&#39;re context is getting high. We used to set this at around %40 of sonnets 168k token window (200k - 32k reserved for output). This came out to about 100k tokens.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;To help users maximize instruction adherence and intelligence on hard codebase problems, we&#39;ve updated our context warnings for long-context models to trigger at the 100k token mark instead of 40% of the usable context. For opus 1m this is only 10% of the context window.&lt;/p&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;TL;DR&lt;/h2&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ol class=&quot;list-decimal space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;Long-context models degrade at all context lengths, not just long ones.&lt;/li&gt;
&lt;li&gt;More context isn&#39;t more capability - the instruction budget doesn&#39;t scale with the context window.&lt;/li&gt;
&lt;li&gt;Context isolation beats context expansion. Sub-agents, progressive disclosure, and &lt;a href=&quot;https://www.humanlayer.dev/blog/context-efficient-backpressure&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;context-efficient backpressure&lt;/a&gt; keep each context window small, focused, and in the smart zone.&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;</description><link>https://www.humanlayer.dev/blog/long-context-isnt-the-answer</link><guid isPermaLink="false">https://www.humanlayer.dev/blog/long-context-isnt-the-answer</guid><pubDate>Sun, 22 Mar 2026 16:00:00 GMT</pubDate><author>Kyle</author><category>agents</category><category>claudecode</category><category>best-practices</category><category>context-engineering</category></item><item><title>Getting Claude to Actually Read Your CLAUDE.md</title><description>&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Claude Code wraps your CLAUDE.md in a &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;&amp;lt;system_reminder&amp;gt;&lt;/code&gt; that explicitly tells the model the contents &quot;may or may not be relevant.&quot; The longer your file gets, the more Claude seems to treat individual sections as optional.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;We &lt;a href=&quot;https://www.humanlayer.dev/blog/writing-a-good-claude-md&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;wrote before&lt;/a&gt; about keeping these files concise and avoiding stuff that belongs in a linter. But even after trimming things down, I kept running into cases where Claude would ignore testing instructions while writing tests, or skip our API conventions when building endpoints.&lt;/p&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;Conditional &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;&amp;lt;important if&amp;gt;&lt;/code&gt; blocks&lt;/h2&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;What&#39;s been working for me: wrapping sections in &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;&amp;lt;important if=&quot;condition&quot;&amp;gt;&lt;/code&gt; tags.&lt;/p&gt;
&lt;pre class=&quot;group&quot;&gt;&lt;pre class=&quot;prismjs rsh-code-block grid relative min-w-[250px] mb-6 bg-gray-400/5 p-4&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider border bg-transparent text-[var(--accent)] border-transparent hover:bg-[var(--accent)]/10 hover:border-[var(--accent)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-1 h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-10&quot; aria-label=&quot;Copy code&quot; title=&quot;Copy code&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-copy h-3 w-3&quot; aria-hidden=&quot;true&quot;&gt;&lt;rect width=&quot;14&quot; height=&quot;14&quot; x=&quot;8&quot; y=&quot;8&quot; rx=&quot;2&quot; ry=&quot;2&quot;&gt;&lt;/rect&gt;&lt;path d=&quot;M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;code class=&quot;overflow-x-auto&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;&quot;&gt;&amp;lt;important if=&quot;you are writing or modifying tests&quot;&amp;gt;
&lt;/span&gt;- Use `createTestApp()` helper for integration tests
&lt;!-- --&gt;- Mock database with `dbMock` from `packages/db/test`
&lt;!-- --&gt;- Test fixtures live in `__fixtures__/` directories
&lt;!-- --&gt;&amp;lt;/important&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;/pre&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;We don&#39;t have a rigorous explanation for why this helps. My guess is that the explicit condition gives Claude a clearer signal about when to apply the instructions, rather than leaving it to decide relevance on its own. Whatever the mechanism, we&#39;ve seen noticeably better adherence on tasks where only some sections of my CLAUDE.md should apply.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;A few things I&#39;ve learned:&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Don&#39;t wrap everything.&lt;/strong&gt; Project identity, directory structure, and tech stack are relevant to basically every task. The conditional blocks are for testing setup or deployment procedures that only matter sometimes.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Make conditions specific.&lt;/strong&gt; &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;&amp;lt;important if=&quot;you are writing code&quot;&amp;gt;&lt;/code&gt; matches almost everything and defeats the purpose. I try to make each condition narrow enough that it only fires when I actually want those rules applied.&lt;/p&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;A skill to automate this&lt;/h2&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;I did a lot of restructuring CLAUDE.md files by hand, so I made a Claude Code skill that does the rewrite. It pulls out the foundational stuff, wraps domain-specific sections in conditional blocks, and cleans up some common problems (stale code snippets, style rules that should be in a linter, vague instructions that don&#39;t actually help).&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;It&#39;s not perfect—you&#39;ll probably want to review what it produces—but it&#39;s a decent starting point.&lt;/p&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;Try it&lt;/h2&gt;
&lt;pre class=&quot;group&quot;&gt;&lt;pre class=&quot;prismjs rsh-code-block grid relative min-w-[250px] mb-6 bg-gray-400/5 p-4&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider border bg-transparent text-[var(--accent)] border-transparent hover:bg-[var(--accent)]/10 hover:border-[var(--accent)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-1 h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-10&quot; aria-label=&quot;Copy code&quot; title=&quot;Copy code&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-copy h-3 w-3&quot; aria-hidden=&quot;true&quot;&gt;&lt;rect width=&quot;14&quot; height=&quot;14&quot; x=&quot;8&quot; y=&quot;8&quot; rx=&quot;2&quot; ry=&quot;2&quot;&gt;&lt;/rect&gt;&lt;path d=&quot;M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;code class=&quot;overflow-x-auto&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;&quot;&gt;npx skills add humanlayer/skills --skill improve-claude-md&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/pre&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Then in your project:&lt;/p&gt;
&lt;pre class=&quot;group&quot;&gt;&lt;pre class=&quot;prismjs rsh-code-block grid relative min-w-[250px] mb-6 bg-gray-400/5 p-4&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider border bg-transparent text-[var(--accent)] border-transparent hover:bg-[var(--accent)]/10 hover:border-[var(--accent)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-1 h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-10&quot; aria-label=&quot;Copy code&quot; title=&quot;Copy code&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-copy h-3 w-3&quot; aria-hidden=&quot;true&quot;&gt;&lt;rect width=&quot;14&quot; height=&quot;14&quot; x=&quot;8&quot; y=&quot;8&quot; rx=&quot;2&quot; ry=&quot;2&quot;&gt;&lt;/rect&gt;&lt;path d=&quot;M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;code class=&quot;overflow-x-auto&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;&quot;&gt;/improve-claude-md&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/pre&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;It reads your existing CLAUDE.md and outputs a rewritten version. Source is at &lt;a href=&quot;https://github.com/humanlayer/skills/tree/main/plugins/improve-claude-md&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;github.com/humanlayer/skills&lt;/a&gt;.&lt;/p&gt;</description><link>https://www.humanlayer.dev/blog/stop-claude-from-ignoring-your-claude-md</link><guid isPermaLink="false">https://www.humanlayer.dev/blog/stop-claude-from-ignoring-your-claude-md</guid><pubDate>Mon, 16 Mar 2026 16:00:00 GMT</pubDate><author>Dex</author><category>agents</category><category>claudecode</category><category>skills</category></item><item><title>Skill Issue: Harness Engineering for Coding Agents</title><description>&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;We&#39;ve spent the past year watching coding agents fail in every conceivable way: ignoring instructions, executing dangerous commands un-prompted, and going in circles on the simplest of tasks.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;We&#39;ve seen teams ship immense amounts of slop. We&#39;ve even &lt;a href=&quot;https://www.youtube.com/live/99Kxkemj1g8?si=tVsK88M3XPyo0urD&amp;amp;t=20967&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;shipped a little bit of slop ourselves&lt;/a&gt;.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Every time, the instinct was the same:&lt;/p&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ul class=&quot;list-disc space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;&quot;We just need better models, GPT-6 will fix it&quot;&lt;/li&gt;
&lt;li&gt;&quot;We just need better instruction-following&quot;&lt;/li&gt;
&lt;li&gt;&quot;It&#39;ll work once [niche library I&#39;m using] is in the training data&quot;&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;But over the course of dozens of projects and hundreds of agent sessions, we kept arriving at the same conclusion: it&#39;s not a model problem. It&#39;s a &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;configuration problem&lt;/strong&gt;.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Yes, models will get smarter, and some existing failure modes will disappear. And then because they are smarter, we will give them new problems which are bigger and harder, and they will &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;continue to fail in unexpected ways&lt;/strong&gt;. Unexpected failures modes are a fundamental problem for non-deterministic systems.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/skill-issue/gpt-6.png&quot; alt=&quot;gpt-6&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;So instead of praying for &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;gpt-6.4-codex-ultrahigh_extended&lt;/code&gt; to save us all, we try to focus on answering the question of &lt;em style=&quot;color:var(--text-secondary)&quot;&gt;&quot;how do we get the most out of &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;today&#39;s&lt;/strong&gt; models?&quot;&lt;/em&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;There are lots of ways to get better performance out of your coding agent. If you use coding agents for moderately hard tasks, you&#39;ve probably configured your coding agent a bit. Have you used skills? MCP servers? Sub-agents? Memory? AGENTS.md files?&lt;/p&gt;
&lt;pre class=&quot;group&quot;&gt;&lt;pre class=&quot;prismjs rsh-code-block grid relative min-w-[250px] mb-6 bg-gray-400/5 p-4&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider border bg-transparent text-[var(--accent)] border-transparent hover:bg-[var(--accent)]/10 hover:border-[var(--accent)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-1 h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-10&quot; aria-label=&quot;Copy code&quot; title=&quot;Copy code&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-copy h-3 w-3&quot; aria-hidden=&quot;true&quot;&gt;&lt;rect width=&quot;14&quot; height=&quot;14&quot; x=&quot;8&quot; y=&quot;8&quot; rx=&quot;2&quot; ry=&quot;2&quot;&gt;&lt;/rect&gt;&lt;path d=&quot;M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;code class=&quot;overflow-x-auto&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;&quot;&gt;coding agent = AI model(s) + harness&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/pre&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;These are all technically separate concepts, but they are all part of the coding agent&#39;s configuration surface. We call this the &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;coding agent&#39;s harness&lt;/strong&gt;, and we think of it as &lt;a href=&quot;https://www.vtrivedy.com/posts/claude-code-sdk-haas-harness-as-a-service&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;the agent’s runtime&lt;/a&gt;, or as its peripherals: what does the model use to interact with its environment?&lt;/p&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;Harness Engineering&lt;/h2&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Harness engineering&lt;/strong&gt;, coined by &lt;a href=&quot;https://x.com/Vtrivedy10&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;Viv&lt;/a&gt;, describes the practice of leveraging these configuration points to customize and improve your coding agent&#39;s output quality and reliability.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/skill-issue/harness-components.png&quot; alt=&quot;harness components&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;
&lt;em style=&quot;color:var(--text-secondary)&quot;&gt;Image from &lt;a href=&quot;https://blog.langchain.com/the-anatomy-of-an-agent-harness/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;Viv&#39;s post&lt;/a&gt;&lt;/em&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;As &lt;a href=&quot;https://mitchellh.com/writing/my-ai-adoption-journey#step-5-engineer-the-harness&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;Mitchell Hashimoto put it&lt;/a&gt;, harness engineering&lt;/p&gt;
&lt;blockquote class=&quot;border-l-4 pl-4 my-4 italic&quot; style=&quot;border-color:var(--accent);color:var(--text-muted)&quot;&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;[...] is the idea that anytime you find an agent makes a mistake, you take the time to engineer a solution such that the agent never makes that mistake again.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;... as a Subset of Context Engineering&lt;/h2&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;We view harness engineering as a subset of &lt;a href=&quot;https://www.humanlayer.dev/blog/advanced-context-engineering&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;context engineering&lt;/a&gt;. Coined by my cofounder &lt;a href=&quot;https://x.com/dexhorthy&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;Dex&lt;/a&gt; in &lt;a href=&quot;https://github.com/humanlayer/12-factor-agents&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;12-factor agents&lt;/a&gt;, context engineering is a superset of “prompt engineering” and a variety of other techniques for systematically improving AI agents’ reliability.&amp;nbsp;You can find the original talk on &lt;a href=&quot;https://www.youtube.com/watch?v=IS_y40zY-hc&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Harness engineering then is the subset of context engineering which primarily involves leveraging harness configuration points to carefully manage the context windows of coding agents.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/skill-issue/harness-engineering.png&quot; alt=&quot;harness engineering as context engineering&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;It answers:&lt;/p&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ul class=&quot;list-disc space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;How do we give our coding agent new capabilities?&lt;/li&gt;
&lt;li&gt;How do we teach it things about our codebase that aren’t in the training data?&lt;/li&gt;
&lt;li&gt;How do we add determinism beyond &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;CRITICAL: always do XYZ&lt;/code&gt; in the system message?&lt;/li&gt;
&lt;li&gt;How do we adapt the agent’s behavior for our specific codebase?&lt;/li&gt;
&lt;li&gt;How do we increase task success rates beyond “magic prompts”?&lt;/li&gt;
&lt;li&gt;How do we prevent our context window from inflating too rapidly, or with too much bad context?&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Skills, MCP servers, sub-agents, hooks, and back-pressure mechanisms are all tactical solutions we’ve arrived at.&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;Views on Harness Engineering&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Viv’s posts on harness engineering are worth reading alongside this one — &lt;a href=&quot;https://www.vtrivedy.com/posts/claude-code-sdk-haas-harness-as-a-service&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;the first&lt;/a&gt; frames the four customization levers (system prompt, tools/MCPs, context, sub-agents), and &lt;a href=&quot;https://blog.langchain.com/the-anatomy-of-an-agent-harness/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;the second&lt;/a&gt; works backwards from what models &lt;em style=&quot;color:var(--text-secondary)&quot;&gt;can’t&lt;/em&gt; do natively to derive why each harness component exists.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/skill-issue/backwards.png&quot; alt=&quot;working backwards from what models can&#39;t do natively&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;
&lt;em style=&quot;color:var(--text-secondary)&quot;&gt;Image from &lt;a href=&quot;https://blog.langchain.com/the-anatomy-of-an-agent-harness/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;Viv&#39;s post&lt;/a&gt;&lt;/em&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;We’d add two levers he doesn’t emphasize:&lt;/p&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ol class=&quot;list-decimal space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;hooks&lt;/strong&gt; for automated integration and deterministic control flow&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;skills&lt;/strong&gt; for progressive disclosure of knowledge. (Dex likes to refer to them as &quot;Instruction Modules&quot; - more on this in another post.)&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;After months of solving hard problems in complex brownfield enterprise-scale codebases, we have found that sub-agents are a particularly powerful lever. When working on hard problems that require many, many context windows to solve, &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;sub-agents are the key to maintaining coherency across many sessions&lt;/strong&gt;. Sub-agents &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;function as a &quot;context firewall&quot;&lt;/strong&gt; that ensures discrete tasks can run in isolated context windows so none of the intermediate noise accumulates in your parent thread which is responsible for orchestration, and you can maintain coherency for much, much longer.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/skill-issue/context-firewall.png&quot; alt=&quot;context firewall&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;OpenAI recently wrote a &lt;a href=&quot;https://openai.com/index/harness-engineering/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;blog post&lt;/a&gt; on the topic as well. There&#39;s some great content in there, and it seems to indicate that they view harness engineering as configuring everything &lt;em style=&quot;color:var(--text-secondary)&quot;&gt;outside&lt;/em&gt; of the agent&#39;s runtime. It&#39;s more focused on back-pressure and verification mechanisms. (Although this may be a mis-reading; the post is somewhat unclear: the word &quot;harness&quot; only appears once in the text of the post, and in reference to evals rather than harness engineering itself.)&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;But What About Post-Training?&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Given that frontier coding models are post-trained on their harnesses (e.g. Claude in Claude Code, GPT-5 Codex in Codex), some will argue that the best harness and/or configuration is the one that the model was trained on.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;For example, the Codex models are so tightly coupled with the Codex harness&#39;s &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;apply_patch&lt;/code&gt; tool that &lt;a href=&quot;https://opencode.ai/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;OpenCode&lt;/a&gt; — built as an open-source alternative to Claude Code — had to &lt;a href=&quot;https://github.com/anomalyco/opencode/pull/9127&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;add an &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;apply_patch&lt;/code&gt; tool&lt;/a&gt; specifically for GPT/Codex models to mimic the Codex harness to improve the Codex models&#39; performance in the OpenCode harness - while Claude and other models still use normal &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;edit&lt;/code&gt; and &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;write&lt;/code&gt; tools.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;This &lt;em style=&quot;color:var(--text-secondary)&quot;&gt;can&lt;/em&gt; mean that a model will perform better when coupled with the harness it was post-trained on, and some might infer that this means you shouldn&#39;t customize the harness at all.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;But it cuts both ways: &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;models can be over-fitted to their harness&lt;/strong&gt;. Viv cites &lt;a href=&quot;https://terminalbench.com/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;Terminal Bench 2.0&lt;/a&gt; where Opus 4.6 in Claude Code comes in position #33, but when placed in a different harness that wasn&#39;t seen during post-training, it comes in at #5 (+/- about 4 positions in either direction).&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/skill-issue/terminal-bench.png&quot; alt=&quot;terminal bench&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;Engineering Your Harness&lt;/h2&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;With that in mind, let&#39;s walk through the configuration surfaces we&#39;ve found most impactful.&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;CLAUDE.md &amp;amp; AGENTS.md&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Before touching any other harness configuration points, it&#39;s usually worth customizing your CLAUDE.md / AGENTS.md files. These are markdown files at the top-level of your repository that get deterministically injected into the agent&#39;s system prompt by the harness.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;We have already shared &lt;a href=&quot;https://www.humanlayer.dev/blog/writing-a-good-claude-md&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;some opinions about what makes a good CLAUDE.md&lt;/a&gt; file and how to use it correctly, so give that a read if you&#39;re not familiar with it. Matt Pocock also wrote a &lt;a href=&quot;https://www.aihero.dev/a-complete-guide-to-agents-md&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;great follow-up&lt;/a&gt; that more generally applies to AGENTS.md.&lt;/p&gt;
&lt;h4 class=&quot;text-xl mb-1 mt-8 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;#### &lt;!-- --&gt;The ETH Zurich Study&lt;/h4&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;After ETH Zurich published their &lt;a href=&quot;https://arxiv.org/abs/2602.11988&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;study testing 138 agentfiles across various repos&lt;/a&gt; which indicated that most agentfiles were useless-or-worse, we got a lot of feedback on our &lt;a href=&quot;https://www.humanlayer.dev/blog/writing-a-good-claude-md&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;CLAUDE.md post&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote class=&quot;border-l-4 pl-4 my-4 italic&quot; style=&quot;border-color:var(--accent);color:var(--text-muted)&quot;&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;See, CLAUDE.md files don&#39;t even help — they&#39;re a waste of time.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Indeed: the study tested many agentfiles across a wide variety of repos, and found:&lt;/p&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ul class=&quot;list-disc space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;that LLM-generated ones actually &lt;em style=&quot;color:var(--text-secondary)&quot;&gt;hurt&lt;/em&gt; performance while costing 20%+ more&lt;/li&gt;
&lt;li&gt;human-written ones only helped about 4%.&lt;/li&gt;
&lt;li&gt;Agents spent 14-22% more reasoning tokens processing context file instructions, took more steps to complete tasks, and ran more tools — all without improving resolution rates.&lt;/li&gt;
&lt;li&gt;Codebase overviews and directory listings didn&#39;t help at all; agents discover repository structure on their own just fine.&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;A careful reading of the study &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;indicates that what we said in our post was correct:&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ul class=&quot;list-disc space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Agent-generated files were worse. Yes, we said:&lt;/p&gt;
&lt;blockquote class=&quot;border-l-4 pl-4 my-4 italic&quot; style=&quot;border-color:var(--accent);color:var(--text-muted)&quot;&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;avoid auto-generating it. You should carefully craft its contents for best results.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Lots of files too-heavily-steered the model to use specific tools, causing worse outcomes. Yep, we said:&lt;/p&gt;
&lt;blockquote class=&quot;border-l-4 pl-4 my-4 italic&quot; style=&quot;border-color:var(--accent);color:var(--text-muted)&quot;&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Less (instructions) is more. While you shouldn&#39;t omit necessary instructions, you should include as few instructions as reasonably possible in the file.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Files contained irrelevant context. Yep, we said:&lt;/p&gt;
&lt;blockquote class=&quot;border-l-4 pl-4 my-4 italic&quot; style=&quot;border-color:var(--accent);color:var(--text-muted)&quot;&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Use Progressive Disclosure&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;The human-written ones barely helped because of too many conditional rules. Yep, we said:&lt;/p&gt;
&lt;blockquote class=&quot;border-l-4 pl-4 my-4 italic&quot; style=&quot;border-color:var(--accent);color:var(--text-muted)&quot;&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Keep the contents of your CLAUDE.md concise and universally applicable.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Our CLAUDE.md is under 60 lines.&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;MCP Servers Are for Tools&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;MCP servers are&amp;nbsp;primarily for plugging tools into your coding agent to extend its capabilities beyond file I/O and bash commands. The MCP specification includes additional features like resources, prompts, and elicitations, but &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;these are generally not well-supported by MCP clients and coding agent harnesses&lt;/strong&gt;.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;The MCP spec supports servers that run on your (or the agent&#39;s) local machine which allow the agent to interact with its local environment, but it also supports HTTP-based MCP servers that can connect your agent with remote tools and services like Linear, Sentry, and more.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;When you plug an MCP server into your coding agent, the list of available tools, their descriptions, and the arguments needed to invoke them &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;are injected into your coding agent&#39;s system prompt&lt;/strong&gt;. As a result, the MCP server can use the tool descriptions to customize your agent’s behavior by providing your agent with instructions about when to use them.&amp;nbsp;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;WARNING&lt;/strong&gt;: because MCP servers’ tool descriptions are added to your coding agent’s system prompt, never connect to one you don’t trust. This can be a dangerous vector for prompt injection! STDIO servers and other servers that run client-side with npx or uvx can also execute code on your host in the absence of prompt injection.&lt;/p&gt;
&lt;h4 class=&quot;text-xl mb-1 mt-8 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;#### &lt;!-- --&gt;Too Many Tools Is Bad&lt;/h4&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;We’ve seen this firsthand: plug too many MCP tools into your agent, and the context window fills up with tool descriptions, pushing you into &lt;a href=&quot;https://youtu.be/rmvDxxNubIg?si=O17nmS3SScaAkpp-&amp;amp;t=355&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;the dumb zone&lt;/a&gt; much faster:&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/skill-issue/too-many-tools.png&quot; alt=&quot;too many tools&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;The &lt;a href=&quot;https://www.aihero.dev/a-complete-guide-to-agents-md#the-instruction-budget&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;instruction budget&lt;/a&gt; matters too — every irrelevant tool description is an instruction the agent has to process without any benefit.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;In fact, these failure modes are so common that Anthropic released &lt;a href=&quot;https://platform.claude.com/docs/en/agents-and-tools/tool-use/tool-search-tool&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;experimental support for MCP tool search&lt;/a&gt; to progressively disclose tools to Claude when the user has too many MCP tools connected. TL;DR: if you’re not actively using a server which provides a large number of tools, turn it off.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;We also found that if an MCP server duplicates functionality that’s already available as a CLI well-represented in training data, it works better to just prompt the agent to use the CLI. For things like GitHub, Docker, or most databases, your coding agent can just use the right CLIs and shell commands. The model has seen these tools enough during training that it already knows how to use them, and you gain the added benefit of composability with tools like &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;grep&lt;/code&gt; and &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;jq&lt;/code&gt; to enable additional context-efficiency.&lt;/p&gt;
&lt;h4 class=&quot;text-xl mb-1 mt-8 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;#### &lt;!-- --&gt;Always Be Context-Engineering&lt;/h4&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;At HumanLayer, we used the Linear MCP server for a while before realizing that we really only used a small subset of the tools it provides - so we wrote a small CLI that wraps the Linear API and provides very context-efficient responses, and we included 6 example usages in our &lt;a href=&quot;https://www.humanlayer.dev/blog/writing-a-good-claude-md&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;CLAUDE.md&lt;/a&gt; file:&lt;/p&gt;
&lt;pre class=&quot;group&quot;&gt;&lt;pre class=&quot;prismjs rsh-code-block grid relative min-w-[250px] mb-6 bg-gray-400/5 p-4&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider border bg-transparent text-[var(--accent)] border-transparent hover:bg-[var(--accent)]/10 hover:border-[var(--accent)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-1 h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-10&quot; aria-label=&quot;Copy code&quot; title=&quot;Copy code&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-copy h-3 w-3&quot; aria-hidden=&quot;true&quot;&gt;&lt;rect width=&quot;14&quot; height=&quot;14&quot; x=&quot;8&quot; y=&quot;8&quot; rx=&quot;2&quot; ry=&quot;2&quot;&gt;&lt;/rect&gt;&lt;path d=&quot;M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;code class=&quot;overflow-x-auto&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;&quot;&gt;## Linear
&lt;/span&gt;
&lt;!-- --&gt;Use the Linear CLI for:
&lt;!-- --&gt;
&lt;!-- --&gt;- **fetching issues**: `linear get-issue ENG-XXXX`
&lt;!-- --&gt;- **listing issues**: `linear list-issues` or `linear my-issues`
&lt;!-- --&gt;- **adding comments**: `linear add-comment -i ENG-XXXX &quot;comment&quot;`
&lt;!-- --&gt;- **adding links**: `linear add-link ENG-XXXX &quot;url&quot; -t &quot;link title&quot;`
&lt;!-- --&gt;- **updating status**: `linear update-status ENG-XXXX &quot;status name&quot;` (&quot;spec needed&quot;, &quot;research needed&quot;, &quot;research in progress&quot;, &quot;research in review&quot;, &quot;ready for plan&quot;, &quot;plan in progress&quot;, &quot;plan in review&quot;, &quot;ready for dev&quot;, &quot;in dev&quot;, &quot;code review&quot;)
&lt;!-- --&gt;- **get branch name**: `linear get-issue-v2 ENG-XXXX --fields branch` (use this when creating a worktree)
&lt;!-- --&gt;- **get images from the ticket**: `linear fetch-images ENG-XXXX` (do this any time the ticket has images in the description)&lt;/code&gt;&lt;/pre&gt;&lt;/pre&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;This saved us thousands of tokens from the MCP server&#39;s tool definitions that were ending up in our agent’s system prompt, and many more from the verbose MCP server responses.&amp;nbsp;&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;Skills Are for Reusable Knowledge (and Tools)&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Skills were originally introduced by Anthropic for use with Claude Code, but have since become an open standard supported by other harnesses like Codex and OpenCode. You can read about how they&#39;re structured in &lt;a href=&quot;https://platform.claude.com/docs/en/agents-and-tools/agent-skills/overview&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;the Anthropic docs&lt;/a&gt; — what matters here is &lt;em style=&quot;color:var(--text-secondary)&quot;&gt;why&lt;/em&gt; they&#39;re useful.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Before we go further: skill registries have already been caught &lt;a href=&quot;https://www.esecurityplanet.com/threats/hundreds-of-malicious-skills-found-in-openclaws-clawhub/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;distributing hundreds of malicious skills&lt;/a&gt;. Treat skills like you&#39;d treat &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;npm install random-package&lt;/code&gt; — read what you&#39;re installing. Registries like &lt;a href=&quot;https://docs.openclaw.ai/tools/clawhub&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;ClawHub&lt;/a&gt; and &lt;a href=&quot;https://skills.sh/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;skills.sh&lt;/a&gt; can execute arbitrary code on your machine.&lt;/p&gt;
&lt;h4 class=&quot;text-xl mb-1 mt-8 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;#### &lt;!-- --&gt;Progressive Disclosure&lt;/h4&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;We learned this one early: we kept stuffing every instruction and tool into the system prompt, and the agent kept getting worse. We were blowing through our &lt;a href=&quot;https://www.aihero.dev/a-complete-guide-to-agents-md#the-instruction-budget&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;instruction budget&lt;/a&gt; before the agent even started working. Skills solve this through &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;progressive disclosure&lt;/strong&gt; — the agent only gets access to specific instructions, knowledge, or tools when it decides (or you decide for it) that it needs them.&lt;/p&gt;
&lt;h4 class=&quot;text-xl mb-1 mt-8 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;#### &lt;!-- --&gt;Skill Activation&lt;/h4&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;When a skill is activated, the &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;SKILL.md&lt;/code&gt; file in the skill&#39;s directory is loaded into the agent&#39;s context window as a user message, and the agent is informed of the directory that the skill file was loaded from. The &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;SKILL.md&lt;/code&gt; file may inform the agent of anything else it&#39;s bundled with:&lt;/p&gt;
&lt;pre class=&quot;group&quot;&gt;&lt;pre class=&quot;prismjs rsh-code-block grid relative min-w-[250px] mb-6 bg-gray-400/5 p-4&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider border bg-transparent text-[var(--accent)] border-transparent hover:bg-[var(--accent)]/10 hover:border-[var(--accent)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-1 h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-10&quot; aria-label=&quot;Copy code&quot; title=&quot;Copy code&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-copy h-3 w-3&quot; aria-hidden=&quot;true&quot;&gt;&lt;rect width=&quot;14&quot; height=&quot;14&quot; x=&quot;8&quot; y=&quot;8&quot; rx=&quot;2&quot; ry=&quot;2&quot;&gt;&lt;/rect&gt;&lt;path d=&quot;M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;code class=&quot;overflow-x-auto&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;&quot;&gt;example-skill/
&lt;/span&gt;|--- SKILL.md
&lt;!-- --&gt;|--- response_template.md
&lt;!-- --&gt;|--- CLIs/
&lt;!-- --&gt;   |--- linear-cli
&lt;!-- --&gt;   |--- tunnel-cli&lt;/code&gt;&lt;/pre&gt;&lt;/pre&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Since each skill has its own directory, you can get even more creative with progressive disclosure: you might bundle several markdown files in the skill, each of which contains different information about different functionalities or for different purposes, and the main &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;SKILL.md&lt;/code&gt; file can tell the agent what the other files in the skill are and if/when it should read them.&lt;/p&gt;
&lt;h4 class=&quot;text-xl mb-1 mt-8 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;#### &lt;!-- --&gt;Distributing Tools with Skills&lt;/h4&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Unfortunately, it&#39;s not possible to bundle MCP servers or custom agent tools directly into a skill - you have to write them into an executable, a CLI, an NPM package, or something else which you can either distribute with your skill or instruct the agent to install in the skill file.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;For example, instead of configuring a Playwright MCP server, you could just provide your agent with a skill for web browsing using BrowserBase&#39;s &lt;a href=&quot;https://github.com/browserbase/skills&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;agent browser skills&lt;/a&gt; or Vercel&#39;s &lt;a href=&quot;https://github.com/vercel-labs/agent-browser&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;agent browser CLI&lt;/a&gt;.&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;Sub-Agents Are for Context Control&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Sub-agents are a popular but often misunderstood harness configuration point. We tried the &quot;frontend engineer&quot; sub-agent and &quot;backend engineer&quot; sub-agent and &quot;data analyst&quot; sub-agent thing. It doesn&#39;t work. What does work is using sub-agents for &lt;a href=&quot;https://www.humanlayer.dev/blog/advanced-context-engineering&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;context control&lt;/a&gt;.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;They provide a way to encapsulate an entire coding agent session&#39;s worth of work such that the dispatching agent only sees the prompt it writes for the sub-agent, and the sub-agent&#39;s final result. None of the intermediate tool calls, tool results, or other messages end up in the parent coding agent&#39;s context window.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/skill-issue/sub-agents.png&quot; alt=&quot;sub-agents&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Breaking work up into discrete tasks and delegating it to sub-agents is how we keep our primary coding agent thread in the &quot;smart zone.&quot; This is how we handle research, implementation, and a number of other context-heavy tasks in our day-to-day workflows.&lt;/p&gt;
&lt;h4 class=&quot;text-xl mb-1 mt-8 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;#### &lt;!-- --&gt;Sub-Agents Avoid Context Rot&lt;/h4&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Chroma&#39;s &lt;a href=&quot;https://research.trychroma.com/context-rot&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;context rot research&lt;/a&gt; provides empirical backing to what we&#39;ve been saying for a long time: models perform worse at longer context lengths. &lt;a href=&quot;https://youtu.be/rmvDxxNubIg?si=O17nmS3SScaAkpp-&amp;amp;t=355&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;Avoid the dumb zone&lt;/a&gt;.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Chroma researchers tested 18 models on needle-in-a-haystack tasks, which is admittedly quite different from agentic coding. But the finding matches our experience exactly: performance degrades as context length increases — even on simple tasks.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Worse, when there&#39;s low semantic similarity between the question and the relevant information in context, the degradation is &lt;em style=&quot;color:var(--text-secondary)&quot;&gt;steeper&lt;/em&gt;. We’ve watched this happen in real time: every intermediate tool call, every grep result, every file read in the parent session that doesn’t end up being relevant is a potential distractor, and the Chroma research confirms that distractor effects &lt;em style=&quot;color:var(--text-secondary)&quot;&gt;compound&lt;/em&gt; at longer context windows.&lt;/p&gt;
&lt;h4 class=&quot;text-xl mb-1 mt-8 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;#### &lt;!-- --&gt;Aside: Long-Context Models&lt;/h4&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;This is also why we&#39;re skeptical of the &quot;just make the context window bigger&quot; approach to coding agents. When a lab offers an extended-context version of a given model, you are usually not getting a bigger model with a larger &quot;instruction budget&quot; - you&#39;re getting the same model with some clever math (e.g. &lt;a href=&quot;https://arxiv.org/pdf/2309.00071&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;YaRN&lt;/a&gt;) to extend the length of the sequence the model can attend to.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Consider the needle-in-a-haystack problem. A bigger context window doesn&#39;t make the model better at finding the needle — it just makes the haystack bigger. For our purposes, it means you can stuff more instructions (each user message is &lt;em style=&quot;color:var(--text-secondary)&quot;&gt;at least&lt;/em&gt; one instruction, and usually several) into the context window - putting you deeper and deeper into the &quot;dumb zone&quot;.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/skill-issue/long-context.jpg&quot; alt=&quot;long context&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;If you think you need longer context, you may just need better context window isolation. Sub-agents solve this structurally: each one gets a fresh, small, high-relevance context window with a fresh &quot;instruction budget&quot; for its task, and only the condensed result flows back to the parent - allowing you to stitch together many context windows for a single problem.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;The limit case probably looks something like this, although at some point you&#39;re crossing &lt;a href=&quot;https://alexzhang13.github.io/blog/2025/rlm/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;Recursive Language Model&lt;/a&gt; territory.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/skill-issue/limit-case.png&quot; alt=&quot;limit case&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;(Note: some arrows omitted for brevity.)&lt;/p&gt;
&lt;h4 class=&quot;text-xl mb-1 mt-8 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;#### &lt;!-- --&gt;Sub-Agent Use-Cases&lt;/h4&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Great examples of things to use sub-agents for include:&lt;/p&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ul class=&quot;list-disc space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;Locating specific definitions or implementations in the codebase&lt;/li&gt;
&lt;li&gt;Analyzing the codebase to identify patterns for a specific type of work&lt;/li&gt;
&lt;li&gt;Tracing the flow of information through the codebase, e.g. tracing a request across service boundaries&lt;/li&gt;
&lt;li&gt;Other general code/documentation/web research tasks&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;These types of tasks often have a straightforward question and simple answer, but require lots of intermediate tool calls that you don&#39;t want or need in your parent session. Sub-agents should return highly condensed responses that also follow the principle of progressive disclosure. For example, our sub-agents provide an answer to the question but also cite sources in &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;filepath:line&lt;/code&gt; format or with URLs so that the parent agent isn&#39;t exposed to all the sources the sub-agent used, but if it needs more details or confirmation, it has the information that it needs to go find the relevant context:&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/skill-issue/compaction.png&quot; alt=&quot;compaction&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Dex spoke about this more extensively &lt;a href=&quot;https://www.youtube.com/watch?v=IS_y40zY-hc&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Claude Code and some other coding agents even provide built-in, task-specific sub-agents, e.g. Claude Code&#39;s &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;Explore&lt;/code&gt; sub-agent for codebase exploration, or their &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;Bash&lt;/code&gt; sub-agent which is designed to execute verbose bash commands and extract information to return to the parent agent without polluting its context. Other coding agents support sub-agents but don&#39;t define their own, and require that the user manually configure them if desired.&lt;/p&gt;
&lt;h4 class=&quot;text-xl mb-1 mt-8 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;#### &lt;!-- --&gt;Sub-Agents Are (Also) for Cost Control&lt;/h4&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Sub-agents can also help with cost control. We use an expensive model (Opus) for the parent session where thinking-heavy tasks like planning and orchestration happen, and a cheaper, faster model like Sonnet or Haiku for each sub-agent. Sub-agents receive much smaller and more discrete tasks that can be handled by a less-intelligent model with a smaller &quot;instruction budget&quot; — no need to burn Opus tokens on a codebase grep.&lt;/p&gt;
&lt;h4 class=&quot;text-xl mb-1 mt-8 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;#### &lt;!-- --&gt;So We Heard You Like Sub-Agents&lt;/h4&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Some harnesses don&#39;t support sub-agents at all! Even Codex didn&#39;t until recently, and support is still &lt;a href=&quot;https://developers.openai.com/codex/multi-agent/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;experimental&lt;/a&gt;.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Fortunately you can still use this powerful context encapsulation pattern by writing an MCP server that provides a tool for launching a new agent session which receives a prompt from the parent agent, launches a new coding agent session with that prompt as the user message, and which returns the sub-agent&#39;s final response message to the parent.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;A &lt;em style=&quot;color:var(--text-secondary)&quot;&gt;very&lt;/em&gt; rough approximation of a server to do this can be found &lt;a href=&quot;https://github.com/humanlayer/claudelayer/blob/main/src/index.ts&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;here&lt;/a&gt;. &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Warning&lt;/strong&gt;: using this pattern with a coding agent that supports sub-agents will allow the harness&#39;s native sub-agents to dispatch sub-agents via MCP. This can result in an unpredictable game of telephone:&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/skill-issue/sub-agent-telephone.png&quot; alt=&quot;telephone&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Jokes aside, practically you have to be very careful when you write your sub-agents&#39; system prompts to carefully specify the scope of their role:&lt;/p&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ul class=&quot;list-disc space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;What is the agent&#39;s role - what should it do, but also what should it &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;not&lt;/strong&gt; do&lt;/li&gt;
&lt;li&gt;What information should the agent return, and &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;how&lt;/strong&gt; should it return it&lt;/li&gt;
&lt;li&gt;What tools should the sub-agent have?&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;It&#39;s also worth noting that many harnesses have an MCP tool call timeout - if you implement this pattern, you may need to configure your harness to increase the MCP tool call timeout.&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;Hooks Are for Control Flow&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Claude Code has the concept of &lt;a href=&quot;https://code.claude.com/docs/en/hooks&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;hooks&lt;/a&gt;: user-defined commands or scripts that are automatically executed when certain events occur and at various points of the agent&#39;s lifecycle. Similarly, &lt;a href=&quot;https://opencode.ai/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;Opencode&lt;/a&gt; has the concept of &lt;a href=&quot;https://opencode.ai/docs/plugins/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;plugins&lt;/a&gt; which do the same thing. Other coding agents may have similar configuration points. (Sadly, Codex &lt;a href=&quot;https://github.com/openai/codex/discussions/2150&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;doesn&#39;t have an equivalent&lt;/a&gt;.)&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Hooks are conceptually similar to &lt;a href=&quot;https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;git hooks&lt;/a&gt;, but they&#39;re &lt;a href=&quot;https://karanbansal.in/blog/claude-code-hooks/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;quite flexible&lt;/a&gt;. They can be used to add new features, integrate with external services, automate routine actions, modify permissions, and configure default behavior.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Implementation details vary between harnesses, but generally a hook can:&lt;/p&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ul class=&quot;list-disc space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;run something automatically but silently when an event occurs&lt;/li&gt;
&lt;li&gt;run when a tool is called, and return additional context to the agent in addition to the tool result&lt;/li&gt;
&lt;li&gt;surface build/type errors to a coding agent before it finishes, so that it&#39;s forced to keep working until it resolves the error&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Common use cases include...&lt;/p&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ul class=&quot;list-disc space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Notifications&lt;/strong&gt;: We wire our agents up to play sounds when they finish or when they need attention (e.g. an approval has been pending for too long)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Approvals&lt;/strong&gt;: We automatically approve or deny tool calls based on input values and more expressive rules than the coding agent’s default permissions model. For example, we automatically deny any &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;Bash()&lt;/code&gt; tool calls that try to run migrations, with an instruction to ask the user to run them instead.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Integrations&lt;/strong&gt;: We have our agents send a Slack message when they’re finished, create a GitHub PR, or set up a preview environment.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Verification&lt;/strong&gt;: If your framework and repository can run a typecheck or build in under a handful of seconds, run it every time the agent stops to surface errors to it — this is exactly what the hook below does.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;
&lt;h4 class=&quot;text-xl mb-1 mt-8 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;#### &lt;!-- --&gt;An Example Hook&lt;/h4&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Here&#39;s a hook I (via Claude) wrote for our repo which implements the last example I gave. When Claude stops, it runs our biome formatter and TypeScript type checks. If there are errors, they are raised to Claude. If not, the script exits silently.&lt;/p&gt;
&lt;pre class=&quot;group&quot;&gt;&lt;pre class=&quot;prismjs rsh-code-block grid relative min-w-[250px] mb-6 bg-gray-400/5 p-4&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider border bg-transparent text-[var(--accent)] border-transparent hover:bg-[var(--accent)]/10 hover:border-[var(--accent)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-1 h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-10&quot; aria-label=&quot;Copy code&quot; title=&quot;Copy code&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-copy h-3 w-3&quot; aria-hidden=&quot;true&quot;&gt;&lt;rect width=&quot;14&quot; height=&quot;14&quot; x=&quot;8&quot; y=&quot;8&quot; rx=&quot;2&quot; ry=&quot;2&quot;&gt;&lt;/rect&gt;&lt;path d=&quot;M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;code class=&quot;overflow-x-auto&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;token shebang important&quot;&gt;#!/bin/bash&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token string variable&quot;&gt;$CLAUDE_PROJECT_DIR&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;# prebuild generates types and builds internal SDK packages so typecheck has&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;# everything it needs. runs bun install afterward to pick up any new generated files.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token assign-left variable&quot;&gt;PREBUILD_OUTPUT&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;bun run generate-cache-key &lt;/span&gt;&lt;span class=&quot;token variable operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt; turbo run build --filter&lt;/span&gt;&lt;span class=&quot;token variable operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;@humanlayer/hld-sdk &lt;/span&gt;&lt;span class=&quot;token variable operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt; bun &lt;/span&gt;&lt;span class=&quot;token variable function&quot;&gt;install&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token variable operator file-descriptor important&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token variable operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token variable file-descriptor important&quot;&gt;&amp;amp;1&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$?&lt;/span&gt;&lt;span class=&quot;&quot;&gt; -ne &lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;prebuild failed:&quot;&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token file-descriptor important&quot;&gt;&amp;amp;2&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token string variable&quot;&gt;$PREBUILD_OUTPUT&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token file-descriptor important&quot;&gt;&amp;amp;2&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;exit&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;fi&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;# biome and typecheck run in parallel to keep the feedback loop tight.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;# one quirk: biome --write exits with code 1 if it made any changes, even if it&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;# successfully fixed everything. so we run it twice with ||: if the first pass&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;# makes changes and exits 1, the second pass will exit 0 since there&#39;s nothing&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;# left to fix. if there are unfixable errors, both passes fail and exit 2.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token assign-left variable&quot;&gt;OUTPUT&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;bun run --parallel &lt;/span&gt;&lt;span class=&quot;token variable punctuation&quot;&gt;\&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token variable string&quot;&gt;&quot;biome check . --write --unsafe || biome check . --write --unsafe&quot;&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token variable punctuation&quot;&gt;\&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token variable string&quot;&gt;&quot;turbo run typecheck&quot;&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token variable operator file-descriptor important&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token variable operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token variable file-descriptor important&quot;&gt;&amp;amp;1&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$?&lt;/span&gt;&lt;span class=&quot;&quot;&gt; -ne &lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token string variable&quot;&gt;$OUTPUT&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token file-descriptor important&quot;&gt;&amp;amp;2&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;exit&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;fi&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/pre&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;On success the hook is completely silent — nothing ends up in the agent&#39;s context. On failure, only the errors are surfaced, and exit code &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;2&lt;/code&gt; tells the harness to re-engage the agent so it fixes them before finishing.&lt;/p&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;Back-Pressure Increases Your Chances of Success&lt;/h2&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;We&#39;ve &lt;a href=&quot;https://www.humanlayer.dev/blog/context-efficient-backpressure&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;written about back-pressure before&lt;/a&gt;. The core insight is that your likelihood of successfully solving a problem with a coding agent is strongly correlated with the agent&#39;s ability to verify its own work. We&#39;ve spent a lot of time building out tests and other back-pressure mechanisms into our repository, and it remains one of the &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;highest-leverage things we have spent time on&lt;/strong&gt;.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Our codebase has verification mechanisms that allow the agent to check its own work:&lt;/p&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ul class=&quot;list-disc space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;typechecks and build steps (&lt;a href=&quot;https://arxiv.org/pdf/2504.09246&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;probably in a strongly-typed language&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;unit tests and/or integration tests&lt;/li&gt;
&lt;li&gt;code coverage reporting (we have a &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;Stop&lt;/code&gt; hook that prompts the agent to increase coverage if it drops)&lt;/li&gt;
&lt;li&gt;UI interaction and testing integrations (playwright, &lt;a href=&quot;https://github.com/vercel-labs/agent-browser&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;agent-browser&lt;/a&gt;, etc)&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Critically, these verification mechanisms need to be &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;context-efficient.&lt;/strong&gt; We learned this one the hard way — early on we had our agent run the full test suite after every change, and 4,000 lines of passing tests would flood the context window. The agent would then lose track of the actual task and start hallucinating about test files it had just read. Now we &lt;a href=&quot;https://www.humanlayer.dev/blog/context-efficient-backpressure&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;swallow the output and only surface errors&lt;/a&gt;. We do the same with builds — success is silent, and only failures produce verbose output.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;We give Claude &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;concise&lt;/strong&gt; instructions about how to use all of these mechanisms in our CLAUDE.md file. Some are even bundled inside skills for &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;progressive disclosure&lt;/strong&gt;.&lt;/p&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;Closing Notes&lt;/h2&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;It is entirely possible to spend more time optimizing your coding agent setup than actually shipping code with it — we’ve been there.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Our approach: bias towards shipping. We only spend time on harness configuration to the extent that it’s actually enabling us to ship more high-quality code faster. When the agent fails, we take the time to engineer a solution so it doesn’t fail that way again — but we don’t go looking for problems to solve preemptively.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;What didn’t work for us:&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ul class=&quot;list-disc space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;Trying to design the ideal harness configuration upfront before we’d even hit real failures&lt;/li&gt;
&lt;li&gt;Installing dozens of skills and MCP servers &quot;just in case&quot;&lt;/li&gt;
&lt;li&gt;Running our entire test suite (5+ minutes) at the end of every agent session (run a subset instead)&lt;/li&gt;
&lt;li&gt;Trying to micro-optimize which sub-agents could access which tools. This led to a lot of tool thrash which gave us worse results, not better ones. Most coding agents don&#39;t have a robust configuration surface for this anyways.&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;What did work:&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ul class=&quot;list-disc space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;Starting simple and adding configuration only when the agent actually failed&lt;/li&gt;
&lt;li&gt;Designing, testing, iterating — and throwing away things that didn’t help. I have thrown away many more hooks than we actually use today.&lt;/li&gt;
&lt;li&gt;Distributing battle-tested configurations to the whole team via repository-level config&lt;/li&gt;
&lt;li&gt;Optimizing for iteration speed, not &quot;likelihood of 1-shotting it on the first attempt&quot;&lt;/li&gt;
&lt;li&gt;Giving the agent a set of capabilities (Linear) and then carefully paring down what we exposed to the model once we knew what we needed.&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;The next time your coding agent isn’t performing the way you expect, before you blame the model, check the harness. Agentfiles, MCP servers, skills, sub-agents, hooks, and back-pressure — that’s where we’ve found most of the leverage. The model is probably fine. It’s just a skill issue.&lt;/p&gt;</description><link>https://www.humanlayer.dev/blog/skill-issue-harness-engineering-for-coding-agents</link><guid isPermaLink="false">https://www.humanlayer.dev/blog/skill-issue-harness-engineering-for-coding-agents</guid><pubDate>Wed, 11 Mar 2026 16:00:00 GMT</pubDate><author>Kyle</author><category>agents</category><category>claudecode</category><category>best-practices</category></item><item><title>A Brief History of Ralph</title><description>&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;The &lt;a href=&quot;https://ghuntley.com/ralph/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;Ralph Wiggum Technique&lt;/a&gt;, created by &lt;a href=&quot;https://x.com/GeoffreyHuntley&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;Geoff Huntley&lt;/a&gt;, went viral in the final weeks of 2025. Here&#39;s the story of ralph since the first time I met Geoff in June of 2025.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;I&#39;ve been messing with ralph since ~June 2025. Here&#39;s my story and what I learned along the way.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;tl;dr&lt;/strong&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Jan 1 2026 - If you wanna skip to the end, I did a deep dive on ralph w/ Geoff Huntley on Jan 1 2026. It talks through the history, cursed lang, and compares the original bash-loop ralph implementation with the anthropic stop-hook implementation. You can check it out here:&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=SB6cO97tfiY&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=SB6cO97tfiY&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;&lt;img src=&quot;https://img.youtube.com/vi/SB6cO97tfiY/0.jpg&quot; alt=&quot;ralph-yt&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;June 19th 2025&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;I attend a meetup with about 15 members of a Twitter GC where we talk about agentic coding. It&#39;s the first time I see context7, WisprFlow, specstory, taskmaster, and a whole bunch of other tools and addons, some of which are now quite mainstream. One of our engineers demos an early TUI for Claude approvals and what becomes the foundation of research / plan / implement.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;There are about 3 hours of presentations. Geoff shows up 2 hours late and presents last. He completely steals the show, diving deep on ralph, cursed lang (at the time, the compiler stack is written in Rust), livestreaming autonomous coding overnight while asleep in Australia, subagents in amp code, the virtues of drinking 3 margaritas and shouting at cursor, and much, much more.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Geoff talks about the &quot;overbaking&quot; phenomenon. If you leave ralph running too long, you end up with all sorts of bizarre emergent behavior, like post-quantum cryptography support.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;It has dimensions of art, deep engineering, the embrace of chaos, and the raw and authentic joy of making a thing.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;All ~15 of us have a long and (imo) somewhat unsettling conversation about the future of software dev—about how easy it is to take a SaaS and copy 80-90% of it, and about how many types of work are about to change or disappear entirely.&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;July 2025&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Geoff Launches ralph in &lt;a href=&quot;https://ghuntley.com/ralph/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;an official blog post&lt;/a&gt;.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/brief-history-of-ralph/ralph-blog.jpg&quot; alt=&quot;ralph-blog&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;It includes the basic bash loop structure:&lt;/p&gt;
&lt;pre class=&quot;group&quot;&gt;&lt;pre class=&quot;prismjs rsh-code-block grid relative min-w-[250px] mb-6 bg-gray-400/5 p-4&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider border bg-transparent text-[var(--accent)] border-transparent hover:bg-[var(--accent)]/10 hover:border-[var(--accent)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-1 h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-10&quot; aria-label=&quot;Copy code&quot; title=&quot;Copy code&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-copy h-3 w-3&quot; aria-hidden=&quot;true&quot;&gt;&lt;rect width=&quot;14&quot; height=&quot;14&quot; x=&quot;8&quot; y=&quot;8&quot; rx=&quot;2&quot; ry=&quot;2&quot;&gt;&lt;/rect&gt;&lt;path d=&quot;M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;code class=&quot;overflow-x-auto&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;while&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;do&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;cat&lt;/span&gt;&lt;span class=&quot;&quot;&gt; PROMPT.md &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;&quot;&gt; npx --yes @sourcegraph/amp &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;done&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/pre&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;I send it to everyone I know. I hint at it to a few others.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/brief-history-of-ralph/text.jpg&quot; alt=&quot;escape&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;It includes a very lightweight example of one of the prompts (this one came later in the language dev, as far as I can tell, since its about the stdlib)&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/brief-history-of-ralph/prompt.png&quot; alt=&quot;prompt&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;At the time, it included an ask (paraphrasing here as it appears to be gone now)&lt;/p&gt;
&lt;blockquote class=&quot;border-l-4 pl-4 my-4 italic&quot; style=&quot;border-color:var(--accent);color:var(--text-muted)&quot;&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;you could probably find the cursed lang repo on github if you looked for it, but please don&#39;t share it yet&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;This is exciting.&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;August 2025 - Advanced Context Engineering for Coding agents&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;If you were early to the coding agents poweruser game, you might have seen &lt;a href=&quot;https://hlyr.dev/ace-fca&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;Getting AI to work in complex codebases&lt;/a&gt; on hackernews and the &lt;a href=&quot;https://www.youtube.com/watch?v=IS_y40zY-hc&amp;amp;t=606s&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;youtube talk it was based on&lt;/a&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;It references ralph and why its such an important example of why engineering your context window is such a high-leverage activity.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Ralph is also a great example of using declarative specifications over imperative instructions.&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;August 2025 - hacking productivity tools&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;I love hacking on Getting Things Done (GTD) and other productivity systems. I for whatever reason am still stuck on omnifocus which is an ancient but well-honed implementation of the system. But I have always longed for an AI native version.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;I wrote a half-pager on what I wanted, I had ralph write the specs from that, and I had another ralph build the implementation from the specs.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;I didn&#39;t really read the specs, and I didn&#39;t read the code.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;The output sucked. I went back to read the specs and they were way off base.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;That&#39;s fine it was a saturday morning toy thing, but I learned stuff.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Lessons&lt;/strong&gt;:&lt;/p&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ul class=&quot;list-disc space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;if the specs are bad, the results will be meh&lt;/li&gt;
&lt;li&gt;if you don&#39;t actually know your desired end state workflows and how you will test it, you probably won&#39;t know what to do when its done&lt;/li&gt;
&lt;li&gt;if you are iterating/exploring, you probably don&#39;t want ralph in the first place&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;August 2025 - we put a coding agent in a while loop and it shipped 6 repos overnight&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;You may recall this HN discussion - &lt;a href=&quot;https://news.ycombinator.com/item?id=45005434&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;we put a coding agent in a while loop and it shipped 6 repos overnight&lt;/a&gt; - here&#39;s the original post simon and I wrote up at &lt;a href=&quot;https://github.com/repomirrorhq/repomirror/blob/main/repomirror.md&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;repomirrorhq/repomirror&lt;/a&gt;&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;August 2025 - testing ralph for a refactor&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;I did a few experiments with ralph for side projects, but the most interestinng one was this one.&lt;/p&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ol class=&quot;list-decimal space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;An engineer was complaining that the frontend code was messy and was hard to work in, sprawling patterns, long components, etc&lt;/li&gt;
&lt;li&gt;I spent about 30 minutes back and forth with claude developing a &lt;a href=&quot;https://github.com/humanlayer/humanlayer/pull/513/files#diff-5487b92720e928ed8ea977964b50e2aa06799655c363794f44b399db24aef042&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;REACT_CODING_STANDARDS.md&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;I spent another 30 minutes working with the engineer (who has a lot more react experience than I do) to refine and update this doc&lt;/li&gt;
&lt;li&gt;I launched a ralph with a prompt &quot;make sure the code base matches the standards&quot; &lt;a href=&quot;https://github.com/humanlayer/humanlayer/pull/513/files#diff-53b6860818e438160467dd18325eb5213e411ea3622a567344f74a1e5e7a68ca&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;prompt.md&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Over the next 6 hours, it developed a &lt;a href=&quot;https://github.com/dexhorthy/humanlayer/blob/75e29a84c8c9261ff5c4ca62d2212736e9be9f02/humanlayer-wui/REACT_REFACTOR_PLAN.md&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;REACT_REFACTOR_PLAN.md&lt;/a&gt; and blasted through the whole thing&lt;/li&gt;
&lt;li&gt;I checked in after 6 hours and it claimed to be finished, so I stopped it and sent it over to team for a look.&lt;/li&gt;
&lt;li&gt;Overall the feedback was positive, but the PR quickly got some merge conflicts and so we never ended up merging it - you can &lt;a href=&quot;https://github.com/humanlayer/humanlayer/pull/513/files#diff-c63bc7049cdcb765ad6c4525336e5a0c6ce6b00f901e162da2b5e9c386af630c&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;view the closed PR here&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Lesson&lt;/strong&gt; - code is cheap - the easier alternative to &quot;merge/rebase&quot; is just to re-run the ralph loop on the fresh code with the same prompt and re-open a PR.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Lesson&lt;/strong&gt; - for existing codebases, make the change set manageable - we have since set up any ralph-ish desired state loops to once ONCE on a cron overnight, and merge small iterations over time. Waking up to one small refactor every morning is better than both a) waking up to none and b) waking up to 50.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;See also: &lt;a href=&quot;https://ronjeffries.com/xprog/articles/refactoring-not-on-the-backlog/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;Ron Jeffries: Refactoring -- Not on the backlog!&lt;/a&gt;&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;September 2025 - cursed lang launch&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;In September 2025, Geoff &lt;a href=&quot;https://ghuntley.com/cursed/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;launches cursed lang officially&lt;/a&gt;, the programming language that ralph built. Once in C, once in rust, and then finally in zig. It has a standard library and a stage-2 compiler (cursed lang compiler written in cursed lang).&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Check out the &lt;a href=&quot;https://cursed-lang.org/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;Cursed Lang Homepage&lt;/a&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/brief-history-of-ralph/cursed-lang.png&quot; alt=&quot;cursed-lang&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Aside&lt;/strong&gt; - I want to do a cursed lang hackathon next time Geoff is in SF - stay tune or ping me on X if this is something you&#39;re be interested in.&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;October 2025 - Claude Anonymous SF&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;I did a 5-minute ralph presentation at &lt;a href=&quot;https://luma.com/i37ahi52&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;claude code anonymous&lt;/a&gt; in sf, in a room full of some of the most creative and enterprising claude code and codex users in town. &lt;a href=&quot;https://x.com/steipete&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;steipete&lt;/a&gt; came all the way out from Austria to co-host with the Sentry folks.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;It&#39;s hard to capture the glory of ralph in a 5 minute lightning talk. But even if all the context engineering concepts get missed, its always a fun time because of the deep art Geoff put into it the naming and branding.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Highlight was a question from the audience &quot;so do you recommend this?&quot; - my answer: &quot;well, I believe you should try everything&quot;. Perhaps the point is not the 5-line bash loop. Perhaps the point is &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;dumb things can work surprisingly well&lt;/strong&gt;, so what could we expect from a smart version of the thing?&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;October 2025 - AI That Works w/ Geoff Huntley&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;I was annoyed that I couldn&#39;t really do ralph justice in 5 minutes, so I wrangled &lt;a href=&quot;https://x.com/vaibcode&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;Vaibhav&lt;/a&gt; and &lt;a href=&quot;https://x.com/GeoffreyHuntley&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;Geoff&lt;/a&gt; to do a 75-minute podcast deep diving on ralph and why it works.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;We talk a lot about context windows, control loops, and various applications of the technique - refactoring, spec generation, new project setup, etc.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/brief-history-of-ralph/ralph-slides.png&quot; alt=&quot;ralph-whiteboard&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;It was a fun time. You can watch it here:&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=fOPvAPdqgPo&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=fOPvAPdqgPo&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;&lt;img src=&quot;https://img.youtube.com/vi/fOPvAPdqgPo/0.jpg&quot; alt=&quot;aitw&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;a href=&quot;https://github.com/ai-that-works/ai-that-works/tree/main/2025-10-28-ralph-wiggum-coding-agent-power-tools&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;There&#39;s some code samples here&lt;/a&gt;&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;December 2025 - Anthropic Plugin Launches&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;At some point the anthropic team released an &lt;a href=&quot;https://github.com/anthropics/claude-code/tree/main/plugins/ralph-wiggum&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;official ralph wiggum plugin&lt;/a&gt;.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Many people tweeted at Geoff about it.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;a href=&quot;https://x.com/GeoffreyHuntley/status/1999722774403928218&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;a href=&quot;https://x.com/GeoffreyHuntley/status/1999722774403928218&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/brief-history-of-ralph/ralph-plugin.png&quot; alt=&quot;ralph-plugin&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;I test it out. I am disappointed. It dies in cryptic ways unless you have &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;--dangerously-skip-permissions&lt;/code&gt;.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;It installs hooks in weird places you can&#39;t find, uses a strange markdown file to track state, and adds an opaque stop hook for all claude sessions in a directory until you disable it. If you, in trying to stop it, delete the markdown file before stopping it, you break claude in that repo until you disable the plugin entirely.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Beyond that, it misses the key point of ralph which is not &quot;run forever&quot; but in &quot;carve off small bits of work into independent context windows&quot;.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;I look forward to see more from Anthropic on this in the future, but for now I&#39;ll keep my 5-line bash loops.&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;December 2025 - Youtube Slop Everywhere&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;There were quickly ralph wiggum videos everywhere. Most of them are typical youtube ai hype-slop:&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;a href=&quot;https://www.youtube.com/results?search_query=ralph+wiggum+claude&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;a href=&quot;https://www.youtube.com/results?search_query=ralph+wiggum+claude&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/brief-history-of-ralph/ralph-yt.png&quot; alt=&quot;ralph-yt&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;I actually like &lt;a href=&quot;https://www.youtube.com/watch?v=_IK18goX4X8&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;Matt Pockock&#39;s youtube overview&lt;/a&gt; because its true to the OG technique, and Matt does a good job of grounding the technique in a workflow like kanban, requirements discovery, etc.&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;Jan 1 2026 - Ralph Wiggum Showdown&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;So much ralph hype, I decided to give the official plugin another shot. I posted this graphic on twitter:&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;a href=&quot;https://x.com/dexhorthy/status/2006832274848047285&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;a href=&quot;https://x.com/dexhorthy/status/2006832274848047285&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/brief-history-of-ralph/ralph-tweet.png&quot; alt=&quot;ralph-tweet&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;To my pleasant surprise, Geoff texted me and was like &quot;okay I can jump on for the first 30 minutes or so&quot;.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;So here ya go, a bonafide ralph wiggum yap, the whole story, why it works, with whiteboards and live examples for a side project I&#39;m working on called &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;kustomark&lt;/code&gt;.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=SB6cO97tfiY&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=SB6cO97tfiY&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;&lt;img src=&quot;https://img.youtube.com/vi/SB6cO97tfiY/0.jpg&quot; alt=&quot;ralph-yt&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Here&#39;s the repos that got built. I still haven&#39;t gotten around to evaluating which one, if any, actually solves my problem:&lt;/p&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ul class=&quot;list-disc space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/dexhorthy/kustomark-ralph-bash&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;https://github.com/dexhorthy/kustomark-ralph-bash&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/dexhorthy/kustomark-ralph-plugin&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;https://github.com/dexhorthy/kustomark-ralph-plugin&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;What&#39;s next&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;I still need to do a deep dive on what was built on the showdown stream. That&#39;s coming in the next few days, hopefully, because the kustomark plugin is a thing I actually want+need for some projects we&#39;re exploring.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;You should mess with this stuff. It&#39;s not exactly the future, but its an imporant slice through a bunch of important concepts that will make you a better Agentic Coder and a better AI Engineer.&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;Okay one more thing&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;A gift and a shameless plug - a lot of you are sitting around on the waitlist wondering &quot;when the heck is codelayer gonna actually launch&quot;. Quick update there - we&#39;re still working hard in the trenches with customers, and learning a lot that has led us to reexamine the entire product. However I am very proud of the OG codelayer and we have many many very happy users on the free private beta. So -- with the disclaimer that we will likely sunset the current beta in favor of a new thing we&#39;re launching soon -- if you read this far and you wanna try codelayer - check out the docs at &lt;a href=&quot;https://hlyr.dev/docs&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;https://hlyr.dev/docs&lt;/a&gt; and have fun.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Excited to share what&#39;s next.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;In the mean time, happy ralphing. Hurry up before it gets &lt;a href=&quot;https://martinfowler.com/bliki/SemanticDiffusion.html&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;semantically diffused&lt;/a&gt;.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;-dex&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;PPS&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;We&#39;re hiring yada yada come build cool shit&lt;/p&gt;</description><link>https://www.humanlayer.dev/blog/brief-history-of-ralph</link><guid isPermaLink="false">https://www.humanlayer.dev/blog/brief-history-of-ralph</guid><pubDate>Mon, 05 Jan 2026 16:00:00 GMT</pubDate><author>Dex</author><category>agents</category><category>claudecode</category><category>ralph-wiggum</category></item><item><title>Context-Efficient Backpressure for Coding Agents</title><description>&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Here&#39;s a pattern we use constantly at HumanLayer: swallow all test/build/lint output and replace it with a single &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;✓&lt;/code&gt; if the stage passes.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;If &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;exitCode != 0&lt;/code&gt;, dump the stashed output to stdout. Otherwise, the agent never sees it.&lt;/p&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;stay in the smart zone&lt;/h2&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;You should try hard to stay in the &lt;a href=&quot;https://youtu.be/rmvDxxNubIg?si=bbPvQb6-etG5wD_I&amp;amp;t=347&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;~75k token &quot;smart zone&quot;&lt;/a&gt; for claude models - every line of &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;PASS src/utils/helper.test.ts&lt;/code&gt; is waste.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;A jest/maven/pytest run might dump 200+ lines of output, and then your agent has to parse all of that to find the one failure it actually needs to fix.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Or worse, if all tests are passing, you just threw away 2-3% of your context window for an &quot;all good&quot; result you could have conveyed in less than 10 tokens.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;You&#39;re &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;wasting context&lt;/strong&gt; - every token you use is diminishing the results and moves you closer to &quot;need to clear or compact to get back to the smart zone&quot;.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;And you should forget the token cost and time-it-takes-to-run concerns for now (we&#39;ll come back to time in a second), since &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;human&lt;/strong&gt; time wasted on wrangling an agent in the dumb zone is likely more expensive by 10x or more.&lt;/p&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;a pretty dumb fix&lt;/h2&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Not a full fix, but in the right direction:&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Rather than letting the model decide what to truncate, we like to take control of output deterministically.&lt;/p&gt;
&lt;pre class=&quot;group&quot;&gt;&lt;pre class=&quot;prismjs rsh-code-block grid relative min-w-[250px] mb-6 bg-gray-400/5 p-4&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider border bg-transparent text-[var(--accent)] border-transparent hover:bg-[var(--accent)]/10 hover:border-[var(--accent)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-1 h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-10&quot; aria-label=&quot;Copy code&quot; title=&quot;Copy code&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-copy h-3 w-3&quot; aria-hidden=&quot;true&quot;&gt;&lt;rect width=&quot;14&quot; height=&quot;14&quot; x=&quot;8&quot; y=&quot;8&quot; rx=&quot;2&quot; ry=&quot;2&quot;&gt;&lt;/rect&gt;&lt;path d=&quot;M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;code class=&quot;overflow-x-auto&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;token function-name function&quot;&gt;run_silent&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;local&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token assign-left variable&quot;&gt;description&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token string variable&quot;&gt;$1&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;local&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token assign-left variable&quot;&gt;command&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token string variable&quot;&gt;$2&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;local&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token assign-left variable&quot;&gt;tmp_file&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;mktemp&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;eval&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token string variable&quot;&gt;$command&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token string variable&quot;&gt;$tmp_file&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator file-descriptor important&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token file-descriptor important&quot;&gt;&amp;amp;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;  ✓ %s&lt;/span&gt;&lt;span class=&quot;token string entity&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token string variable&quot;&gt;$description&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;rm&lt;/span&gt;&lt;span class=&quot;&quot;&gt; -f &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token string variable&quot;&gt;$tmp_file&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;local&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token assign-left variable&quot;&gt;exit_code&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$?&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;  ✗ %s&lt;/span&gt;&lt;span class=&quot;token string entity&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token string variable&quot;&gt;$description&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;cat&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token string variable&quot;&gt;$tmp_file&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;rm&lt;/span&gt;&lt;span class=&quot;&quot;&gt; -f &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token string variable&quot;&gt;$tmp_file&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$exit_code&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;fi&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/pre&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Invoke it with&lt;/p&gt;
&lt;pre class=&quot;group&quot;&gt;&lt;pre class=&quot;prismjs rsh-code-block grid relative min-w-[250px] mb-6 bg-gray-400/5 p-4&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider border bg-transparent text-[var(--accent)] border-transparent hover:bg-[var(--accent)]/10 hover:border-[var(--accent)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-1 h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-10&quot; aria-label=&quot;Copy code&quot; title=&quot;Copy code&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-copy h-3 w-3&quot; aria-hidden=&quot;true&quot;&gt;&lt;rect width=&quot;14&quot; height=&quot;14&quot; x=&quot;8&quot; y=&quot;8&quot; rx=&quot;2&quot; ry=&quot;2&quot;&gt;&lt;/rect&gt;&lt;path d=&quot;M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;code class=&quot;overflow-x-auto&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;&quot;&gt;run_silent &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;fe integration tests&quot;&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;bun run test:integration&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/pre&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Instead of 200 lines of test output, the agent sees:&lt;/p&gt;
&lt;pre class=&quot;group&quot;&gt;&lt;pre class=&quot;prismjs rsh-code-block grid relative min-w-[250px] mb-6 bg-gray-400/5 p-4&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider border bg-transparent text-[var(--accent)] border-transparent hover:bg-[var(--accent)]/10 hover:border-[var(--accent)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-1 h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-10&quot; aria-label=&quot;Copy code&quot; title=&quot;Copy code&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-copy h-3 w-3&quot; aria-hidden=&quot;true&quot;&gt;&lt;rect width=&quot;14&quot; height=&quot;14&quot; x=&quot;8&quot; y=&quot;8&quot; rx=&quot;2&quot; ry=&quot;2&quot;&gt;&lt;/rect&gt;&lt;path d=&quot;M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;code class=&quot;overflow-x-auto&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;&quot;&gt;  ✓ Auth tests
&lt;/span&gt;  ✓ Utils tests
&lt;!-- --&gt;  ✗ API tests
&lt;!-- --&gt;
&lt;!-- --&gt;  FAIL src/api/users.test.ts
&lt;!-- --&gt;  ● should validate email format
&lt;!-- --&gt;    Expected: true
&lt;!-- --&gt;    Received: false&lt;/code&gt;&lt;/pre&gt;&lt;/pre&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;The model doesn&#39;t need to decide whether to truncate. You&#39;ve already made that decision. Success = ✓. Failure = full output.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Now your only job is to convince the model not to do its own truncation. Maybe you can &lt;a href=&quot;https://www.humanlayer.dev/blog/writing-a-good-claude-md&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;shout at it in your claude.md&lt;/a&gt;.&lt;/p&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;make it smaller over time&lt;/h2&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Once you have the basic wrapper working, iterate:&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Enable failFast.&lt;/strong&gt; &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;pytest -x&lt;/code&gt;, &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;jest --bail&lt;/code&gt;, &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;go test -failfast&lt;/code&gt;. One failure at a time. Don&#39;t make the agent context-switch between five different bugs, or re-read the same &quot;tests 2-5 are failing&quot; output when its still trying to fix test #1.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Filter the output.&lt;/strong&gt; Strip generic stack frames that don&#39;t help your agent find the issue. Remove timing info. grep/sed/awk/cut/etc your way to just the assertion that failed.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Framework-specific parsing.&lt;/strong&gt; even &lt;a href=&quot;https://github.com/humanlayer/humanlayer/blob/main/hack/run_silent.sh&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;a pretty-hacky run_silent.sh&lt;/a&gt; extracts test counts from pytest, jest, go test, and vitest so you still get visibility without the noise.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;We use this pattern heavily when working with customers who have Maven and Gradle projects (notoriously verbose), and it works equally well for xcodebuild, cargo, and anything else that spews.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Here&#39;s the humanlayer/humanlayer checks and tests for a monorepo - we run these in a pre-push hook, and some subset of these projects for each plan phase.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/context-efficient-backpressure/full-suite.png&quot; alt=&quot;output&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;This would easily be half a context window worth of output without the wrappers.&lt;/p&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;im tired of context-anxious models&lt;/h2&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;The latest generation of models has spent so much time in the RL dungeon that they&#39;ve overcorrected way too far on being conservative with how much context they load.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;here&#39;s some patterns I&#39;ve seen in the last few months:&lt;/p&gt;
&lt;h4 class=&quot;text-xl mb-1 mt-8 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;#### &lt;!-- --&gt;output swallowing&lt;/h4&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;piping output to &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;/dev/null&lt;/code&gt; and using an &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;||&lt;/code&gt; operator to just print a message based on the commands exit code&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/context-efficient-backpressure/model-wrap.png&quot; alt=&quot;model wrapping bash&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;while its cool that we&#39;re being conservative, remember what cat would have printed without the output swallowing:&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/context-efficient-backpressure/cat-output.png&quot; alt=&quot;cat output without wrapping&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;In this trivial example, the guardrails actually use MORE TOKENS:&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/context-efficient-backpressure/token-compare.png&quot; alt=&quot;/blog/context-efficient-backpressure/token-compare.png&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Disclaimers - 1) yes if cat had repeated the whole filename, that would have been more tokens. 2) this is an &lt;a href=&quot;https://claude-tokenizer.vercel.app/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;unofficial tokenizer&lt;/a&gt; and probably out of date&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;but you get my point here - the real nasty one comes next -&lt;/p&gt;
&lt;h4 class=&quot;text-xl mb-1 mt-8 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;#### &lt;!-- --&gt;piping to head / tail&lt;/h4&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;I hear so many complaints about &quot;oh it ran a 5 minute test suite with &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;head -n 50&lt;/code&gt; and now it has to run it again&quot;&lt;/p&gt;
&lt;pre class=&quot;group&quot;&gt;&lt;pre class=&quot;prismjs rsh-code-block grid relative min-w-[250px] mb-6 bg-gray-400/5 p-4&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider border bg-transparent text-[var(--accent)] border-transparent hover:bg-[var(--accent)]/10 hover:border-[var(--accent)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-1 h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-10&quot; aria-label=&quot;Copy code&quot; title=&quot;Copy code&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-copy h-3 w-3&quot; aria-hidden=&quot;true&quot;&gt;&lt;rect width=&quot;14&quot; height=&quot;14&quot; x=&quot;8&quot; y=&quot;8&quot; rx=&quot;2&quot; ry=&quot;2&quot;&gt;&lt;/rect&gt;&lt;path d=&quot;M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;code class=&quot;overflow-x-auto&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;&quot;&gt;venv/bin/python -m pytest -n 4 | head -n 50&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/pre&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;If your tests take less than 30 seconds, great you probably don&#39;t care, but that&#39;s not the case for most of us. And again, we&#39;re gonna focus on &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;human time&lt;/strong&gt; wasted while the agent runs and re-runs test suites, or wasted on compacting/restarting a context window because too many tokens got used.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Ironically, in trying to conserve context and serve us better, models end up burning more tokens, more human time, and more mental energy.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;I won&#39;t opine on why the product teams that focus on model behavior have leaned into this behavior, but I can only assume its at least in-broad-strokes intentional. It helps models perform well in codebases that &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;are not&lt;/strong&gt; thoughtful about context-efficiency of their &lt;a href=&quot;https://ghuntley.com/secure-codegen/#in-practice&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;backpressure mechanisms&lt;/a&gt;&lt;/p&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;its not your fault&lt;/h2&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Okay fine, opining time: things are this way because labs have to take big swings and the majority of their potential user base doesn&#39;t know how (or want to learn how) to do context engineering well. Sure, &quot;don&#39;t make me think&quot;. But also, &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;let me think if I want to&lt;/strong&gt;.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;a href=&quot;https://x.com/gingerhendrixai/status/1998082340019446203&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;a href=&quot;https://x.com/gingerhendrixai/status/1998082340019446203&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/context-efficient-backpressure/gareth.png&quot; alt=&quot;gareth-tweet&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;As we always say - deterministic is better than non-deterministic. If you already know what matters, don&#39;t leave it to a model to churn through 1000s of junk tokens to decide.&lt;/p&gt;</description><link>https://www.humanlayer.dev/blog/context-efficient-backpressure</link><guid isPermaLink="false">https://www.humanlayer.dev/blog/context-efficient-backpressure</guid><pubDate>Mon, 08 Dec 2025 16:00:00 GMT</pubDate><author>Dex</author><category>agents</category><category>claudecode</category><category>best-practices</category><category>devex</category></item><item><title>Writing a good CLAUDE.md</title><description>&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;em style=&quot;color:var(--text-secondary)&quot;&gt;Note: this post is also applicable to &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;AGENTS.md&lt;/code&gt;&lt;/em&gt;, the open-source equivalent of &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;CLAUDE.md&lt;/code&gt; for agents and harnesses like OpenCode, Zed, Cursor and Codex.&lt;/p&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;Principle: LLMs are (mostly) stateless&lt;/h2&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;LLMs are stateless functions. Their weights are frozen by the time they&#39;re used for inference, so they don&#39;t learn over time. The only thing that the model knows about your codebase is the tokens you put into it.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Similarly, coding agent harnesses such as Claude Code usually require you to manage agents&#39; memory explicitly. &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;CLAUDE.md&lt;/code&gt; (or &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;AGENTS.md&lt;/code&gt;) is the only file that by default goes into &lt;em style=&quot;color:var(--text-secondary)&quot;&gt;every single conversation&lt;/em&gt; you have with the agent.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;This has three important implications:&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ol class=&quot;list-decimal space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;Coding agents know absolutely nothing about your codebase at the beginning of each session.&lt;/li&gt;
&lt;li&gt;The agent must be told anything that&#39;s important to know about your codebase each time you start a session.&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;CLAUDE.md&lt;/code&gt; is the preferred way of doing this.&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;CLAUDE.md&lt;/code&gt; onboards Claude to your codebase&lt;/h2&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Since Claude doesn&#39;t know anything about your codebase at the beginning of each session, you should use &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;CLAUDE.md&lt;/code&gt; to onboard Claude into your codebase. At a high level, this means it should cover:&lt;/p&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ul class=&quot;list-disc space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;WHAT&lt;/strong&gt;: tell Claude about the tech, your stack, the project structure. Give Claude a map of the codebase. This is especially important in monorepos! Tell Claude what the apps are, what the shared packages are, and what everything is for so that it knows where to look for things&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;WHY&lt;/strong&gt;: tell Claude the &lt;em style=&quot;color:var(--text-secondary)&quot;&gt;purpose&lt;/em&gt; of the project and what everything is doing in the repository. What are the purpose and function of the different parts of the project?&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;HOW&lt;/strong&gt;: tell Claude how it should work on the project. For example, do you use &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;bun&lt;/code&gt; instead of &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;node&lt;/code&gt;? You want to include all the information it needs to actually do meaningful work on the project. How can Claude verify Claude&#39;s changes? How can it run tests, typechecks, and compilation steps?&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;But the way you do this is important! Don&#39;t try to stuff every command Claude could possibly need to run in your &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;CLAUDE.md&lt;/code&gt; file - you will get sub-optimal results.&lt;/p&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;Claude often ignores &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;CLAUDE.md&lt;/code&gt;&lt;/h2&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Regardless of which model you&#39;re using, you may notice that Claude frequently ignores your &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;CLAUDE.md&lt;/code&gt; file&#39;s contents.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;You can investigate this yourself by putting a logging proxy between the claude code CLI and the Anthropic API using &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;ANTHROPIC_BASE_URL&lt;/code&gt;. Claude code injects the following system reminder with your &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;CLAUDE.md&lt;/code&gt; file in the user message to the agent:&lt;/p&gt;
&lt;pre class=&quot;group&quot;&gt;&lt;pre class=&quot;prismjs rsh-code-block grid relative min-w-[250px] mb-6 bg-gray-400/5 p-4&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider border bg-transparent text-[var(--accent)] border-transparent hover:bg-[var(--accent)]/10 hover:border-[var(--accent)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-1 h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-10&quot; aria-label=&quot;Copy code&quot; title=&quot;Copy code&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-copy h-3 w-3&quot; aria-hidden=&quot;true&quot;&gt;&lt;rect width=&quot;14&quot; height=&quot;14&quot; x=&quot;8&quot; y=&quot;8&quot; rx=&quot;2&quot; ry=&quot;2&quot;&gt;&lt;/rect&gt;&lt;path d=&quot;M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;code class=&quot;overflow-x-auto&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;&quot;&gt;&amp;lt;system-reminder&amp;gt;
&lt;/span&gt;      IMPORTANT: this context may or may not be relevant to your tasks. 
&lt;!-- --&gt;      You should not respond to this context unless it is highly relevant to your task.
&lt;!-- --&gt;&amp;lt;/system-reminder&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;/pre&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;As a result, Claude will ignore the contents of your &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;CLAUDE.md&lt;/code&gt; if it decides that it is not relevant to its current task. The more information you have in the file that&#39;s not &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;universally applicable&lt;/strong&gt; to the tasks you have it working on, the more likely it is that Claude will ignore your instructions in the file.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;em style=&quot;color:var(--text-secondary)&quot;&gt;Why did Anthropic add this?&lt;/em&gt; It&#39;s hard to say for sure, but we can speculate a bit. Most &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;CLAUDE.md&lt;/code&gt; files we come across include a bunch of instructions in the file that &lt;em style=&quot;color:var(--text-secondary)&quot;&gt;aren&#39;t&lt;/em&gt; broadly applicable. Many users treat the file as a way to add &quot;hotfixes&quot; to behavior they didn&#39;t like by appending lots of instructions that weren&#39;t necessarily broadly applicable.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;We can only assume that the Claude Code team found that by telling Claude to ignore the bad instructions, the harness actually produced better results.&lt;/p&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;Creating a good &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;CLAUDE.md&lt;/code&gt; file&lt;/h2&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;The following section provides a number of recommendations on how to write a good &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;CLAUDE.md&lt;/code&gt; file following &lt;a href=&quot;https://github.com/humanlayer/12-factor-agents/blob/d20c728368bf9c189d6d7aab704744decb6ec0cc/content/factor-03-own-your-context-window.md&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;context engineering best practices&lt;/a&gt;.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;em style=&quot;color:var(--text-secondary)&quot;&gt;Your mileage may vary.&lt;/em&gt; Not all of these rules are necessarily optimal for every setup. Like anything else, feel free to break the rules once...&lt;/p&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ol class=&quot;list-decimal space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;you understand when &amp;amp; why it&#39;s okay to break them&lt;/li&gt;
&lt;li&gt;you have a good reason to do so&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;Less (instructions) is more&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;It can be tempting to try and stuff every single command that claude could possibly need to run, as well as your code standards and style guidelines into &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;CLAUDE.md&lt;/code&gt;. &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;We recommend against this.&lt;/strong&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Though the topic hasn&#39;t been investigated in an incredibly rigorous manner, &lt;a href=&quot;https://arxiv.org/pdf/2507.11538&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;some research&lt;/a&gt; has been done which indicates the following:&lt;/p&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ol class=&quot;list-decimal space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Frontier thinking LLMs can follow ~ 150-200 instructions with reasonable consistency.&lt;/strong&gt; Smaller models can attend to fewer instructions than larger models, and non-thinking models can attend to fewer instructions than thinking models.&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Smaller models get MUCH worse, MUCH more quickly&lt;/strong&gt;. Specifically, smaller models tend to exhibit an expotential decay in instruction-following performance as the number of instructions increase, whereas larger frontier thinking models exhibit a linear decay (see below). For this reason, we recommend against using smaller models for multi-step tasks or complicated implementation plans.&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;LLMs bias towards instructions that are on the peripheries of the prompt&lt;/strong&gt;: at the very beginning (the Claude Code system message and &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;CLAUDE.md&lt;/code&gt;), and at the very end (the most-recent user messages)&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;As instruction count increases, instruction-following quality decreases uniformly&lt;/strong&gt;. This means that as you give the LLM more instructions, it doesn&#39;t simply ignore the newer (&quot;further down in the file&quot;) instructions - it begins to &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;ignore all of them uniformly&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/writing-a-good-claude-md/instructionfollowing.png&quot; alt=&quot;Instruction following&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Our analysis of the Claude Code harness indicates that &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Claude Code&#39;s system prompt contains ~50 individual instructions&lt;/strong&gt;.
Depending on the model you&#39;re using, that&#39;s nearly a third of the instructions your agent can reliably follow already - and that&#39;s before rules, plugins, skills, or user messages.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;This implies that your &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;CLAUDE.md&lt;/code&gt; file should contain as few instructions as possible - ideally only ones which are universally applicable to your task.&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;CLAUDE.md&lt;/code&gt; file length &amp;amp; applicability&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;All else being equal, &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;an LLM will perform better on a task when its&#39; context window is full of focused, relevant context&lt;/strong&gt; including examples, related files, tool calls, and tool results compared to when its context window has a lot of irrelevant context.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Since &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;CLAUDE.md&lt;/code&gt; goes into &lt;em style=&quot;color:var(--text-secondary)&quot;&gt;every single session&lt;/em&gt;, you should ensure that its contents are as universally applicable as possible.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;For example, avoid including instructions about (for example) how to structure a new database schema - this won&#39;t matter and will distract the model when you&#39;re working on something else that&#39;s unrelated!&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Length-wise, the &lt;em style=&quot;color:var(--text-secondary)&quot;&gt;less is more&lt;/em&gt; principle applies as well. While Anthropic does not have an official recommendation on how long your &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;CLAUDE.md&lt;/code&gt; file should be, general consensus is that &amp;lt; 300 lines is best, and shorter is even better.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;At HumanLayer, our root &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;CLAUDE.md&lt;/code&gt; file is &lt;em style=&quot;color:var(--text-secondary)&quot;&gt;less than sixty lines&lt;/em&gt;.&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;Progressive Disclosure&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Writing a concise &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;CLAUDE.md&lt;/code&gt; file that covers everything you want Claude to know can be challenging, especially in larger projects.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;To address this, we can leverage the principle of &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Progressive Disclosure&lt;/strong&gt; to ensure that claude only sees task- or project-specific instructions when it needs them.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Instead of including all your different instructions about building your project, running tests, code conventions, or other important context in your &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;CLAUDE.md&lt;/code&gt; file, we recommend keeping task-specific instructions in &lt;em style=&quot;color:var(--text-secondary)&quot;&gt;separate markdown files&lt;/em&gt; with self-descriptive names somewhere in your project.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;For example:&lt;/p&gt;
&lt;pre class=&quot;group&quot;&gt;&lt;pre class=&quot;prismjs rsh-code-block grid relative min-w-[250px] mb-6 bg-gray-400/5 p-4&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider border bg-transparent text-[var(--accent)] border-transparent hover:bg-[var(--accent)]/10 hover:border-[var(--accent)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-1 h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-10&quot; aria-label=&quot;Copy code&quot; title=&quot;Copy code&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-copy h-3 w-3&quot; aria-hidden=&quot;true&quot;&gt;&lt;rect width=&quot;14&quot; height=&quot;14&quot; x=&quot;8&quot; y=&quot;8&quot; rx=&quot;2&quot; ry=&quot;2&quot;&gt;&lt;/rect&gt;&lt;path d=&quot;M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;code class=&quot;overflow-x-auto&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;&quot;&gt;agent_docs/
&lt;/span&gt;  |- building_the_project.md
&lt;!-- --&gt;  |- running_tests.md
&lt;!-- --&gt;  |- code_conventions.md
&lt;!-- --&gt;  |- service_architecture.md
&lt;!-- --&gt;  |- database_schema.md
&lt;!-- --&gt;  |- service_communication_patterns.md&lt;/code&gt;&lt;/pre&gt;&lt;/pre&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Then, in your &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;CLAUDE.md&lt;/code&gt; file, you can include a list of these files with a brief description of each, and instruct Claude to decide which (if any) are relevant and to read them before it starts working. Or, ask Claude to present you with the files it wants to read for aproval first before reading them.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Prefer pointers to copies&lt;/strong&gt;. Don&#39;t include code snippets in these files if possible - they will become out-of-date quickly. Instead, include &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;file:line&lt;/code&gt; references to point Claude to the authoritative context.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Conceptually, this is very similar to how &lt;a href=&quot;https://code.claude.com/docs/en/skills&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;Claude Skills&lt;/a&gt; are intended to work, although skills are more focused on tool use than instructions.&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;Claude is (not) an expensive linter&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;One of the most common things that we see people put in their &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;CLAUDE.md&lt;/code&gt; file is code style guidelines. &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Never send an LLM to do a linter&#39;s job&lt;/strong&gt;. LLMs are comparably expensive and &lt;em style=&quot;color:var(--text-secondary)&quot;&gt;incredibly&lt;/em&gt; slow compared to traditional linters and formatters. We think you should &lt;em style=&quot;color:var(--text-secondary)&quot;&gt;always use deterministic tools whenever you can&lt;/em&gt;.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Code style guidelines will inevitably add a bunch of instructions and mostly-irrelevant code snippets into your context window, degrading your LLM&#39;s performance and instruction-following and eating up your context window.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;LLMs are in-context learners&lt;/strong&gt;! If your code follows a certain set of style guidelines or patterns, you should find that armed with a few searches of your codebase (or a good research document!) your agent should tend to follow existing code patterns and conventions without being told to.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;If you feel very stronly about this, you might even consider setting up a &lt;a href=&quot;https://code.claude.com/docs/en/hooks#stop&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;Claude Code &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;Stop&lt;/code&gt; hook&lt;/a&gt; that runs your formatter &amp;amp; linter and presents errors to Claude for it to fix. Don&#39;t make Claude find the formatting issues itself.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Bonus points&lt;/strong&gt;: use a linter that can automatically fix issues (we like Biome), and carefully tune your rules about what can safely be auto-fixed for maximum (safe) coverage.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;You could also create a &lt;a href=&quot;https://code.claude.com/docs/en/slash-commands&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;Slash Command&lt;/a&gt; that includes your code guidelines and which points claude at the changes in version control, or at your &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;git status&lt;/code&gt;, or similar. This way, you can handle implementation and formatting separately. &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;You will see better results with both as a result&lt;/strong&gt;.&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;Don&#39;t use &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;/init&lt;/code&gt; or auto-generate your &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;CLAUDE.md&lt;/code&gt;&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Both Claude Code and other harnesses with OpenCode come with ways to auto-generate your &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;CLAUDE.md&lt;/code&gt; file (or &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;AGENTS.md&lt;/code&gt;).&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Because &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;CLAUDE.md&lt;/code&gt; goes into &lt;em style=&quot;color:var(--text-secondary)&quot;&gt;every single session&lt;/em&gt; with Claude code, it is one of &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;the highest leverage points of the harness&lt;/strong&gt; - for better or for worse, depending on how you use it.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;A bad line of code is a bad line of code. A bad line of an implementation plan has the potential to create a &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;lot&lt;/strong&gt; of bad lines of code. A bad line of a research that misunderstands how the system works has the potential to result in a lot of bad lines in the plan, and therefore a &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;lot more&lt;/strong&gt; bad lines of code as a result.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;But the &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;CLAUDE.md&lt;/code&gt; file affects &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;every single phase of your workflow&lt;/strong&gt; and every single artifact produced by it. As a result, we think you should spend some time thinking very carefully about every single line that goes into it:&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/writing-a-good-claude-md/leverage.png&quot; alt=&quot;Leverage&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;In Conclusion&lt;/h2&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ol class=&quot;list-decimal space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;&lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;CLAUDE.md&lt;/code&gt; is for onboarding Claude into your codebase. It should define your project&#39;s &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;WHY&lt;/strong&gt;, &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;WHAT&lt;/strong&gt;, and &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;HOW&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Less (instructions) is more&lt;/strong&gt;. While you shouldn&#39;t omit necessary instructions, you should include as few instructions as reasonably possible in the file.&lt;/li&gt;
&lt;li&gt;Keep the contents of your &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;CLAUDE.md&lt;/code&gt; &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;concise and universally applicable&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Use &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Progressive Disclosure&lt;/strong&gt; - don&#39;t tell Claude all the information you could possibly want it to know. Rather, tell it &lt;em style=&quot;color:var(--text-secondary)&quot;&gt;how to find&lt;/em&gt; important information so that it can find and use it, but only when it needs to to avoid bloating your context window or instruction count.&lt;/li&gt;
&lt;li&gt;Claude is not a linter. Use linters and code formatters, and use other features like &lt;a href=&quot;https://code.claude.com/docs/en/hooks&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;Hooks&lt;/a&gt; and &lt;a href=&quot;https://code.claude.com/docs/en/slash-commands&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;Slash Commands&lt;/a&gt; as necessary.&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;&lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;CLAUDE.md&lt;/code&gt; is the highest leverage point of the harness&lt;/strong&gt;, so avoid auto-generating it. You should carefully craft its contents for best results.&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;</description><link>https://www.humanlayer.dev/blog/writing-a-good-claude-md</link><guid isPermaLink="false">https://www.humanlayer.dev/blog/writing-a-good-claude-md</guid><pubDate>Mon, 24 Nov 2025 16:00:00 GMT</pubDate><author>Kyle</author><category>agents</category><category>claudecode</category><category>best-practices</category></item><item><title>Advanced Context Engineering for Coding Agents</title><description>&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;Getting AI to Work in Complex Codebases&lt;/h2&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;It seems pretty well-accepted that AI coding tools struggle with real production codebases. The &lt;a href=&quot;https://www.youtube.com/watch?v=tbDDYKRFjhk&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;Stanford study on AI&#39;s impact on developer productivity&lt;/a&gt; found:&lt;/p&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ol class=&quot;list-decimal space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;A lot of the &quot;extra code&quot; shipped by AI tools ends up just reworking the slop that was shipped last week.&lt;/li&gt;
&lt;li&gt;Coding agents are great for new projects or small changes, but in large established codebases, they can often make developers &lt;em style=&quot;color:var(--text-secondary)&quot;&gt;less&lt;/em&gt; productive.&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;The common response is somewhere between the pessimist &quot;this will never work&quot; and the more measured &quot;maybe someday when there are smarter models.&quot;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;After several months of tinkering, I&#39;ve found that &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;you can get really far with today&#39;s models if you embrace core context engineering principles&lt;/strong&gt;.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;This isn&#39;t another &quot;10x your productivity&quot; pitch. I &lt;a href=&quot;https://hlyr.dev/12fa&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;tend to be pretty measured when it comes to interfacing with the ai hype machine&lt;/a&gt;. But we&#39;ve stumbled into workflows that leave me with considerable optimism for what&#39;s possible. We&#39;ve gotten claude code to handle 300k LOC Rust codebases, ship a week&#39;s worth of work in a day, and maintain code quality that passes expert review. We use a family of techniques I call &quot;frequent intentional compaction&quot; - deliberately structuring how you feed context to the AI throughout the development process.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;I am now fully convinced that AI for coding is not just for toys and prototypes, but rather a deeply technical engineering craft.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Video Version&lt;/strong&gt;: If you prefer video, this post is based on &lt;a href=&quot;https://hlyr.dev/ace&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;a talk given at Y Combinator on August 20th&lt;/a&gt;&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;Grounding Context from AI Engineer&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Two talks from AI Engineer 2025 fundamentally shaped my thinking about this problem.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;The first is &lt;a href=&quot;https://www.youtube.com/watch?v=8rABwKRsec4&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;Sean Grove&#39;s talk on &quot;Specs are the new code&quot;&lt;/a&gt; and the second is &lt;a href=&quot;https://www.youtube.com/watch?v=tbDDYKRFjhk&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;the Stanford study on AI&#39;s impact on developer productivity&lt;/a&gt;.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Sean argued that we’re all &lt;em style=&quot;color:var(--text-secondary)&quot;&gt;vibe coding wrong&lt;/em&gt;. The idea of chatting with an AI agent for two hours, specifying what you want, and then throwing away all the prompts while committing only the final code… is like a Java developer compiling a JAR and checking in the compiled binary while throwing away the source.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Sean proposes that in the AI future, the specs will become the real code. That in two years, you&#39;ll be opening python files in your IDE with about the same frequency that, today, you might open up a hex editor to read assembly (which, for most of us, is never).&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=tbDDYKRFjhk&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;Yegor&#39;s talk on developer productivity&lt;/a&gt; tackled an orthogonal problem. They analyzed commits from 100k developers and found, among other things,&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;(1) That AI tools often lead to a lot of rework, diminishing the perceived productivity gains&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/advanced-context-engineering/ai-software-rework.png&quot; alt=&quot;Rework&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;(2) That AI tools work well for greenfield projects, but are often counter-productive for brownfield codebases and complex tasks&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/advanced-context-engineering/ai-software-productivity.png&quot; alt=&quot;Productivity&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;This matched what I heard talking with founders:&lt;/p&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ul class=&quot;list-disc space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;“Too much slop.”&lt;/li&gt;
&lt;li&gt;“Tech debt factory.”&lt;/li&gt;
&lt;li&gt;“Doesn’t work in big repos.”&lt;/li&gt;
&lt;li&gt;“Doesn’t work for complex systems.”&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;The general vibe on AI-coding for hard stuff tends to be&lt;/p&gt;
&lt;blockquote class=&quot;border-l-4 pl-4 my-4 italic&quot; style=&quot;border-color:var(--accent);color:var(--text-muted)&quot;&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Maybe someday, when models are smarter…&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Heck even &lt;a href=&quot;https://x.com/amasad&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;Amjad&lt;/a&gt; was on a &lt;a href=&quot;https://www.lennysnewsletter.com/p/behind-the-product-replit-amjad-masad&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;lenny&#39;s podcast 9 months ago&lt;/a&gt; talking about how PMs use Replit agent to prototype new stuff and then they hand it off to engineers to implement for production.
(Disclaimer: i haven&#39;t caught up with him recently (ok, ever), this stance may have changed)&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Whenever I hear &quot;Maybe someday when the models are smart&quot; I generally leap to exclaim &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;that&#39;s what context engineering is all about&lt;/strong&gt;: getting the most out of &lt;em style=&quot;color:var(--text-secondary)&quot;&gt;today&#39;s&lt;/em&gt; models.&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;What&#39;s actually possible today&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;I&#39;ll deep dive on this a bit futher down, but to prove this isn&#39;t just theory, let me outline a concrete example. A few weeks ago, I decided to test our techniques on &lt;a href=&quot;https://github.com/BoundaryML/baml&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;BAML&lt;/a&gt;, a 300k LOC Rust codebase for a programming language that works with LLMs. I&#39;m at best an amateur Rust dev and had never touched the BAML codebase before.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Within an hour or so, I had a &lt;a href=&quot;https://github.com/BoundaryML/baml/pull/2259#issuecomment-3155883849&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;PR fixing a bug&lt;/a&gt; which was approved by the maintainer the next morning. A few weeks later, &lt;a href=&quot;https://x.com/hellovai&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;@hellovai&lt;/a&gt; and I paired on shipping 35k LOC to BAML, adding &lt;a href=&quot;https://github.com/BoundaryML/baml/pull/2357&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;cancellation support&lt;/a&gt; and &lt;a href=&quot;https://github.com/BoundaryML/baml/pull/2330&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;WASM compilation&lt;/a&gt; - features the team estimated would take a senior engineer 3-5 days each. We got both draft prs ready in about 7 hours.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Again, this is all built around a workflow we call &lt;a href=&quot;https://www.humanlayer.dev/blog/advanced-context-engineering#what-works-even-better-frequent-intentional-compaction&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;frequent intentional compaction&lt;/a&gt; - essentially designing your entire development process around context management, keeping utilization in the 40-60% range, and building in high-leverage human review at exactly the right points. We use a &quot;research, plan, implement&quot; workflow, but the core capabilities/learnings here are FAR more general than any specific workflow or set of prompts.&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;Our weird journey to get here&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;I was working with one of the most productive AI coders I&#39;ve ever met.
Every few days they&#39;d drop &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;2000-line Go PRs&lt;/strong&gt;.
And this wasn&#39;t a nextjs app or a CRUD API. This was complex, &lt;a href=&quot;https://github.com/humanlayer/humanlayer/blob/main/hld/daemon/daemon_subscription_integration_test.go#L45&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;race-prone systems code&lt;/a&gt; that did JSON RPC over unix sockets and managed streaming stdio from forked unix processes (mostly claude code sdk processes, more on that later 🙂).&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;The idea of carefully reading 2,000 lines of complex Go code every few days was simply not sustainable. I was starting to feel a bit like Mitchell Hashimoto when he added the &lt;a href=&quot;https://github.com/ghostty-org/ghostty/pull/8289&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;AI contributions must be disclosed&lt;/a&gt; rules for ghostty.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Our approach was to adopt something like sean&#39;s &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;spec-driven development&lt;/strong&gt;.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;It was uncomfortable at first.
I had to learn to let go of reading every line of PR code.
I still read the tests pretty carefully, but the specs became our source of truth for what was being built and why.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;The transformation took about 8 weeks.
It was incredibly uncomfortable for everyone involved, not least of all for me.
But now we&#39;re flying. A few weeks back, I shipped 6 PRs in a day.
I can count on one hand the number of times I&#39;ve edited a non-markdown file by hand in the last three months.&lt;/p&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;Advanced Context Engineering for Coding Agents&lt;/h2&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;What we needed was:&lt;/p&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ul class=&quot;list-disc space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;AI that Works Well in Brownfield Codebases&lt;/li&gt;
&lt;li&gt;AI that Solves Complex Problems&lt;/li&gt;
&lt;li&gt;No Slop&lt;/li&gt;
&lt;li&gt;Maintain Mental Alignment across the team&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;(And yeah sure, let&#39;s try to spend as many tokens as possible.)&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;I&#39;ll dive into:&lt;/p&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ol class=&quot;list-decimal space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;what we learned applying context engineering to coding agents&lt;/li&gt;
&lt;li&gt;the dimensions along which using these agents is a deeply technical craft&lt;/li&gt;
&lt;li&gt;why I don&#39;t believe these approaches are generalizable&lt;/li&gt;
&lt;li&gt;the number of times I&#39;ve been repeatedly proven wrong about (3)&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;But first: The Naive Way to manage agent context&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Most of us start by using a coding agent like a chatbot. You talk (or &lt;a href=&quot;https://ghuntley.com/six-month-recap/#:~:text=Last%20week%2C%20over%20Zoom%20margaritas%2C%20a%20friend%20and%20I%20reminisced%20about%20COBOL.&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;drunkenly shout&lt;/a&gt;) back and forth with it, vibing your way through a problem until you either run out of context, give up, or the agent starts apologizing.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/advanced-context-engineering/re-steering.png&quot; alt=&quot;Re-Steering&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;A slightly smarter way is to just start over when you get off track, discarding your session and starting a new one, perhaps with a little more steering in the prompt.&lt;/p&gt;
&lt;blockquote class=&quot;border-l-4 pl-4 my-4 italic&quot; style=&quot;border-color:var(--accent);color:var(--text-muted)&quot;&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;[original prompt], but make sure you use XYZ approach, because ABC approach won&#39;t work&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;Slightly Smarter: Intentional Compaction&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;You have probably done something I&#39;ve come to call &quot;intentional compaction&quot;. Whether you&#39;re on track or not, as your context starts to fill up, you probably want to pause your work and start over with a fresh context window. To do this, you might use a prompt like&lt;/p&gt;
&lt;blockquote class=&quot;border-l-4 pl-4 my-4 italic&quot; style=&quot;border-color:var(--accent);color:var(--text-muted)&quot;&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&quot;Write everything we did so far to progress.md, ensure to note the end goal, the approach we&#39;re taking, the steps we&#39;ve done so far, and the current failure we&#39;re working on&quot;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/advanced-context-engineering/intentional-compaction.png&quot; alt=&quot;Intentional Compaction&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;You can also &lt;a href=&quot;https://x.com/dexhorthy/status/1961490837017088051&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;use commit messages for intentional compaction&lt;/a&gt;.&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;What Exactly Are We Compacting?&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;What eats up context?&lt;/p&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ul class=&quot;list-disc space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;Searching for files&lt;/li&gt;
&lt;li&gt;Understanding code flow&lt;/li&gt;
&lt;li&gt;Applying edits&lt;/li&gt;
&lt;li&gt;Test/build logs&lt;/li&gt;
&lt;li&gt;Huge JSON blobs from tools&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;All of these can flood the context window. &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Compaction&lt;/strong&gt; is simply distilling them into structured artifacts.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;A good output for an intentional compaction might include something like&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/advanced-context-engineering/output.png&quot; alt=&quot;Compaction Output&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;Why obsess over context?&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;As we went deep on in &lt;a href=&quot;https://hlyr.dev/12fa&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;12-factor agents&lt;/a&gt;, LLMs are stateless functions. The only thing that affects the quality of your output (without training/tuning models themselves) is the quality of the inputs.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;This is just as true for &lt;a href=&quot;https://www.youtube.com/watch?v=F_RyElT_gJk&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;wielding&lt;/a&gt; coding agents as it is for general agent design, you just have a smaller problem space, and rather than building agents, we&#39;re talking about using agents.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;At any given point, a turn in an agent like claude code is a stateless function call. Context window in, next step out.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/advanced-context-engineering/context-is-everything.png&quot; alt=&quot;Context is Everything&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;That is, the contents of your context window are the ONLY lever you have to affect the quality of your output. So yeah, it&#39;s worth obsessing over.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;You should optimize your context window for:&lt;/p&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ol class=&quot;list-decimal space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;Correctness&lt;/li&gt;
&lt;li&gt;Completeness&lt;/li&gt;
&lt;li&gt;Size&lt;/li&gt;
&lt;li&gt;Trajectory&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Put another way, the worst things that can happen to your context window, in order, are:&lt;/p&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ol class=&quot;list-decimal space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;Incorrect Information&lt;/li&gt;
&lt;li&gt;Missing Information&lt;/li&gt;
&lt;li&gt;Too much Noise&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;If you like equations, here&#39;s a dumb one you can reference:&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/advanced-context-engineering/equation.png&quot; alt=&quot;Equation&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;As &lt;a href=&quot;https://x.com/GeoffreyHuntley&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;Geoff Huntley&lt;/a&gt; puts it,&lt;/p&gt;
&lt;blockquote class=&quot;border-l-4 pl-4 my-4 italic&quot; style=&quot;border-color:var(--accent);color:var(--text-muted)&quot;&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;The name of the game is that you only have approximately &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;170k of context window&lt;/strong&gt; to work with.
So it&#39;s essential to use as little of it as possible.
The more you use the context window, the worse the outcomes you&#39;ll get.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Geoff&#39;s solution to this engineering constraint is a technique he calls &lt;a href=&quot;https://ghuntley.com/ralph/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;Ralph Wiggum as a Software Engineer&lt;/a&gt;, which basically involves running an agent in a while loop forever with a simple prompt.&lt;/p&gt;
&lt;pre class=&quot;group&quot;&gt;&lt;pre class=&quot;prismjs rsh-code-block grid relative min-w-[250px] mb-6 bg-gray-400/5 p-4&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider border bg-transparent text-[var(--accent)] border-transparent hover:bg-[var(--accent)]/10 hover:border-[var(--accent)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-1 h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-10&quot; aria-label=&quot;Copy code&quot; title=&quot;Copy code&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-copy h-3 w-3&quot; aria-hidden=&quot;true&quot;&gt;&lt;rect width=&quot;14&quot; height=&quot;14&quot; x=&quot;8&quot; y=&quot;8&quot; rx=&quot;2&quot; ry=&quot;2&quot;&gt;&lt;/rect&gt;&lt;path d=&quot;M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;code class=&quot;overflow-x-auto&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;&quot;&gt;while :; do
&lt;/span&gt;  cat PROMPT.md | npx --yes @sourcegraph/amp
&lt;!-- --&gt;done&lt;/code&gt;&lt;/pre&gt;&lt;/pre&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;If you wanna learn more about ralph or what&#39;s in PROMPT.md, you can check out Geoff&#39;s post or dive into the project that &lt;a href=&quot;https://x.com/simonfarshid&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;@simonfarshid&lt;/a&gt;, &lt;a href=&quot;https://x.com/lantos1618&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;@lantos1618&lt;/a&gt;, &lt;a href=&quot;https://x.com/AVGVSTVS96&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;@AVGVSTVS96&lt;/a&gt; and I built at last weekend&#39;s YC Agents Hackathon, which was able to (mostly) &lt;a href=&quot;https://github.com/repomirrorhq/repomirror/blob/main/repomirror.md&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;port BrowserUse to TypeScript overnight&lt;/a&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Geoff describes ralph as a &quot;hilariously dumb&quot; solution to the context window problem. &lt;a href=&quot;https://ghuntley.com/content/images/size/w2400/2025/07/The-ralph-Process.png&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;I&#39;m not entirely sure that it is dumb&lt;/a&gt;.&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;Back to compaction: Using Sub-Agents&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Subagents are another way to manage context, and generic subagents (i.e. not &lt;a href=&quot;https://docs.anthropic.com/en/docs/claude-code/sub-agents&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;custom&lt;/a&gt; ones) have been a feature of claude code and many coding CLIs since the early days.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Subagents are not about &lt;a href=&quot;https://x.com/dexhorthy/status/1950288431122436597&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;playing house and anthropomorphizing roles&lt;/a&gt;. Subagents are about context control.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;The most common/straightforward use case for subagents is to let you use a fresh context window to do finding/searching/summarizing that enables the parent agent to get straight to work without clouding its context window with &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;Glob&lt;/code&gt; / &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;Grep&lt;/code&gt; / &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;Read&lt;/code&gt; / etc calls.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;a href=&quot;https://github.com/user-attachments/assets/cb4e7864-9556-4eaa-99ca-a105927f484d&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;https://github.com/user-attachments/assets/cb4e7864-9556-4eaa-99ca-a105927f484d&lt;/a&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/advanced-context-engineering/sub-agents.png&quot; alt=&quot;Sub-Agents&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;The ideal subagent response probably looks similar to the ideal ad-hoc compaction from above&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/advanced-context-engineering/output.png&quot; alt=&quot;Compaction Output&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Getting a subagent to return this is not trivial:&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/advanced-context-engineering/telephone.png&quot; alt=&quot;Telephone&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;What works even better: Frequent Intentional Compaction&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;The techniques I want to talk about and that we&#39;ve adopted in the last few months fall under what I call &quot;frequent intentional compaction&quot;.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Essentially, this means designing your ENTIRE WORKFLOW around context management, and keeping utilization in the 40%-60% range (depends on complexity of the problem ).&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;The way we do it is to split into three (ish) steps.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;I say &quot;ish&quot; because sometimes we skip the research and go straight to planning, and sometimes we&#39;ll do multiple passes of compacted research before we&#39;re ready to implement.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;I&#39;ll share example outputs of each step in a concrete example below. For a given feature or bug, we&#39;ll tend to do:&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Research&lt;/strong&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Understand the codebase, the files relevant to the issue, and how information flows, and perhaps potential causes of a problem.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;here&#39;s our &lt;a href=&quot;https://github.com/humanlayer/humanlayer/blob/main/.claude/commands/research_codebase.md&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;research prompt&lt;/a&gt;.
It currently uses custom subagents, but in other repos I use a more generic version that uses the claude code Task() tool with &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;general-agent&lt;/code&gt;.
The generic one works almost as well.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Plan&lt;/strong&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Outline the exact steps we&#39;ll take to fix the issue, and the files we&#39;ll need to edit and how, being super precise about the testing / verification steps in each phase.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;This is the &lt;a href=&quot;https://github.com/humanlayer/humanlayer/blob/main/.claude/commands/create_plan.md&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;prompt we use for planning&lt;/a&gt;.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Implement&lt;/strong&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Step through the plan, phase by phase. For complex work, I&#39;ll often compact the current status back into the original plan file after each implementation phase is verified.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;This is the &lt;a href=&quot;https://github.com/humanlayer/humanlayer/blob/main/.claude/commands/implement_plan.md&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;implementation prompt we use&lt;/a&gt;.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Aside - if you&#39;ve been hearing a lot about git worktrees, this is the only step that needs to be done in a worktree. We tend to do everything else on main.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;How we manage/share the markdown files&lt;/strong&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;I will skip this part for brevity but feel free to launch a claude session in &lt;a href=&quot;https://github.com/humanlayer/humanlayer&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;humanlayer/humanlayer&lt;/a&gt; and ask how the &quot;thoughts tool&quot; works.&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;Putting this into practice&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;I do a &lt;a href=&quot;https://github.com/ai-that-works/ai-that-works&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;weekly live-coding session&lt;/a&gt; with &lt;a href=&quot;https://www.linkedin.com/in/vaigup/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;@vaibhav&lt;/a&gt; where we whiteboard and code up a solution to an advanced AI Engineering problem. It&#39;s one of the highlights of my week.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Several weeks ago, I &lt;a href=&quot;https://hlyr.dev/he-gh&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;decided to share some more about the process&lt;/a&gt;, curious if our in-house techniques could one-shot a fix to a 300k LOC Rust codebase for BAML, a programming language for working with LLMs. I picked out &lt;a href=&quot;https://github.com/BoundaryML/baml/issues/1252&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;an (admittedly small-ish) bug&lt;/a&gt; from the @BoundaryML repo and got to work.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;You can &lt;a href=&quot;https://hlyr.dev/he-yt&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;watch the episode&lt;/a&gt; to learn more about the process, but to outline it:&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Worth noting&lt;/strong&gt;: I am at best an amateur Rust dev, and I have never worked in the BAML codebase before.&lt;/p&gt;
&lt;h4 class=&quot;text-xl mb-1 mt-8 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;#### &lt;!-- --&gt;The research&lt;/h4&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ul class=&quot;list-disc space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;I created a piece of research, I read it. Claude decided the bug was invalid and the codebase was correct.&lt;/li&gt;
&lt;li&gt;I threw that research out and kicked off a new one, with more steering.&lt;/li&gt;
&lt;li&gt;here is &lt;a href=&quot;https://github.com/ai-that-works/ai-that-works/blob/main/2025-08-05-advanced-context-engineering-for-coding-agents/thoughts/shared/research/2025-08-05_05-15-59_baml_test_assertions.md&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;the final research doc i ended up using&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;
&lt;h4 class=&quot;text-xl mb-1 mt-8 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;#### &lt;!-- --&gt;The plans&lt;/h4&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ul class=&quot;list-disc space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;While the research was running, I got impatient and kicked off a plan, with no research, to see if claude could go straight to an implementation plan - &lt;a href=&quot;https://github.com/ai-that-works/ai-that-works/blob/main/2025-08-05-advanced-context-engineering-for-coding-agents/thoughts/shared/plans/fix-assert-syntax-validation-no-research.md&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;you can see it here&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;When the research was done, I kicked off another implementation plan that used the research results - &lt;a href=&quot;https://github.com/ai-that-works/ai-that-works/blob/main/2025-08-05-advanced-context-engineering-for-coding-agents/thoughts/shared/plans/baml-test-assertion-validation-with-research.md&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;you can see it here&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;The plans are both fairly short, but they differ significantly. They fix the issue in different ways, and have different testing approaches. Without going too much into detail, they both &quot;would have worked&quot; but the one built with research fixed the problem in the &lt;em style=&quot;color:var(--text-secondary)&quot;&gt;best&lt;/em&gt; place and prescribed testing that was in line with the codebase conventions.&lt;/p&gt;
&lt;h4 class=&quot;text-xl mb-1 mt-8 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;#### &lt;!-- --&gt;The implementation&lt;/h4&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ul class=&quot;list-disc space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;This was all happening the night before the podcast recording. I ran both plans in parallel and submitted both as PRs before signing off for the night.&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;By the time we were on the show at 10am PT the next day, &lt;a href=&quot;https://github.com/BoundaryML/baml/pull/2259#issuecomment-3155883849&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;the PR from the plan with the research was already approved by @aaron&lt;/a&gt;, who didn&#39;t even know I was doing a bit for a podcast 🙂. We &lt;a href=&quot;https://github.com/BoundaryML/baml/pull/2258/files&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;closed the other one&lt;/a&gt;.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;So out of our original 4 goals, we hit:&lt;/p&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ul class=&quot;list-disc space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;✅ Works in brownfield codebases (300k LOC rust project)&lt;/li&gt;
&lt;li&gt;Solves complex problems&lt;/li&gt;
&lt;li&gt;✅ no slop (pr merged)&lt;/li&gt;
&lt;li&gt;Keeps mental alignment&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;Solving complex problems&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Vaibhav was still skeptical, and I wanted to see if we could solve a more complex problem.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;So a few weeks later, the two of us spent 7 hours (3 hours on research/plans, 4 hours on implementation) and shipped 35k LOC to add cancellation and wasm support to BAML.
The &lt;a href=&quot;https://github.com/BoundaryML/baml/pull/2357&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;cancelation PR just got merged last week&lt;/a&gt;. &lt;a href=&quot;https://github.com/BoundaryML/baml/pull/2330&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;The WASM one is still open&lt;/a&gt;, but has a working demo of calling the wasm-compiled rust runtime from a JS app in the browser.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;While the cancelation PR required a little more love to take things over the line, we got incredible progress in just a day. Vaibhav estimated that each of these PRs would have been 3-5 days of work for a senior engineer on the BAML team to complete.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;✅ So we can solve complex problems too.&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;This is not Magic&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Remember that part in the example where I read the research and threw it out cause it was wrong? Or me and Vaibhav sitting DEEPLY ENGAGED FOR 7 HOURS? You have to engage with your task when you&#39;re doing this or it WILL NOT WORK.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;There&#39;s a certain type of person who is always looking for the one magic prompt that will solve all their problems. It doesn&#39;t exist.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Frequent Intentional Compaction via a research/plan/implement flow will make your performance &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;better&lt;/strong&gt;, but what makes it &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;good enough for hard problems&lt;/strong&gt; is that you build high-leverage human review into your pipeline.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/advanced-context-engineering/workflow.png&quot; alt=&quot;Workflow&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;Eggs on Faces&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;A few weeks back, &lt;a href=&quot;https://www.linkedin.com/in/bhsmith/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;@blakesmith&lt;/a&gt; and I sat down for 7 hours and &lt;a href=&quot;https://github.com/dexhorthy/parquet-java/blob/remove-hadoop/thoughts/shared/plans/remove-hadoop-dependencies.md&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;tried to remove hadoop dependencies from parquet java&lt;/a&gt; - the deep dive on everything that went wrong and my theories as to why, I&#39;ll save for another post, suffice it to say that it did not go well. The tl;dr is that the research steps didn&#39;t go deep enough through the dependency tree, and assumed classes could be moved upstream without introducing deeply nested hadoop dependencies.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;There are big hard problems you cannot just prompt your way through in 7 hours, and we&#39;re still curiously and excitedly hacking on pushing the boundaries with friends and partners. I think the other learning here is that you probably need at least one person who is an expert in the codebase, and for this case, that was neither of us.&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;On Human Leverage&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;If there&#39;s one thing you take away from all this, let it be this:&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;A bad line of code is… a bad line of code.
But a bad line of a &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;plan&lt;/strong&gt; could lead to hundreds of bad lines of code.
And a bad line of &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;research&lt;/strong&gt;, a misunderstanding of how the codebase works or where certain functionality is located, could land you with thousands of bad lines of code.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/advanced-context-engineering/cascade.png&quot; alt=&quot;Quality Cascade&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;So you want to &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;focus human effort and attention&lt;/strong&gt; on the HIGHEST LEVERAGE parts of the pipeline.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/advanced-context-engineering/leverage.png&quot; alt=&quot;Hierarchy of Leverage&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;When you review the research and the plans, you get more leverage than you do when you review the code. (By the way, one of our primary focuses @ &lt;a href=&quot;https://hlyr.dev/code&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;humanlayer&lt;/a&gt; is helping teams build and leverage high-quality workflow prompts and crafting great collaboration workflows for ai-generated code and specs).&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;What is code review for?&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;People have a lot of different opinions on what code review is for.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;I prefer &lt;a href=&quot;https://blakesmith.me/2015/02/09/code-review-essentials-for-software-teams.html&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;Blake Smith&#39;s framing in Code Review Essentials for Software Teams&lt;/a&gt;, where he says the most important part of code review is mental alignment - keeping members of the team on the page as to how the code is changing and why.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/advanced-context-engineering/code-review-hierarchy-of-needs.png&quot; alt=&quot;Code Review Hierarchy of Needs&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Remember those 2k line golang PRs? I cared about them being correct and well designed, but the biggest source of internal unrest and frustration on the team was the lack of mental alignment. &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;I was starting to lose touch with what our product was and how it worked.&lt;/strong&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;I would expect that anyone who&#39;s worked with a very productive AI coder has had this experience.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;This is actually the most important part of research/plan/implement to us.
A guaranteed side effect of everyone shipping way more code is that a much larger proportion of your codebase is going to be unfamiliar to any given engineer at any point in time.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;I won&#39;t even try to convince you that research/plan/implement is the right approach for most teams - it probably isn&#39;t. But you ABSOLUTELY need an engineering process that&lt;/p&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ol class=&quot;list-decimal space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;keeps team members on the same page&lt;/li&gt;
&lt;li&gt;enables team members to quickly learn about unfamiliar parts of the codebase&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;For most teams, this is pull requests and internal docs. For us, it&#39;s now specs, plans, and research.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;I can&#39;t read 2000 lines of golang daily. But I &lt;em style=&quot;color:var(--text-secondary)&quot;&gt;can&lt;/em&gt; read 200 lines of a well-written implementation plan.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;I can&#39;t go spelunking through 40+ files of daemon code for an hour+ when something is broken (okay, I can, but I don&#39;t want to). I &lt;em style=&quot;color:var(--text-secondary)&quot;&gt;can&lt;/em&gt; steer a research prompt to give me the speed-run on where I should be looking and why.&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;Recap&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Basically we got everything we needed.&lt;/p&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ul class=&quot;list-disc space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;✅ Works in brownfield codebases&lt;/li&gt;
&lt;li&gt;✅ Solves complex problems&lt;/li&gt;
&lt;li&gt;✅ No slop&lt;/li&gt;
&lt;li&gt;✅ Maintains mental alignment&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;(oh, and yeah, our team of three is averaging about $12k on opus per month)&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;So you don&#39;t think I&#39;m just another &lt;a href=&quot;https://www.youtube.com/watch?v=IS_y40zY-hc&amp;amp;lc=UgzFldRM6LU5unLuFn54AaABAg.AMKlTmJAT5ZAMKrOOAMw3I&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;hyped up mustachio&#39;d sales guy&lt;/a&gt;, I&#39;ll note that this does not work perfectly for every problem (we&#39;ll be back for another round sound, parquet-java).&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;In August the whole team spent 2 weeks spinning circles on a really tricky race condition that spiraled into a rabbit hole of issues with MCP sHTTP keepalives in golang and a whole bunch of other dead ends.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;But that&#39;s the exception now. In general, this works well for us. Our intern shipped 2 PRs on his first day, and 10 on his 8th day. I was genuinely skeptical that it would work for anyone else, but me and Vaibhav shipped 35k LOC of working BAML code in 7 hours. (And if you haven&#39;t met Vaibhav, he&#39;s one of the most meticulous engineers I know when it comes to code design and quality.)&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;What&#39;s coming&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;I&#39;m reasonably confident that coding agents will be commoditized.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;The hard part will be the team and workflow transformation. Everything about collaboration will change in a world where AI writes 99% of our code.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;And I believe pretty strongly that if you don&#39;t figure this out, you&#39;re gonna get lapped by someone who did.&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;okay so clearly you have something to sell me&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;We&#39;re pretty bullish on spec-first, agentic workflows, so we&#39;re building tools to make it easier. Among many things, I&#39;m obsessed with the problem of scaling these &quot;frequent intentional compaction&quot; workflows collaboratively across large teams.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Today, we&#39;re launching CodeLayer, our new &quot;post-IDE IDE&quot; in private beta - think &quot;Superhuman for claude code&quot;. If you&#39;re a fan of Superhuman and/or vim mode and you&#39;re ready to move beyond &quot;vibe coding&quot; and get serious about building with agents, we&#39;d love to have you join the waitlist.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Sign up at &lt;a href=&quot;https://humanlayer.dev/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;https://humanlayer.dev&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;For OSS Maintainers - lets ship something together&lt;/h2&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;If you are a maintainer on a complex OSS project and based in the bay area, my open offer - I will pair with you in-person in SF for 7 hours on a saturday and see if we can ship something big.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;I get a lot of learning about the limitations and where these techniques fall short (and, with any luck, a working merged PR that adds a ton of value that I can point to). You get to learn the workflow in the only way I&#39;ve found that works well - direct 1x1 pairing.&lt;/p&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;For Engineering Leaders&lt;/h2&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;If you or someone you know is an engineering leader that wants to 10x their team&#39;s productivity with AI, we&#39;re forward-deploying with teams of all sizes to help drive the culture/process/tech shift needed to transition to an ai-first coding world.&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;Thanks&lt;/h3&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ul class=&quot;list-disc space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;Thanks to all the friends and founders who&#39;ve listened through early ramble-y versions of this post - Adam, Josh, Andrew, and many many more&lt;/li&gt;
&lt;li&gt;Thanks Sundeep for weathering this wacky storm&lt;/li&gt;
&lt;li&gt;Thanks Allison, Geoff, and Gerred for dragging us kicking and screaming into the future&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;</description><link>https://www.humanlayer.dev/blog/advanced-context-engineering</link><guid isPermaLink="false">https://www.humanlayer.dev/blog/advanced-context-engineering</guid><pubDate>Thu, 28 Aug 2025 16:00:00 GMT</pubDate><author>Dex</author><category>agents</category><category>claudecode</category><category>best-practices</category></item><item><title>12 Factor Agents</title><description>&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Based on the original 12 Factor Agents post &lt;a href=&quot;https://github.com/humanlayer/12-factor-agents&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;on GitHub&lt;/a&gt;. &lt;em style=&quot;color:var(--text-secondary)&quot;&gt;In the spirit of &lt;a href=&quot;https://12factor.net/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;12 Factor Apps&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;Introduction&lt;/h2&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;I&#39;ve tried every agent framework out there, from the plug-and-play crew/langchains to the &quot;minimalist&quot; smolagents of the world to the &quot;production grade&quot; langraph, griptape, etc.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;I&#39;ve talked to a lot of really strong founders, in and out of YC, who are all building really impressive things with AI. Most of them are rolling the stack themselves. I don&#39;t see a lot of frameworks in production customer-facing agents.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;I&#39;ve been surprised to find that most of the products out there billing themselves as &quot;AI Agents&quot; are not all that agentic. A lot of them are mostly deterministic code, with LLM steps sprinkled in at just the right points to make the experience truly magical.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Agents, at least the good ones, don&#39;t follow the &quot;here&#39;s your prompt, here&#39;s a bag of tools, loop until you hit the goal&quot; pattern. Rather, they are comprised of mostly just software.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;So, I set out to answer:&lt;/p&gt;
&lt;blockquote class=&quot;border-l-4 pl-4 my-4 italic&quot; style=&quot;border-color:var(--accent);color:var(--text-muted)&quot;&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;What are the principles we can use to build LLM-powered software that is actually good enough to put in the hands of production customers?&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;Table of Contents&lt;/h2&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ul class=&quot;list-disc space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;&lt;a href=&quot;https://www.humanlayer.dev/blog/12-factor-agents#how-we-got-here-a-brief-history-of-software&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;How We Got Here: A Brief History of Software&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.humanlayer.dev/blog/12-factor-agents#factor-1-natural-language-to-tool-calls&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;Factor 1: Natural Language to Tool Calls&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.humanlayer.dev/blog/12-factor-agents#factor-2-own-your-prompts&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;Factor 2: Own Your Prompts&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.humanlayer.dev/blog/12-factor-agents#factor-3-own-your-context-window&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;Factor 3: Own Your Context Window&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.humanlayer.dev/blog/12-factor-agents#factor-4-tools-are-just-structured-outputs&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;Factor 4: Tools Are Just Structured Outputs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.humanlayer.dev/blog/12-factor-agents#factor-5-unify-execution-state-and-business-state&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;Factor 5: Unify Execution State and Business State&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.humanlayer.dev/blog/12-factor-agents#factor-6-launchpauseresume-with-simple-apis&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;Factor 6: Launch/Pause/Resume with Simple APIs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.humanlayer.dev/blog/12-factor-agents#factor-7-contact-humans-with-tool-calls&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;Factor 7: Contact Humans with Tool Calls&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.humanlayer.dev/blog/12-factor-agents#factor-8-own-your-control-flow&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;Factor 8: Own Your Control Flow&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.humanlayer.dev/blog/12-factor-agents#factor-9-compact-errors-into-context-window&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;Factor 9: Compact Errors into Context Window&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.humanlayer.dev/blog/12-factor-agents#factor-10-small-focused-agents&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;Factor 10: Small, Focused Agents&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.humanlayer.dev/blog/12-factor-agents#factor-11-trigger-from-anywhere&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;Factor 11: Trigger from Anywhere&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.humanlayer.dev/blog/12-factor-agents#factor-12-make-your-agent-a-stateless-reducer&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;Factor 12: Make Your Agent a Stateless Reducer&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;
&lt;hr class=&quot;my-8&quot; style=&quot;border-color:var(--border-color)&quot;&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;How We Got Here: A Brief History of Software&lt;/h2&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;You don&#39;t have to listen to me&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Whether you&#39;re new to agents or an ornery old veteran like me, I&#39;m going to try to convince you to throw out most of what you think about AI Agents, take a step back, and rethink them from first principles. (spoiler alert if you didn&#39;t catch the OpenAI responses launch a few weeks back, but pushing MORE agent logic behind an API ain&#39;t it)&lt;/p&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;Agents are software, and a brief history thereof&lt;/h2&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;let&#39;s talk about how we got here&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;60 years ago&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;We&#39;re gonna talk a lot about Directed Graphs (DGs) and their Acyclic friends, DAGs. I&#39;ll start by pointing out that...well...software is a directed graph. There&#39;s a reason we used to represent programs as flow charts.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/12-factor-agents/010-software-dag.png&quot; alt=&quot;010-software-dag&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;20 years ago&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Around 20 years ago, we started to see DAG orchestrators become popular. We&#39;re talking classics like &lt;a href=&quot;https://airflow.apache.org/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;Airflow&lt;/a&gt;, &lt;a href=&quot;https://www.prefect.io/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;Prefect&lt;/a&gt;, some predecessors, and some newer ones like (&lt;a href=&quot;https://dagster.io/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;dagster&lt;/a&gt;, &lt;a href=&quot;https://www.inngest.com/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;inggest&lt;/a&gt;, &lt;a href=&quot;https://www.windmill.dev/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;windmill&lt;/a&gt;). These followed the same graph pattern, with the added benefit of observability, modularity, retries, administration, etc.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/12-factor-agents/015-dag-orchestrators.png&quot; alt=&quot;015-dag-orchestrators&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;10-15 years ago&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;When ML models started to get good enough to be useful, we started to see DAGs with ML models sprinkled in. You might imagine steps like &quot;summarize the text in this column into a new column&quot; or &quot;classify the support issues by severity or sentiment&quot;.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/12-factor-agents/020-dags-with-ml.png&quot; alt=&quot;020-dags-with-ml&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;But at the end of the day, it&#39;s still mostly the same good old deterministic software.&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;The promise of agents&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;I&#39;m not the first &lt;a href=&quot;https://youtu.be/Dc99-zTMyMg?si=bcT0hIwWij2mR-40&amp;amp;t=73&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;person to say this&lt;/a&gt;, but my biggest takeaway when I started learning about agents, was that you get to throw the DAG away. Instead of software engineers coding each step and edge case, you can give the agent a goal and a set of transitions:&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/12-factor-agents/025-agent-dag.png&quot; alt=&quot;025-agent-dag&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;And let the LLM make decisions in real time to figure out the path&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/12-factor-agents/026-agent-dag-lines.png&quot; alt=&quot;026-agent-dag-lines&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;The promise here is that you write less software, you just give the LLM the &quot;edges&quot; of the graph and let it figure out the nodes. You can recover from errors, you can write less code, and you may find that LLMs find novel solutions to problems.&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;Agents as loops&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Put another way, you&#39;ve got this loop consisting of 3 steps:&lt;/p&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ol class=&quot;list-decimal space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;LLM determines the next step in the workflow, outputting structured json (&quot;tool calling&quot;)&lt;/li&gt;
&lt;li&gt;Deterministic code executes the tool call&lt;/li&gt;
&lt;li&gt;The result is appended to the context window&lt;/li&gt;
&lt;li&gt;repeat until the next step is determined to be &quot;done&quot;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;pre class=&quot;group&quot;&gt;&lt;pre class=&quot;prismjs rsh-code-block grid relative min-w-[250px] mb-6 bg-gray-400/5 p-4&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider border bg-transparent text-[var(--accent)] border-transparent hover:bg-[var(--accent)]/10 hover:border-[var(--accent)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-1 h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-10&quot; aria-label=&quot;Copy code&quot; title=&quot;Copy code&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-copy h-3 w-3&quot; aria-hidden=&quot;true&quot;&gt;&lt;rect width=&quot;14&quot; height=&quot;14&quot; x=&quot;8&quot; y=&quot;8&quot; rx=&quot;2&quot; ry=&quot;2&quot;&gt;&lt;/rect&gt;&lt;path d=&quot;M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;code class=&quot;overflow-x-auto&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;&quot;&gt;initial_event &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;message&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;...&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;context &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;&quot;&gt;initial_event&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;while&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token boolean&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  next_step &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;&quot;&gt; llm&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;determine_next_step&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;&quot;&gt;context&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  context&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;&quot;&gt;next_step&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;&quot;&gt;next_step&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;intent &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;done&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;&quot;&gt; next_step&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;final_answer
&lt;/span&gt;
&lt;span class=&quot;&quot;&gt;  result &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;&quot;&gt; execute_step&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;&quot;&gt;next_step&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  context&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/pre&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Our initial context is just the starting event (maybe a user message, maybe a cron fired, maybe a webhook, etc),
and we ask the llm to choose the next step (tool) or to determine that we&#39;re done.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Here&#39;s a multi-step example:&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/12-factor-agents/027-agent-loop-animation.gif&quot; alt=&quot;027-agent-loop-animation&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;And the &quot;materialized&quot; DAG that was generated would look something like:&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/12-factor-agents/027-agent-loop-dag.png&quot; alt=&quot;027-agent-loop-dag&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;The problem with this &quot;loop until you solve it&quot; pattern&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;The biggest problems with this pattern:&lt;/p&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ul class=&quot;list-disc space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;Agents get lost when the context window gets too long - they spin out trying the same broken approach over and over again&lt;/li&gt;
&lt;li&gt;literally thats it, but that&#39;s enough to kneecap the approach&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Even if you haven&#39;t hand-rolled an agent, you&#39;ve probably seen this long-context problem in working with agentic coding tools. They just get lost after a while and you need to start a new chat.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;I&#39;ll even perhaps posit something I&#39;ve heard in passing quite a bit, and that YOU probably have developed your own intuition around:&lt;/p&gt;
&lt;blockquote class=&quot;border-l-4 pl-4 my-4 italic&quot; style=&quot;border-color:var(--accent);color:var(--text-muted)&quot;&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Even as models support longer and longer context windows, you&#39;ll ALWAYS get better results with a small, focused prompt and context&lt;/strong&gt;&lt;/h3&gt;
&lt;/blockquote&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Most builders I&#39;ve talked to &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;pushed the &quot;tool calling loop&quot; idea to the side&lt;/strong&gt; when they realized that anything more than 10-20 turns becomes a big mess that the LLM can&#39;t recover from. Even if the agent gets it right 90% of the time, that&#39;s miles away from &quot;good enough to put in customer hands&quot;. Can you imagine a web app that crashed on 10% of page loads?&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;What actually works - micro agents&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;One thing that I &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;have&lt;/strong&gt; seen in the wild quite a bit is taking the agent pattern and sprinkling it into a broader more deterministic DAG.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/12-factor-agents/028-micro-agent-dag.png&quot; alt=&quot;028-micro-agent-dag&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;You might be asking - &quot;why use agents at all in this case?&quot; - we&#39;ll get into that shortly, but basically, having language models managing well-scoped sets of tasks makes it easy to incorporate live human feedback, translating it into workflow steps without spinning out into context error loops.&lt;/p&gt;
&lt;blockquote class=&quot;border-l-4 pl-4 my-4 italic&quot; style=&quot;border-color:var(--accent);color:var(--text-muted)&quot;&gt;
&lt;h4 class=&quot;text-xl mb-1 mt-8 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;#### &lt;!-- --&gt;having language models managing well-scoped sets of tasks makes it easy to incorporate live human feedback...without spinning out into context error loops&lt;/h4&gt;
&lt;/blockquote&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;A real life micro agent&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Here&#39;s an example of how deterministic code might run one micro agent responsible for handling the human-in-the-loop steps for deployment.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/12-factor-agents/029-deploybot-high-level.png&quot; alt=&quot;029-deploybot-high-level&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ul class=&quot;list-disc space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Human&lt;/strong&gt; Merges PR to GitHub main branch&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Deterministic Code&lt;/strong&gt; Deploys to staging env&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Deterministic Code&lt;/strong&gt; Runs end-to-end (e2e) tests against staging&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Deterministic Code&lt;/strong&gt; Hands to agent for prod deployment, with initial context: &quot;deploy SHA 4af9ec0 to production&quot;&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Agent&lt;/strong&gt; calls &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;deploy_frontend_to_prod(4af9ec0)&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Deterministic code&lt;/strong&gt; requests human approval on this action&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Human&lt;/strong&gt; Rejects the action with feedback &quot;can you deploy the backend first?&quot;&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Agent&lt;/strong&gt; calls &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;deploy_backend_to_prod(4af9ec0)&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Deterministic code&lt;/strong&gt; requests human approval on this action&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Human&lt;/strong&gt; approves the action&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Deterministic code&lt;/strong&gt; executed the backend deployment&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Agent&lt;/strong&gt; calls &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;deploy_frontend_to_prod(4af9ec0)&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Deterministic code&lt;/strong&gt; requests human approval on this action&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Human&lt;/strong&gt; approves the action&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Deterministic code&lt;/strong&gt; executed the frontend deployment&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Agent&lt;/strong&gt; determines that the task was completed successfully, we&#39;re done!&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Deterministic code&lt;/strong&gt; run the end-to-end tests against production&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Deterministic code&lt;/strong&gt; task completed, OR pass to rollback agent to review failures and potentially roll back&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/12-factor-agents/033-deploybot.gif&quot; alt=&quot;033-deploybot-animation&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;This example is based on a real life &lt;a href=&quot;https://github.com/got-agents/agents/tree/main/deploybot-ts&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;OSS agent we&#39;ve shipped to manage our deployments at Humanlayer&lt;/a&gt; - here is a real conversation I had with it last week:&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/12-factor-agents/035-deploybot-conversation.png&quot; alt=&quot;035-deploybot-conversation&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;We haven&#39;t given this agent a huge pile of tools or tasks. The primary value in the LLM is parsing the human&#39;s plaintext feedback and proposing an updated course of action. We isolate tasks and contexts as much as possible to keep the LLM focused on a small, 5-10 step workflow.&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;So what&#39;s an agent really?&lt;/h3&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ul class=&quot;list-disc space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;prompt&lt;/strong&gt; - tell an LLM how to behave, and what &quot;tools&quot; it has available. The output of the prompt is a JSON object that describe the next step in the workflow (the &quot;tool call&quot; or &quot;function call&quot;).&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;switch statement&lt;/strong&gt; - based on the JSON that the LLM returns, decide what to do with it.&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;accumulated context&lt;/strong&gt; - store the list of steps that have happened and their results&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;for loop&lt;/strong&gt; - until the LLM emits some sort of &quot;Terminal&quot; tool call (or plaintext response), add the result of the switch statement to the context window and ask the LLM to choose the next step.&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/12-factor-agents/040-4-components.png&quot; alt=&quot;040-4-components&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;In the &quot;deploybot&quot; example, we gain a couple benefits from owning the control flow and context accumulation:&lt;/p&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ul class=&quot;list-disc space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;In our &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;switch statement&lt;/strong&gt; and &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;for loop&lt;/strong&gt;, we can hijack control flow to pause for human input or to wait for completion of long-running tasks&lt;/li&gt;
&lt;li&gt;We can trivially serialize the &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;context&lt;/strong&gt; window for pause+resume&lt;/li&gt;
&lt;li&gt;In our &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;prompt&lt;/strong&gt;, we can optimize the heck out of how we pass instructions and &quot;what happened so far&quot; to the LLM&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;
&lt;hr class=&quot;my-8&quot; style=&quot;border-color:var(--border-color)&quot;&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;Factor 1: Natural Language to Tool Calls&lt;/h2&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;One of the most common patterns in agent building is to convert natural language to structured tool calls. This is a powerful pattern that allows you to build agents that can reason about tasks and execute them.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/12-factor-agents/110-natural-language-tool-calls.png&quot; alt=&quot;110-natural-language-tool-calls&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;This pattern, when applied atomically, is the simple translation of a phrase like&lt;/p&gt;
&lt;blockquote class=&quot;border-l-4 pl-4 my-4 italic&quot; style=&quot;border-color:var(--accent);color:var(--text-muted)&quot;&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;can you create a payment link for $750 to Terri for sponsoring the february AI tinkerers meetup?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;to a structured object that describes a Stripe API call like&lt;/p&gt;
&lt;pre class=&quot;group&quot;&gt;&lt;pre class=&quot;prismjs rsh-code-block grid relative min-w-[250px] mb-6 bg-gray-400/5 p-4&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider border bg-transparent text-[var(--accent)] border-transparent hover:bg-[var(--accent)]/10 hover:border-[var(--accent)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-1 h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-10&quot; aria-label=&quot;Copy code&quot; title=&quot;Copy code&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-copy h-3 w-3&quot; aria-hidden=&quot;true&quot;&gt;&lt;rect width=&quot;14&quot; height=&quot;14&quot; x=&quot;8&quot; y=&quot;8&quot; rx=&quot;2&quot; ry=&quot;2&quot;&gt;&lt;/rect&gt;&lt;path d=&quot;M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;code class=&quot;overflow-x-auto&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token property&quot;&gt;&quot;function&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token property&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;create_payment_link&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token property&quot;&gt;&quot;parameters&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token property&quot;&gt;&quot;amount&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;750&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token property&quot;&gt;&quot;customer&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;cust_128934ddasf9&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token property&quot;&gt;&quot;product&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;prod_8675309&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token property&quot;&gt;&quot;price&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;prc_09874329fds&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token property&quot;&gt;&quot;quantity&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token property&quot;&gt;&quot;memo&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Hey Jeff - see below for the payment link for the february ai tinkerers meetup&quot;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/pre&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Note&lt;/strong&gt;: in reality the stripe API is a bit more complex, a &lt;a href=&quot;https://github.com/dexhorthy/mailcrew&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;real agent that does this&lt;/a&gt; (&lt;a href=&quot;https://www.youtube.com/watch?v=f_cKnoPC_Oo&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;video&lt;/a&gt;) would list customers, list products, list prices, etc to build this payload with the proper ids, or include those ids in the prompt/context window (we&#39;ll see below how those are kinda the same thing though!)&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;From there, deterministic code can pick up the payload and do something with it.&lt;/p&gt;
&lt;pre class=&quot;group&quot;&gt;&lt;pre class=&quot;prismjs rsh-code-block grid relative min-w-[250px] mb-6 bg-gray-400/5 p-4&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider border bg-transparent text-[var(--accent)] border-transparent hover:bg-[var(--accent)]/10 hover:border-[var(--accent)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-1 h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-10&quot; aria-label=&quot;Copy code&quot; title=&quot;Copy code&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-copy h-3 w-3&quot; aria-hidden=&quot;true&quot;&gt;&lt;rect width=&quot;14&quot; height=&quot;14&quot; x=&quot;8&quot; y=&quot;8&quot; rx=&quot;2&quot; ry=&quot;2&quot;&gt;&lt;/rect&gt;&lt;path d=&quot;M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;code class=&quot;overflow-x-auto&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;# The LLM takes natural language and returns a structured object&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;nextStep &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;&quot;&gt; llm&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;determineNextStep&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token triple-quoted-string string&quot;&gt;&quot;&quot;&quot;
&lt;/span&gt;&lt;span class=&quot;token triple-quoted-string string&quot;&gt;  create a payment link for $750 to Jeff
&lt;/span&gt;&lt;span class=&quot;token triple-quoted-string string&quot;&gt;  for sponsoring the february AI tinkerers meetup
&lt;/span&gt;&lt;span class=&quot;token triple-quoted-string string&quot;&gt;  &quot;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;# Handle the structured output based on its function&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;&quot;&gt; nextStep&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;function &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;create_payment_link&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    stripe&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;paymentlinks&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;create&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;&quot;&gt;nextStep&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;parameters&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;# or whatever you want, see below&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;elif&lt;/span&gt;&lt;span class=&quot;&quot;&gt; nextStep&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;function &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;something_else&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;# ... more cases&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;pass&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;# the model didn&#39;t call a tool we know about&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;# do something else&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;pass&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/pre&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;NOTE&lt;/strong&gt;: While a full agent would then receive the API call result and loop with it, eventually returning something like&lt;/p&gt;
&lt;blockquote class=&quot;border-l-4 pl-4 my-4 italic&quot; style=&quot;border-color:var(--accent);color:var(--text-muted)&quot;&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;I&#39;ve successfully created a payment link for $750 to Terri for sponsoring the february AI tinkerers meetup. Here&#39;s the link: &lt;a href=&quot;https://buy.stripe.com/test_1234567890&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;https://buy.stripe.com/test_1234567890&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Instead&lt;/strong&gt;, We&#39;re actually going to skip that step here, and save it for another factor, which you may or may not want to also incorporate (up to you!)&lt;/p&gt;
&lt;hr class=&quot;my-8&quot; style=&quot;border-color:var(--border-color)&quot;&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;Factor 2: Own Your Prompts&lt;/h2&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Don&#39;t outsource your prompt engineering to a framework.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/12-factor-agents/120-own-your-prompts.png&quot; alt=&quot;120-own-your-prompts&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;By the way, &lt;a href=&quot;https://hamel.dev/blog/posts/prompt/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;this is far from novel advice:&lt;/a&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Some frameworks provide a &quot;black box&quot; approach like this:&lt;/p&gt;
&lt;pre class=&quot;group&quot;&gt;&lt;pre class=&quot;prismjs rsh-code-block grid relative min-w-[250px] mb-6 bg-gray-400/5 p-4&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider border bg-transparent text-[var(--accent)] border-transparent hover:bg-[var(--accent)]/10 hover:border-[var(--accent)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-1 h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-10&quot; aria-label=&quot;Copy code&quot; title=&quot;Copy code&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-copy h-3 w-3&quot; aria-hidden=&quot;true&quot;&gt;&lt;rect width=&quot;14&quot; height=&quot;14&quot; x=&quot;8&quot; y=&quot;8&quot; rx=&quot;2&quot; ry=&quot;2&quot;&gt;&lt;/rect&gt;&lt;path d=&quot;M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;code class=&quot;overflow-x-auto&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;&quot;&gt;agent &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;&quot;&gt; Agent&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  role&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;...&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  goal&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;...&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  personality&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;...&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  tools&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;&quot;&gt;tool1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt; tool2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt; tool3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;&quot;&gt;task &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;&quot;&gt; Task&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  instructions&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;...&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  expected_output&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;&quot;&gt;OutputModel
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;&quot;&gt;result &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;&quot;&gt; agent&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;&quot;&gt;task&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/pre&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;This is great for pulling in some TOP NOTCH prompt engineering to get you started, but it is often difficult to tune and/or reverse engineer to get exactly the right tokens into your model.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Instead, own your prompts and treat them as first-class code:&lt;/p&gt;
&lt;pre class=&quot;group&quot;&gt;&lt;pre class=&quot;prismjs rsh-code-block grid relative min-w-[250px] mb-6 bg-gray-400/5 p-4&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider border bg-transparent text-[var(--accent)] border-transparent hover:bg-[var(--accent)]/10 hover:border-[var(--accent)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-1 h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-10&quot; aria-label=&quot;Copy code&quot; title=&quot;Copy code&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-copy h-3 w-3&quot; aria-hidden=&quot;true&quot;&gt;&lt;rect width=&quot;14&quot; height=&quot;14&quot; x=&quot;8&quot; y=&quot;8&quot; rx=&quot;2&quot; ry=&quot;2&quot;&gt;&lt;/rect&gt;&lt;path d=&quot;M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;code class=&quot;overflow-x-auto&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;&quot;&gt;function &lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;DetermineNextStep&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;&quot;&gt;thread&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;DoneForNow&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;ListGitTags&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;DeployBackend&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;DeployFrontend&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;RequestMoreInformation&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  prompt #&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;
&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;    {{ _.role(&quot;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;system&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;) }}
&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;    You are a helpful assistant that manages deployments for frontend and backend systems.
&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;    You work diligently to ensure safe and successful deployments by following best practices
&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;    and proper deployment procedures.
&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;    Before deploying any system, you should check:
&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;    - The deployment environment (staging vs production)
&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;    - The correct tag/version to deploy
&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;    - The current system status
&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;    You can use tools like deploy_backend, deploy_frontend, and check_deployment_status
&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;    to manage deployments. For sensitive deployments, use request_approval to get
&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;    human verification.
&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;    Always think about what to do first, like:
&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;    - Check current deployment status
&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;    - Verify the deployment tag exists
&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;    - Request approval if needed
&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;    - Deploy to staging before production
&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;    - Monitor deployment progress
&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;    {{ _.role(&quot;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;use&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;r&quot;) }}
&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;    {{ thread }}
&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;    What should the next step be?
&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;  &quot;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;#
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/pre&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;(the above example uses &lt;a href=&quot;https://github.com/boundaryml/baml&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;BAML&lt;/a&gt; to generate the prompt, but you can do this with any prompt engineering tool you want, or even just template it manually)&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;If the signature looks a little funny, we&#39;ll get to that in &lt;a href=&quot;https://www.humanlayer.dev/blog/12-factor-agents#factor-4-tools-are-just-structured-outputs&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;factor 4 - tools are just structured outputs&lt;/a&gt;&lt;/p&gt;
&lt;pre class=&quot;group&quot;&gt;&lt;pre class=&quot;prismjs rsh-code-block grid relative min-w-[250px] mb-6 bg-gray-400/5 p-4&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider border bg-transparent text-[var(--accent)] border-transparent hover:bg-[var(--accent)]/10 hover:border-[var(--accent)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-1 h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-10&quot; aria-label=&quot;Copy code&quot; title=&quot;Copy code&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-copy h-3 w-3&quot; aria-hidden=&quot;true&quot;&gt;&lt;rect width=&quot;14&quot; height=&quot;14&quot; x=&quot;8&quot; y=&quot;8&quot; rx=&quot;2&quot; ry=&quot;2&quot;&gt;&lt;/rect&gt;&lt;path d=&quot;M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;code class=&quot;overflow-x-auto&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;DetermineNextStep&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;&quot;&gt;thread&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;&quot;&gt; DoneForNow &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;&quot;&gt; ListGitTags &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;&quot;&gt; DeployBackend &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;&quot;&gt; DeployFrontend &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;&quot;&gt; RequestMoreInformation &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/pre&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Key benefits of owning your prompts:&lt;/p&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ol class=&quot;list-decimal space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Full Control&lt;/strong&gt;: Write exactly the instructions your agent needs, no black box abstractions&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Testing and Evals&lt;/strong&gt;: Build tests and evals for your prompts just like you would for any other code&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Iteration&lt;/strong&gt;: Quickly modify prompts based on real-world performance&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Transparency&lt;/strong&gt;: Know exactly what instructions your agent is working with&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Role Hacking&lt;/strong&gt;: take advantage of APIs that support nonstandard usage of user/assistant roles - for example, the now-deprecated non-chat flavor of OpenAI &quot;completions&quot; API. This includes some so-called &quot;model gaslighting&quot; techniques&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Remember: Your prompts are the primary interface between your application logic and the LLM.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Having full control over your prompts gives you the flexibility and prompt control you need for production-grade agents.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;I don&#39;t know what&#39;s the best prompt, but I know you want the flexibility to be able to try EVERYTHING.&lt;/p&gt;
&lt;hr class=&quot;my-8&quot; style=&quot;border-color:var(--border-color)&quot;&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;Factor 3: Own Your Context Window&lt;/h2&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;You don&#39;t necessarily need to use standard message-based formats for conveying context to an LLM.&lt;/p&gt;
&lt;blockquote class=&quot;border-l-4 pl-4 my-4 italic&quot; style=&quot;border-color:var(--accent);color:var(--text-muted)&quot;&gt;
&lt;h4 class=&quot;text-xl mb-1 mt-8 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;#### &lt;!-- --&gt;At any given point, your input to an LLM in an agent is &quot;here&#39;s what&#39;s happened so far, what&#39;s the next step&quot;&lt;/h4&gt;
&lt;/blockquote&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Everything is context engineering. &lt;a href=&quot;https://thedataexchange.media/baml-revolution-in-ai-engineering/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;LLMs are stateless functions&lt;/a&gt; that turn inputs into outputs. To get the best outputs, you need to give them the best inputs.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Creating great context means:&lt;/p&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ul class=&quot;list-disc space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;The prompt and instructions you give to the model&lt;/li&gt;
&lt;li&gt;Any documents or external data you retrieve (e.g. RAG)&lt;/li&gt;
&lt;li&gt;Any past state, tool calls, results, or other history&lt;/li&gt;
&lt;li&gt;Any past messages or events from related but separate histories/conversations (Memory)&lt;/li&gt;
&lt;li&gt;Instructions about what sorts of structured data to output&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;on context engineering&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;This guide is all about getting as much as possible out of today&#39;s models. Notably not mentioned are:&lt;/p&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ul class=&quot;list-disc space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;Changes to models parameters like temperature, top_p, frequency_penalty, presence_penalty, etc.&lt;/li&gt;
&lt;li&gt;Training your own completion or embedding models&lt;/li&gt;
&lt;li&gt;Fine-tuning existing models&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Again, I don&#39;t know what&#39;s the best way to hand context to an LLM, but I know you want the flexibility to be able to try EVERYTHING.&lt;/p&gt;
&lt;h4 class=&quot;text-xl mb-1 mt-8 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;#### &lt;!-- --&gt;Standard vs Custom Context Formats&lt;/h4&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Most LLM clients use a standard message-based format like this:&lt;/p&gt;
&lt;pre class=&quot;group&quot;&gt;&lt;pre class=&quot;prismjs rsh-code-block grid relative min-w-[250px] mb-6 bg-gray-400/5 p-4&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider border bg-transparent text-[var(--accent)] border-transparent hover:bg-[var(--accent)]/10 hover:border-[var(--accent)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-1 h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-10&quot; aria-label=&quot;Copy code&quot; title=&quot;Copy code&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-copy h-3 w-3&quot; aria-hidden=&quot;true&quot;&gt;&lt;rect width=&quot;14&quot; height=&quot;14&quot; x=&quot;8&quot; y=&quot;8&quot; rx=&quot;2&quot; ry=&quot;2&quot;&gt;&lt;/rect&gt;&lt;path d=&quot;M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;code class=&quot;overflow-x-auto&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token key atrule&quot;&gt;&#39;role&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;system&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token key atrule&quot;&gt;&#39;content&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;You are a helpful assistant...&#39;&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token key atrule&quot;&gt;&#39;role&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;user&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token key atrule&quot;&gt;&#39;content&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Can you deploy the backend?&#39;&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token key atrule&quot;&gt;&#39;role&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;assistant&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token key atrule&quot;&gt;&#39;content&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token null important&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token key atrule&quot;&gt;&#39;tool_calls&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token key atrule&quot;&gt;&#39;id&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;1&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token key atrule&quot;&gt;&#39;name&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;list_git_tags&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token key atrule&quot;&gt;&#39;arguments&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;{}&#39;&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token key atrule&quot;&gt;&#39;role&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;tool&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token key atrule&quot;&gt;&#39;name&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;list_git_tags&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token key atrule&quot;&gt;&#39;content&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;{&quot;tags&quot;: [{&quot;name&quot;: &quot;v1.2.3&quot;, &quot;commit&quot;: &quot;abc123&quot;, &quot;date&quot;: &quot;2024-03-15T10:00:00Z&quot;}, {&quot;name&quot;: &quot;v1.2.2&quot;, &quot;commit&quot;: &quot;def456&quot;, &quot;date&quot;: &quot;2024-03-14T15:30:00Z&quot;}, {&quot;name&quot;: &quot;v1.2.1&quot;, &quot;commit&quot;: &quot;abe033d&quot;, &quot;date&quot;: &quot;2024-03-13T09:15:00Z&quot;}]}&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token key atrule&quot;&gt;&#39;tool_call_id&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;1&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/pre&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;While this works great for most use cases, if you want to really get THE MOST out of today&#39;s LLMs, you need to get your context into the LLM in the most token- and attention-efficient way you can.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;As an alternative to the standard message-based format, you can build your own context format that&#39;s optimized for your use case. For example, you can use custom objects and pack/spread them into one or more user, system, assistant, or tool messages as makes sense.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Here&#39;s an example of putting the whole context window into a single user message:&lt;/p&gt;
&lt;pre class=&quot;group&quot;&gt;&lt;pre class=&quot;prismjs rsh-code-block grid relative min-w-[250px] mb-6 bg-gray-400/5 p-4&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider border bg-transparent text-[var(--accent)] border-transparent hover:bg-[var(--accent)]/10 hover:border-[var(--accent)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-1 h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-10&quot; aria-label=&quot;Copy code&quot; title=&quot;Copy code&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-copy h-3 w-3&quot; aria-hidden=&quot;true&quot;&gt;&lt;rect width=&quot;14&quot; height=&quot;14&quot; x=&quot;8&quot; y=&quot;8&quot; rx=&quot;2&quot; ry=&quot;2&quot;&gt;&lt;/rect&gt;&lt;path d=&quot;M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;code class=&quot;overflow-x-auto&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token key atrule&quot;&gt;&quot;role&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;system&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token key atrule&quot;&gt;&quot;content&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;You are a helpful assistant...&quot;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token key atrule&quot;&gt;&quot;role&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;user&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token key atrule&quot;&gt;&quot;content&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;token scalar string&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;token scalar string&quot;&gt;            Here&#39;s everything that happened so far:&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;&quot;&gt;        &amp;lt;slack_message&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;token key atrule&quot;&gt;From&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; @alex
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;token key atrule&quot;&gt;Channel&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;#deployments&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;token key atrule&quot;&gt;Text&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; Can you deploy the backend&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;        &amp;lt;/slack_message&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;&quot;&gt;        &amp;lt;list_git_tags&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;token key atrule&quot;&gt;intent&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;list_git_tags&quot;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;        &amp;lt;/list_git_tags&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;&quot;&gt;        &amp;lt;list_git_tags_result&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;token key atrule&quot;&gt;tags&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token key atrule&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;v1.2.3&quot;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;                &lt;/span&gt;&lt;span class=&quot;token key atrule&quot;&gt;commit&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;abc123&quot;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;                &lt;/span&gt;&lt;span class=&quot;token key atrule&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;2024-03-15T10:00:00Z&quot;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token key atrule&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;v1.2.2&quot;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;                &lt;/span&gt;&lt;span class=&quot;token key atrule&quot;&gt;commit&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;def456&quot;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;                &lt;/span&gt;&lt;span class=&quot;token key atrule&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;2024-03-14T15:30:00Z&quot;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token key atrule&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;v1.2.1&quot;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;                &lt;/span&gt;&lt;span class=&quot;token key atrule&quot;&gt;commit&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;ghi789&quot;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;                &lt;/span&gt;&lt;span class=&quot;token key atrule&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;2024-03-13T09:15:00Z&quot;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;        &amp;lt;/list_git_tags_result&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;&quot;&gt;        what&#39;s the next step&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/pre&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;The model may infer that you&#39;re asking it &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;what&#39;s the next step&lt;/code&gt; by the tool schemas you supply, but it never hurts to roll it into your prompt template.&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;code example&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;We can build this with something like:&lt;/p&gt;
&lt;pre class=&quot;group&quot;&gt;&lt;pre class=&quot;prismjs rsh-code-block grid relative min-w-[250px] mb-6 bg-gray-400/5 p-4&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider border bg-transparent text-[var(--accent)] border-transparent hover:bg-[var(--accent)]/10 hover:border-[var(--accent)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-1 h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-10&quot; aria-label=&quot;Copy code&quot; title=&quot;Copy code&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-copy h-3 w-3&quot; aria-hidden=&quot;true&quot;&gt;&lt;rect width=&quot;14&quot; height=&quot;14&quot; x=&quot;8&quot; y=&quot;8&quot; rx=&quot;2&quot; ry=&quot;2&quot;&gt;&lt;/rect&gt;&lt;path d=&quot;M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;code class=&quot;overflow-x-auto&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Thread&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  events&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; List&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;&quot;&gt;Event&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Event&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;# could just use string, or could be explicit - up to you&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; Literal&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;list_git_tags&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;deploy_backend&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;deploy_frontend&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;request_more_information&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;done_for_now&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;list_git_tags_result&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;deploy_backend_result&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;deploy_frontend_result&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;request_more_information_result&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;done_for_now_result&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;error&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  data&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; ListGitTags &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;&quot;&gt; DeployBackend &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;&quot;&gt; DeployFrontend &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;&quot;&gt; RequestMoreInformation &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;        ListGitTagsResult &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;&quot;&gt; DeployBackendResult &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;&quot;&gt; DeployFrontendResult &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;&quot;&gt; RequestMoreInformationResult &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;&quot;&gt; string
&lt;/span&gt;
&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;def&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;event_to_prompt&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; Event&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    data &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;&quot;&gt; event&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;data &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;isinstance&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;&quot;&gt; \
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;           &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;&quot;&gt; stringifyToYaml&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string-interpolation string&quot;&gt;f&quot;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token string-interpolation interpolation punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token string-interpolation interpolation&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;token string-interpolation interpolation punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token string-interpolation interpolation builtin&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token string-interpolation interpolation punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token string-interpolation string&quot;&gt;&amp;gt;\n&lt;/span&gt;&lt;span class=&quot;token string-interpolation interpolation punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token string-interpolation interpolation&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;token string-interpolation interpolation punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token string-interpolation string&quot;&gt;\n&amp;lt;/&lt;/span&gt;&lt;span class=&quot;token string-interpolation interpolation punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token string-interpolation interpolation&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;token string-interpolation interpolation punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token string-interpolation interpolation builtin&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token string-interpolation interpolation punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token string-interpolation string&quot;&gt;&amp;gt;&quot;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;
&lt;!-- --&gt;
&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;def&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;thread_to_prompt&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;&quot;&gt;thread&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; Thread&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;\n\n&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;&quot;&gt;event_to_prompt&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;&quot;&gt; event &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt;&lt;span class=&quot;&quot;&gt; thread&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;events&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/pre&gt;
&lt;h4 class=&quot;text-xl mb-1 mt-8 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;#### &lt;!-- --&gt;Example Context Windows&lt;/h4&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Here&#39;s how context windows might look with this approach:&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Initial Slack Request:&lt;/strong&gt;&lt;/p&gt;
&lt;pre class=&quot;group&quot;&gt;&lt;pre class=&quot;prismjs rsh-code-block grid relative min-w-[250px] mb-6 bg-gray-400/5 p-4&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider border bg-transparent text-[var(--accent)] border-transparent hover:bg-[var(--accent)]/10 hover:border-[var(--accent)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-1 h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-10&quot; aria-label=&quot;Copy code&quot; title=&quot;Copy code&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-copy h-3 w-3&quot; aria-hidden=&quot;true&quot;&gt;&lt;rect width=&quot;14&quot; height=&quot;14&quot; x=&quot;8&quot; y=&quot;8&quot; rx=&quot;2&quot; ry=&quot;2&quot;&gt;&lt;/rect&gt;&lt;path d=&quot;M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;code class=&quot;overflow-x-auto&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;slack_message&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;    From: @alex
&lt;!-- --&gt;    Channel: #deployments
&lt;!-- --&gt;    Text: Can you deploy the latest backend to production?
&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;slack_message&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/pre&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;After Listing Git Tags:&lt;/strong&gt;&lt;/p&gt;
&lt;pre class=&quot;group&quot;&gt;&lt;pre class=&quot;prismjs rsh-code-block grid relative min-w-[250px] mb-6 bg-gray-400/5 p-4&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider border bg-transparent text-[var(--accent)] border-transparent hover:bg-[var(--accent)]/10 hover:border-[var(--accent)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-1 h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-10&quot; aria-label=&quot;Copy code&quot; title=&quot;Copy code&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-copy h-3 w-3&quot; aria-hidden=&quot;true&quot;&gt;&lt;rect width=&quot;14&quot; height=&quot;14&quot; x=&quot;8&quot; y=&quot;8&quot; rx=&quot;2&quot; ry=&quot;2&quot;&gt;&lt;/rect&gt;&lt;path d=&quot;M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;code class=&quot;overflow-x-auto&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;slack_message&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;    From: @alex
&lt;!-- --&gt;    Channel: #deployments
&lt;!-- --&gt;    Text: Can you deploy the latest backend to production?
&lt;!-- --&gt;    Thread: []
&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;slack_message&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;list_git_tags&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;    intent: &quot;list_git_tags&quot;
&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;list_git_tags&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;list_git_tags_result&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;    tags:
&lt;!-- --&gt;      - name: &quot;v1.2.3&quot;
&lt;!-- --&gt;        commit: &quot;abc123&quot;
&lt;!-- --&gt;        date: &quot;2024-03-15T10:00:00Z&quot;
&lt;!-- --&gt;      - name: &quot;v1.2.2&quot;
&lt;!-- --&gt;        commit: &quot;def456&quot;
&lt;!-- --&gt;        date: &quot;2024-03-14T15:30:00Z&quot;
&lt;!-- --&gt;      - name: &quot;v1.2.1&quot;
&lt;!-- --&gt;        commit: &quot;ghi789&quot;
&lt;!-- --&gt;        date: &quot;2024-03-13T09:15:00Z&quot;
&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;list_git_tags_result&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/pre&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;After Error and Recovery:&lt;/strong&gt;&lt;/p&gt;
&lt;pre class=&quot;group&quot;&gt;&lt;pre class=&quot;prismjs rsh-code-block grid relative min-w-[250px] mb-6 bg-gray-400/5 p-4&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider border bg-transparent text-[var(--accent)] border-transparent hover:bg-[var(--accent)]/10 hover:border-[var(--accent)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-1 h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-10&quot; aria-label=&quot;Copy code&quot; title=&quot;Copy code&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-copy h-3 w-3&quot; aria-hidden=&quot;true&quot;&gt;&lt;rect width=&quot;14&quot; height=&quot;14&quot; x=&quot;8&quot; y=&quot;8&quot; rx=&quot;2&quot; ry=&quot;2&quot;&gt;&lt;/rect&gt;&lt;path d=&quot;M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;code class=&quot;overflow-x-auto&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;slack_message&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;    From: @alex
&lt;!-- --&gt;    Channel: #deployments
&lt;!-- --&gt;    Text: Can you deploy the latest backend to production?
&lt;!-- --&gt;    Thread: []
&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;slack_message&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;deploy_backend&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;    intent: &quot;deploy_backend&quot;
&lt;!-- --&gt;    tag: &quot;v1.2.3&quot;
&lt;!-- --&gt;    environment: &quot;production&quot;
&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;deploy_backend&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;    error running deploy_backend: Failed to connect to deployment service
&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;request_more_information&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;    intent: &quot;request_more_information_from_human&quot;
&lt;!-- --&gt;    question: &quot;I had trouble connecting to the deployment service, can you provide more details and/or check on the status of the service?&quot;
&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;request_more_information&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;human_response&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;    data:
&lt;!-- --&gt;      response: &quot;I&#39;m not sure what&#39;s going on, can you check on the status of the latest workflow?&quot;
&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;human_response&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/pre&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;From here your next step might be:&lt;/p&gt;
&lt;pre class=&quot;group&quot;&gt;&lt;pre class=&quot;prismjs rsh-code-block grid relative min-w-[250px] mb-6 bg-gray-400/5 p-4&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider border bg-transparent text-[var(--accent)] border-transparent hover:bg-[var(--accent)]/10 hover:border-[var(--accent)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-1 h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-10&quot; aria-label=&quot;Copy code&quot; title=&quot;Copy code&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-copy h-3 w-3&quot; aria-hidden=&quot;true&quot;&gt;&lt;rect width=&quot;14&quot; height=&quot;14&quot; x=&quot;8&quot; y=&quot;8&quot; rx=&quot;2&quot; ry=&quot;2&quot;&gt;&lt;/rect&gt;&lt;path d=&quot;M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;code class=&quot;overflow-x-auto&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;&quot;&gt;nextStep &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;&quot;&gt; determine_next_step&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;&quot;&gt;thread_to_prompt&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;&quot;&gt;thread&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/pre&gt;
&lt;pre class=&quot;group&quot;&gt;&lt;pre class=&quot;prismjs rsh-code-block grid relative min-w-[250px] mb-6 bg-gray-400/5 p-4&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider border bg-transparent text-[var(--accent)] border-transparent hover:bg-[var(--accent)]/10 hover:border-[var(--accent)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-1 h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-10&quot; aria-label=&quot;Copy code&quot; title=&quot;Copy code&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-copy h-3 w-3&quot; aria-hidden=&quot;true&quot;&gt;&lt;rect width=&quot;14&quot; height=&quot;14&quot; x=&quot;8&quot; y=&quot;8&quot; rx=&quot;2&quot; ry=&quot;2&quot;&gt;&lt;/rect&gt;&lt;path d=&quot;M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;code class=&quot;overflow-x-auto&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;intent&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;get_workflow_status&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;workflow_name&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;tag_push_prod.yaml&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/pre&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;The XML-style format is just one example - the point is you can build your own format that makes sense for your application. You&#39;ll get better quality if you have the flexibility to experiment with different context structures and what you store vs. what you pass to the LLM.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Key benefits of owning your context window:&lt;/p&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ol class=&quot;list-decimal space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Information Density&lt;/strong&gt;: Structure information in ways that maximize the LLM&#39;s understanding&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Error Handling&lt;/strong&gt;: Include error information in a format that helps the LLM recover. Consider hiding errors and failed calls from context window once they are resolved.&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Safety&lt;/strong&gt;: Control what information gets passed to the LLM, filtering out sensitive data&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Flexibility&lt;/strong&gt;: Adapt the format as you learn what works best for your use case&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Token Efficiency&lt;/strong&gt;: Optimize context format for token efficiency and LLM understanding&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Context includes: prompts, instructions, RAG documents, history, tool calls, memory&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Remember: The context window is your primary interface with the LLM. Taking control of how you structure and present information can dramatically improve your agent&#39;s performance.&lt;/p&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;Don&#39;t take it from me&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;About 2 months after 12-factor agents was published, context engineering started to become a pretty popular term.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;There&#39;s also a quite good &lt;a href=&quot;https://x.com/lenadroid/status/1943685060785524824&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;Context Engineering Cheat Sheet&lt;/a&gt; from &lt;a href=&quot;https://x.com/lenadroid&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;@lenadroid&lt;/a&gt; from July 2025.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Recurring theme here: I don&#39;t know what&#39;s the best approach, but I know you want the flexibility to be able to try EVERYTHING.&lt;/p&gt;
&lt;hr class=&quot;my-8&quot; style=&quot;border-color:var(--border-color)&quot;&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;Factor 4: Tools Are Just Structured Outputs&lt;/h2&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Tools don&#39;t need to be complex. At their core, they&#39;re just structured output from your LLM that triggers deterministic code.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/12-factor-agents/140-tools-are-just-structured-outputs.png&quot; alt=&quot;140-tools-are-just-structured-outputs&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;For example, lets say you have two tools &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;CreateIssue&lt;/code&gt; and &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;SearchIssues&lt;/code&gt;. To ask an LLM to &quot;use one of several tools&quot; is just to ask it to output JSON we can parse into an object representing those tools.&lt;/p&gt;
&lt;pre class=&quot;group&quot;&gt;&lt;pre class=&quot;prismjs rsh-code-block grid relative min-w-[250px] mb-6 bg-gray-400/5 p-4&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider border bg-transparent text-[var(--accent)] border-transparent hover:bg-[var(--accent)]/10 hover:border-[var(--accent)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-1 h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-10&quot; aria-label=&quot;Copy code&quot; title=&quot;Copy code&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-copy h-3 w-3&quot; aria-hidden=&quot;true&quot;&gt;&lt;rect width=&quot;14&quot; height=&quot;14&quot; x=&quot;8&quot; y=&quot;8&quot; rx=&quot;2&quot; ry=&quot;2&quot;&gt;&lt;/rect&gt;&lt;path d=&quot;M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;code class=&quot;overflow-x-auto&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Issue&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  title&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  description&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  team_id&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  assignee_id&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;CreateIssue&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  intent&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;create_issue&quot;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  issue&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; Issue
&lt;/span&gt;
&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;SearchIssues&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  intent&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;search_issues&quot;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  query&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  what_youre_looking_for&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;str&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/pre&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;The pattern is simple:&lt;/p&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ol class=&quot;list-decimal space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;LLM outputs structured JSON&lt;/li&gt;
&lt;li&gt;Deterministic code executes the appropriate action (like calling an external API)&lt;/li&gt;
&lt;li&gt;Results are captured and fed back into the context&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;This creates a clean separation between the LLM&#39;s decision-making and your application&#39;s actions. The LLM decides what to do, but your code controls how it&#39;s done. Just because an LLM &quot;called a tool&quot; doesn&#39;t mean you have to go execute a specific corresponding function in the same way every time.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;If you recall our switch statement from above&lt;/p&gt;
&lt;pre class=&quot;group&quot;&gt;&lt;pre class=&quot;prismjs rsh-code-block grid relative min-w-[250px] mb-6 bg-gray-400/5 p-4&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider border bg-transparent text-[var(--accent)] border-transparent hover:bg-[var(--accent)]/10 hover:border-[var(--accent)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-1 h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-10&quot; aria-label=&quot;Copy code&quot; title=&quot;Copy code&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-copy h-3 w-3&quot; aria-hidden=&quot;true&quot;&gt;&lt;rect width=&quot;14&quot; height=&quot;14&quot; x=&quot;8&quot; y=&quot;8&quot; rx=&quot;2&quot; ry=&quot;2&quot;&gt;&lt;/rect&gt;&lt;path d=&quot;M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;code class=&quot;overflow-x-auto&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;&quot;&gt; nextStep&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;intent &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;create_payment_link&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    stripe&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;paymentlinks&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;create&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;&quot;&gt;nextStep&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;parameters&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;# or whatever you want, see below&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;elif&lt;/span&gt;&lt;span class=&quot;&quot;&gt; nextStep&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;intent &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;wait_for_a_while&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;# do something monadic idk&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;#... the model didn&#39;t call a tool we know about&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;# do something else&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/pre&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Note&lt;/strong&gt;: there has been a lot said about the benefits of &quot;plain prompting&quot; vs. &quot;tool calling&quot; vs. &quot;JSON mode&quot; and the performance tradeoffs of each. We&#39;ll link some resources to that stuff soon, but not gonna get into it here. See &lt;a href=&quot;https://www.boundaryml.com/blog/schema-aligned-parsing&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;Prompting vs JSON Mode vs Function Calling vs Constrained Generation vs SAP&lt;/a&gt;, &lt;a href=&quot;https://www.vellum.ai/blog/when-should-i-use-function-calling-structured-outputs-or-json-mode#:~:text=We%20don%27t%20recommend%20using%20JSON,always%20use%20Structured%20Outputs%20instead&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;When should I use function calling, structured outputs, or JSON mode?&lt;/a&gt; and &lt;a href=&quot;https://docs.llamaindex.ai/en/stable/examples/llm/openai_json_vs_function_calling/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;OpenAI JSON vs Function Calling&lt;/a&gt;.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;The &quot;next step&quot; might not be as atomic as just &quot;run a pure function and return the result&quot;. You unlock a lot of flexibility when you think of &quot;tool calls&quot; as just a model outputting JSON describing what deterministic code should do. Put this together with &lt;a href=&quot;https://www.humanlayer.dev/blog/12-factor-agents#factor-8-own-your-control-flow&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;factor 8 own your control flow&lt;/a&gt;.&lt;/p&gt;
&lt;hr class=&quot;my-8&quot; style=&quot;border-color:var(--border-color)&quot;&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;Factor 5: Unify Execution State and Business State&lt;/h2&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Even outside the AI world, many infrastructure systems try to separate &quot;execution state&quot; from &quot;business state&quot;. For AI apps, this might involve complex abstractions to track things like current step, next step, waiting status, retry counts, etc. This separation creates complexity that may be worthwhile, but may be overkill for your use case.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;As always, it&#39;s up to you to decide what&#39;s right for your application. But don&#39;t think you &lt;em style=&quot;color:var(--text-secondary)&quot;&gt;have&lt;/em&gt; to manage them separately.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;More clearly:&lt;/p&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ul class=&quot;list-disc space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Execution state&lt;/strong&gt;: current step, next step, waiting status, retry counts, etc.&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Business state&lt;/strong&gt;: What&#39;s happened in the agent workflow so far (e.g. list of OpenAI messages, list of tool calls and results, etc.)&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;If possible, SIMPLIFY - unify these as much as possible.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/12-factor-agents/155-unify-state-animation.gif&quot; alt=&quot;155-unify-state&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;In reality, you can engineer your application so that you can infer all execution state from the context window. In many cases, execution state (current step, waiting status, etc.) is just metadata about what has happened so far.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;You may have things that can&#39;t go in the context window, like session ids, password contexts, etc, but your goal should be to minimize those things. By embracing &lt;a href=&quot;https://www.humanlayer.dev/blog/12-factor-agents#factor-3-own-your-context-window&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;factor 3&lt;/a&gt; you can control what actually goes into the LLM&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;This approach has several benefits:&lt;/p&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ol class=&quot;list-decimal space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Simplicity&lt;/strong&gt;: One source of truth for all state&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Serialization&lt;/strong&gt;: The thread is trivially serializable/deserializable&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Debugging&lt;/strong&gt;: The entire history is visible in one place&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Flexibility&lt;/strong&gt;: Easy to add new state by just adding new event types&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Recovery&lt;/strong&gt;: Can resume from any point by just loading the thread&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Forking&lt;/strong&gt;: Can fork the thread at any point by copying some subset of the thread into a new context / state ID&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Human Interfaces and Observability&lt;/strong&gt;: Trivial to convert a thread into a human-readable markdown or a rich Web app UI&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;hr class=&quot;my-8&quot; style=&quot;border-color:var(--border-color)&quot;&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;Factor 6: Launch/Pause/Resume with Simple APIs&lt;/h2&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Agents are just programs, and we have things we expect from how to launch, query, resume, and stop them.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/12-factor-agents/165-pause-resume-animation.gif&quot; alt=&quot;165-pause-resume&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;It should be easy for users, apps, pipelines, and other agents to launch an agent with a simple API.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Agents and their orchestrating deterministic code should be able to pause an agent when a long-running operation is needed.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;External triggers like webhooks should enable agents to resume from where they left off without deep integration with the agent orchestrator.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Closely related to &lt;a href=&quot;https://www.humanlayer.dev/blog/12-factor-agents#factor-5-unify-execution-state-and-business-state&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;factor 5 - unify execution state and business state&lt;/a&gt; and &lt;a href=&quot;https://www.humanlayer.dev/blog/12-factor-agents#factor-8-own-your-control-flow&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;factor 8 - own your control flow&lt;/a&gt;, but can be implemented independently.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Note&lt;/strong&gt; - often AI orchestrators will allow for pause and resume, but not between the moment of tool selection and tool execution. See also &lt;a href=&quot;https://www.humanlayer.dev/blog/12-factor-agents#factor-7-contact-humans-with-tool-calls&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;factor 7 - contact humans with tool calls&lt;/a&gt; and &lt;a href=&quot;https://www.humanlayer.dev/blog/12-factor-agents#factor-11-trigger-from-anywhere&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;factor 11 - trigger from anywhere, meet users where they are&lt;/a&gt;.&lt;/p&gt;
&lt;hr class=&quot;my-8&quot; style=&quot;border-color:var(--border-color)&quot;&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;Factor 7: Contact Humans with Tool Calls&lt;/h2&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;By default, LLM APIs rely on a fundamental HIGH-STAKES token choice: Are we returning plaintext content, or are we returning structured data?&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/12-factor-agents/170-contact-humans-with-tools.png&quot; alt=&quot;170-contact-humans-with-tools&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;You&#39;re putting a lot of weight on that choice of first token, which, in the &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;the weather in tokyo&lt;/code&gt; case, is&lt;/p&gt;
&lt;blockquote class=&quot;border-l-4 pl-4 my-4 italic&quot; style=&quot;border-color:var(--accent);color:var(--text-muted)&quot;&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&quot;the&quot;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;but in the &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;fetch_weather&lt;/code&gt; case, it&#39;s some special token to denote the start of a JSON object.&lt;/p&gt;
&lt;blockquote class=&quot;border-l-4 pl-4 my-4 italic&quot; style=&quot;border-color:var(--accent);color:var(--text-muted)&quot;&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;|JSON&amp;gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;You might get better results by having the LLM &lt;em style=&quot;color:var(--text-secondary)&quot;&gt;always&lt;/em&gt; output json, and then declare it&#39;s intent with some natural language tokens like &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;request_human_input&lt;/code&gt; or &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;done_for_now&lt;/code&gt; (as opposed to a &quot;proper&quot; tool like &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;check_weather_in_city&lt;/code&gt;).&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Again, you might not get any performance boost from this, but you should experiment, and ensure you&#39;re free to try weird stuff to get the best results.&lt;/p&gt;
&lt;pre class=&quot;group&quot;&gt;&lt;pre class=&quot;prismjs rsh-code-block grid relative min-w-[250px] mb-6 bg-gray-400/5 p-4&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider border bg-transparent text-[var(--accent)] border-transparent hover:bg-[var(--accent)]/10 hover:border-[var(--accent)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-1 h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-10&quot; aria-label=&quot;Copy code&quot; title=&quot;Copy code&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-copy h-3 w-3&quot; aria-hidden=&quot;true&quot;&gt;&lt;rect width=&quot;14&quot; height=&quot;14&quot; x=&quot;8&quot; y=&quot;8&quot; rx=&quot;2&quot; ry=&quot;2&quot;&gt;&lt;/rect&gt;&lt;path d=&quot;M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;code class=&quot;overflow-x-auto&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Options&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  urgency&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; Literal&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;low&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;medium&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;high&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; Literal&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;free_text&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;yes_no&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;multiple_choice&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  choices&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; List&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;# Tool definition for human interaction&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;RequestHumanInput&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  intent&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;request_human_input&quot;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  question&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  context&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  options&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; Options
&lt;/span&gt;
&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;# Example usage in the agent loop&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;&quot;&gt; nextStep&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;intent &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;request_human_input&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  thread&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;events&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;human_input_requested&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    data&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; nextStep
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  thread_id &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;&quot;&gt; save_state&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;&quot;&gt;thread&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;&quot;&gt; notify_human&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;&quot;&gt;nextStep&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt; thread_id&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;# Break loop and wait for response to come back with thread ID&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;# ... other cases&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/pre&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Later, you might receive a webhook from a system that handles slack, email, sms, or other events.&lt;/p&gt;
&lt;pre class=&quot;group&quot;&gt;&lt;pre class=&quot;prismjs rsh-code-block grid relative min-w-[250px] mb-6 bg-gray-400/5 p-4&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider border bg-transparent text-[var(--accent)] border-transparent hover:bg-[var(--accent)]/10 hover:border-[var(--accent)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-1 h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-10&quot; aria-label=&quot;Copy code&quot; title=&quot;Copy code&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-copy h-3 w-3&quot; aria-hidden=&quot;true&quot;&gt;&lt;rect width=&quot;14&quot; height=&quot;14&quot; x=&quot;8&quot; y=&quot;8&quot; rx=&quot;2&quot; ry=&quot;2&quot;&gt;&lt;/rect&gt;&lt;path d=&quot;M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;code class=&quot;overflow-x-auto&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token decorator annotation punctuation&quot;&gt;@app&lt;/span&gt;&lt;span class=&quot;token decorator annotation punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token decorator annotation punctuation&quot;&gt;post&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;/webhook&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;def&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;webhook&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;&quot;&gt;req&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; Request&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  thread_id &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;&quot;&gt; req&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;threadId
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  thread &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;&quot;&gt; load_state&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;&quot;&gt;thread_id&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  thread&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;events&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;response_from_human&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    data&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; req&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;body
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;# ... simplified for brevity, you likely don&#39;t want to block the web worker here&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  next_step &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;&quot;&gt; determine_next_step&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;&quot;&gt;thread_to_prompt&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;&quot;&gt;thread&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  thread&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;events&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;&quot;&gt;next_step&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  result &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;&quot;&gt; handle_next_step&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;&quot;&gt;thread&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt; next_step&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;# todo - loop or break or whatever you want&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;status&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;ok&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/pre&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;The above includes patterns from &lt;a href=&quot;https://www.humanlayer.dev/blog/12-factor-agents#factor-5-unify-execution-state-and-business-state&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;factor 5 - unify execution state and business state&lt;/a&gt;, &lt;a href=&quot;https://www.humanlayer.dev/blog/12-factor-agents#factor-8-own-your-control-flow&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;factor 8 - own your control flow&lt;/a&gt;, &lt;a href=&quot;https://www.humanlayer.dev/blog/12-factor-agents#factor-3-own-your-context-window&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;factor 3 - own your context window&lt;/a&gt;, and &lt;a href=&quot;https://www.humanlayer.dev/blog/12-factor-agents#factor-4-tools-are-just-structured-outputs&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;factor 4 - tools are just structured outputs&lt;/a&gt;, and several others.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;If we were using the XML-y formatted from &lt;a href=&quot;https://www.humanlayer.dev/blog/12-factor-agents#factor-3-own-your-context-window&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;factor 3 - own your context window&lt;/a&gt;, our context window after a few turns might look like this:&lt;/p&gt;
&lt;pre class=&quot;group&quot;&gt;&lt;pre class=&quot;prismjs rsh-code-block grid relative min-w-[250px] mb-6 bg-gray-400/5 p-4&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider border bg-transparent text-[var(--accent)] border-transparent hover:bg-[var(--accent)]/10 hover:border-[var(--accent)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-1 h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-10&quot; aria-label=&quot;Copy code&quot; title=&quot;Copy code&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-copy h-3 w-3&quot; aria-hidden=&quot;true&quot;&gt;&lt;rect width=&quot;14&quot; height=&quot;14&quot; x=&quot;8&quot; y=&quot;8&quot; rx=&quot;2&quot; ry=&quot;2&quot;&gt;&lt;/rect&gt;&lt;path d=&quot;M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;code class=&quot;overflow-x-auto&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;(snipped for brevity)
&lt;!-- --&gt;
&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;slack_message&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;    From: @alex
&lt;!-- --&gt;    Channel: #deployments
&lt;!-- --&gt;    Text: Can you deploy backend v1.2.3 to production?
&lt;!-- --&gt;    Thread: []
&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;slack_message&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;request_human_input&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;    intent: &quot;request_human_input&quot;
&lt;!-- --&gt;    question: &quot;Would you like to proceed with deploying v1.2.3 to production?&quot;
&lt;!-- --&gt;    context: &quot;This is a production deployment that will affect live users.&quot;
&lt;!-- --&gt;    options: {
&lt;!-- --&gt;        urgency: &quot;high&quot;
&lt;!-- --&gt;        format: &quot;yes_no&quot;
&lt;!-- --&gt;    }
&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;request_human_input&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;human_response&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;    response: &quot;yes please proceed&quot;
&lt;!-- --&gt;    approved: true
&lt;!-- --&gt;    timestamp: &quot;2024-03-15T10:30:00Z&quot;
&lt;!-- --&gt;    user: &quot;alex@company.com&quot;
&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;human_response&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;deploy_backend&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;    intent: &quot;deploy_backend&quot;
&lt;!-- --&gt;    tag: &quot;v1.2.3&quot;
&lt;!-- --&gt;    environment: &quot;production&quot;
&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;deploy_backend&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;deploy_backend_result&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;    status: &quot;success&quot;
&lt;!-- --&gt;    message: &quot;Deployment v1.2.3 to production completed successfully.&quot;
&lt;!-- --&gt;    timestamp: &quot;2024-03-15T10:30:00Z&quot;
&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;deploy_backend_result&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/pre&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Benefits:&lt;/p&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ol class=&quot;list-decimal space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Clear Instructions&lt;/strong&gt;: Tools for different types of human contact allow for more specificity from the LLM&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Inner vs Outer Loop&lt;/strong&gt;: Enables agents workflows &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;outside&lt;/strong&gt; of the traditional chatGPT-style interface, where the control flow and context initialization may be &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;Agent-&amp;gt;Human&lt;/code&gt; rather than &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;Human-&amp;gt;Agent&lt;/code&gt; (think, agents kicked off by a cron or an event)&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Multiple Human Access&lt;/strong&gt;: Can easily track and coordinate input from different humans through structured events&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Multi-Agent&lt;/strong&gt;: Simple abstraction can be easily extended to support &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;Agent-&amp;gt;Agent&lt;/code&gt; requests and responses&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Durable&lt;/strong&gt;: Combined with &lt;a href=&quot;https://www.humanlayer.dev/blog/12-factor-agents#factor-6-launchpauseresume-with-simple-apis&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;factor 6 - launch/pause/resume with simple APIs&lt;/a&gt;, this makes for durable, reliable, and introspectable multiplayer workflows&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;a href=&quot;https://theouterloop.substack.com/p/openais-realtime-api-is-a-step-towards&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;More on Outer Loop Agents over here&lt;/a&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/12-factor-agents/175-outer-loop-agents.png&quot; alt=&quot;175-outer-loop-agents&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Works great with &lt;a href=&quot;https://www.humanlayer.dev/blog/12-factor-agents#factor-11-trigger-from-anywhere&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;factor 11 - trigger from anywhere, meet users where they are&lt;/a&gt;&lt;/p&gt;
&lt;hr class=&quot;my-8&quot; style=&quot;border-color:var(--border-color)&quot;&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;Factor 8: Own Your Control Flow&lt;/h2&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;If you own your control flow, you can do lots of fun things.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/12-factor-agents/180-control-flow.png&quot; alt=&quot;180-control-flow&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Build your own control structures that make sense for your specific use case. Specifically, certain types of tool calls may be reason to break out of the loop and wait for a response from a human or another long-running task like a training pipeline. You may also want to incorporate custom implementation of:&lt;/p&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ul class=&quot;list-disc space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;summarization or caching of tool call results&lt;/li&gt;
&lt;li&gt;LLM-as-judge on structured output&lt;/li&gt;
&lt;li&gt;context window compaction or other &lt;a href=&quot;https://www.humanlayer.dev/blog/12-factor-agents#factor-3-own-your-context-window&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;memory management&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;logging, tracing, and metrics&lt;/li&gt;
&lt;li&gt;client-side rate limiting&lt;/li&gt;
&lt;li&gt;durable sleep / pause / &quot;wait for event&quot;&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;The below example shows three possible control flow patterns:&lt;/p&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ul class=&quot;list-disc space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;request_clarification: model asked for more info, break the loop and wait for a response from a human&lt;/li&gt;
&lt;li&gt;fetch_git_tags: model asked for a list of git tags, fetch the tags, append to context window, and pass straight back to the model&lt;/li&gt;
&lt;li&gt;deploy_backend: model asked to deploy a backend, this is a high-stakes thing, so break the loop and wait for human approval&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;
&lt;pre class=&quot;group&quot;&gt;&lt;pre class=&quot;prismjs rsh-code-block grid relative min-w-[250px] mb-6 bg-gray-400/5 p-4&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider border bg-transparent text-[var(--accent)] border-transparent hover:bg-[var(--accent)]/10 hover:border-[var(--accent)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-1 h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-10&quot; aria-label=&quot;Copy code&quot; title=&quot;Copy code&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-copy h-3 w-3&quot; aria-hidden=&quot;true&quot;&gt;&lt;rect width=&quot;14&quot; height=&quot;14&quot; x=&quot;8&quot; y=&quot;8&quot; rx=&quot;2&quot; ry=&quot;2&quot;&gt;&lt;/rect&gt;&lt;path d=&quot;M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;code class=&quot;overflow-x-auto&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;def&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;handle_next_step&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;&quot;&gt;thread&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; Thread&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;while&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token boolean&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    next_step &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;&quot;&gt; determine_next_step&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;&quot;&gt;thread_to_prompt&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;&quot;&gt;thread&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;# inlined for clarity - in reality you could put&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;# this in a method, use exceptions for control flow, or whatever you want&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;&quot;&gt; next_step&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;intent &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;request_clarification&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;      thread&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;events&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;request_clarification&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;          data&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; nextStep&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;&quot;&gt; send_message_to_human&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;&quot;&gt;next_step&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;&quot;&gt; db&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;save_thread&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;&quot;&gt;thread&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;# async step - break the loop, we&#39;ll get a webhook later&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;break&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;elif&lt;/span&gt;&lt;span class=&quot;&quot;&gt; next_step&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;intent &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;fetch_open_issues&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;      thread&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;events&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;fetch_open_issues&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;        data&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; next_step&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;&quot;&gt;      issues &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;&quot;&gt; linear_client&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;issues&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;&quot;&gt;      thread&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;events&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;fetch_open_issues_result&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;        data&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; issues&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;# sync step - pass the new context to the LLM to determine the NEXT next step&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;continue&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;elif&lt;/span&gt;&lt;span class=&quot;&quot;&gt; next_step&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;intent &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;create_issue&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;      thread&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;events&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;create_issue&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;        data&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; next_step&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;&quot;&gt; request_human_approval&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;&quot;&gt;next_step&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;&quot;&gt; db&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;save_thread&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;&quot;&gt;thread&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;# async step - break the loop, we&#39;ll get a webhook later&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;break&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/pre&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;This pattern allows you to interrupt and resume your agent&#39;s flow as needed, creating more natural conversations and workflows.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Example&lt;/strong&gt; - the number one feature request I have for every AI framework out there is we need to be able to interrupt
a working agent and resume later, ESPECIALLY between the moment of tool &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;selection&lt;/strong&gt; and the moment of tool &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;invocation&lt;/strong&gt;.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Without this level of resumability/granularity, there&#39;s no way to review/approve the tool call before it runs, which means
you&#39;re forced to either:&lt;/p&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ol class=&quot;list-decimal space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;Pause the task in memory while waiting for the long-running thing to complete (think &lt;code class=&quot;px-2 py-0.5 rounded font-mono bg-[var(--code-bg)] text-[var(--accent)] border border-[var(--code-border)] tracking-tight shadow-sm mr-1 align-middle wrap-anywhere box-decoration-clone&quot;&gt;while...sleep&lt;/code&gt;) and restart it from the beginning if the process is interrupted&lt;/li&gt;
&lt;li&gt;Restrict the agent to only low-stakes, low-risk calls like research and summarization&lt;/li&gt;
&lt;li&gt;Give the agent access to do bigger, more useful things, and just yolo hope it doesn&#39;t screw up&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;You may notice this is closely related to &lt;a href=&quot;https://www.humanlayer.dev/blog/12-factor-agents#factor-5-unify-execution-state-and-business-state&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;factor 5 - unify execution state and business state&lt;/a&gt; and &lt;a href=&quot;https://www.humanlayer.dev/blog/12-factor-agents#factor-6-launchpauseresume-with-simple-apis&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;factor 6 - launch/pause/resume with simple APIs&lt;/a&gt;, but can be implemented independently.&lt;/p&gt;
&lt;hr class=&quot;my-8&quot; style=&quot;border-color:var(--border-color)&quot;&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;Factor 9: Compact Errors into Context Window&lt;/h2&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;This one is a little short but is worth mentioning. One of these benefits of agents is &quot;self-healing&quot; - for short tasks, an LLM might call a tool that fails. Good LLMs have a fairly good chance of reading an error message or stack trace and figuring out what to change in a subsequent tool call.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Most frameworks implement this, but you can do JUST THIS without doing any of the other 11 factors. Here&#39;s an example:&lt;/p&gt;
&lt;pre class=&quot;group&quot;&gt;&lt;pre class=&quot;prismjs rsh-code-block grid relative min-w-[250px] mb-6 bg-gray-400/5 p-4&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider border bg-transparent text-[var(--accent)] border-transparent hover:bg-[var(--accent)]/10 hover:border-[var(--accent)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-1 h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-10&quot; aria-label=&quot;Copy code&quot; title=&quot;Copy code&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-copy h-3 w-3&quot; aria-hidden=&quot;true&quot;&gt;&lt;rect width=&quot;14&quot; height=&quot;14&quot; x=&quot;8&quot; y=&quot;8&quot; rx=&quot;2&quot; ry=&quot;2&quot;&gt;&lt;/rect&gt;&lt;path d=&quot;M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;code class=&quot;overflow-x-auto&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;&quot;&gt;thread &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;events&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;&quot;&gt;initial_message&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;while&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token boolean&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  next_step &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;&quot;&gt; determine_next_step&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;&quot;&gt;thread_to_prompt&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;&quot;&gt;thread&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  thread&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;events&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; next_step&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;intent&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;data&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; next_step&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;try&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    result &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;&quot;&gt; handle_next_step&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;&quot;&gt;thread&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt; next_step&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;# our switch statement&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;except&lt;/span&gt;&lt;span class=&quot;&quot;&gt; Exception &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;as&lt;/span&gt;&lt;span class=&quot;&quot;&gt; e&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;# if we get an error, we can add it to the context window and try again&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    thread&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;events&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;error&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;data&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; format_error&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;# loop, or do whatever else here to try to recover&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/pre&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;You may want to implement an errorCounter for a specific tool call, to limit to ~3 attempts of a single tool, or whatever other logic makes sense for your use case.&lt;/p&gt;
&lt;pre class=&quot;group&quot;&gt;&lt;pre class=&quot;prismjs rsh-code-block grid relative min-w-[250px] mb-6 bg-gray-400/5 p-4&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider border bg-transparent text-[var(--accent)] border-transparent hover:bg-[var(--accent)]/10 hover:border-[var(--accent)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-1 h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-10&quot; aria-label=&quot;Copy code&quot; title=&quot;Copy code&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-copy h-3 w-3&quot; aria-hidden=&quot;true&quot;&gt;&lt;rect width=&quot;14&quot; height=&quot;14&quot; x=&quot;8&quot; y=&quot;8&quot; rx=&quot;2&quot; ry=&quot;2&quot;&gt;&lt;/rect&gt;&lt;path d=&quot;M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;code class=&quot;overflow-x-auto&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;&quot;&gt;consecutive_errors &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;while&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token boolean&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;# ... existing code ...&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;try&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    result &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;&quot;&gt; handle_next_step&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;&quot;&gt;thread&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt; next_step&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    thread&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;events&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; next_step&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;intent &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;_result&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;      data&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; result&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;# success! reset the error counter&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    consecutive_errors &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;except&lt;/span&gt;&lt;span class=&quot;&quot;&gt; Exception &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;as&lt;/span&gt;&lt;span class=&quot;&quot;&gt; e&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    consecutive_errors &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;+=&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;&quot;&gt; consecutive_errors &lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;# do the loop and try again&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;      thread&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;events&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;error&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;data&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt; format_error&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;# break the loop, reset parts of the context window, escalate to a human, or whatever else you want to do&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;break&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/pre&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Hitting some consecutive-error-threshold might be a great place to &lt;a href=&quot;https://www.humanlayer.dev/blog/12-factor-agents#factor-7-contact-humans-with-tool-calls&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;escalate to a human&lt;/a&gt;, whether by model decision or via deterministic takeover of the control flow.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/12-factor-agents/195-factor-09-errors.gif&quot; alt=&quot;195-factor-09-errors&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Benefits:&lt;/p&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ol class=&quot;list-decimal space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Self-Healing&lt;/strong&gt;: The LLM can read the error message and figure out what to change in a subsequent tool call&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Durable&lt;/strong&gt;: The agent can continue to run even if one tool call fails&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;I&#39;m sure you will find that if you do this TOO much, your agent will start to spin out and might repeat the same error over and over again.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;That&#39;s where &lt;a href=&quot;https://www.humanlayer.dev/blog/12-factor-agents#factor-8-own-your-control-flow&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;factor 8 - own your control flow&lt;/a&gt; and &lt;a href=&quot;https://www.humanlayer.dev/blog/12-factor-agents#factor-3-own-your-context-window&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;factor 3 - own your context building&lt;/a&gt; come in - you don&#39;t need to just put the raw error back on, you can completely restructure how it&#39;s represented, remove previous events from the context window, or whatever deterministic thing you find works to get an agent back on track.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;But the number one way to prevent error spin-outs is to embrace &lt;a href=&quot;https://www.humanlayer.dev/blog/12-factor-agents#factor-10-small-focused-agents&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;factor 10 - small, focused agents&lt;/a&gt;.&lt;/p&gt;
&lt;hr class=&quot;my-8&quot; style=&quot;border-color:var(--border-color)&quot;&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;Factor 10: Small, Focused Agents&lt;/h2&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Rather than building monolithic agents that try to do everything, build small, focused agents that do one thing well. Agents are just one building block in a larger, mostly deterministic system.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/12-factor-agents/1a0-small-focused-agents.png&quot; alt=&quot;1a0-small-focused-agents&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;The key insight here is about LLM limitations: the bigger and more complex a task is, the more steps it will take, which means a longer context window. As context grows, LLMs are more likely to get lost or lose focus. By keeping agents focused on specific domains with 3-10, maybe 20 steps max, we keep context windows manageable and LLM performance high.&lt;/p&gt;
&lt;blockquote class=&quot;border-l-4 pl-4 my-4 italic&quot; style=&quot;border-color:var(--accent);color:var(--text-muted)&quot;&gt;
&lt;h4 class=&quot;text-xl mb-1 mt-8 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;#### &lt;!-- --&gt;As context grows, LLMs are more likely to get lost or lose focus&lt;/h4&gt;
&lt;/blockquote&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Benefits of small, focused agents:&lt;/p&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ol class=&quot;list-decimal space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Manageable Context&lt;/strong&gt;: Smaller context windows mean better LLM performance&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Clear Responsibilities&lt;/strong&gt;: Each agent has a well-defined scope and purpose&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Better Reliability&lt;/strong&gt;: Less chance of getting lost in complex workflows&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Easier Testing&lt;/strong&gt;: Simpler to test and validate specific functionality&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Improved Debugging&lt;/strong&gt;: Easier to identify and fix issues when they occur&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;h3 class=&quot;text-2xl mb-2 mt-16 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;### &lt;!-- --&gt;What if LLMs get smarter?&lt;/h3&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Do we still need this if LLMs get smart enough to handle 100-step+ workflows?&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;tl;dr yes. As agents and LLMs improve, they &lt;strong style=&quot;color:var(--text-primary)&quot;&gt;might&lt;/strong&gt; naturally expand to be able to handle longer context windows. This means handling MORE of a larger DAG. This small, focused approach ensures you can get results TODAY, while preparing you to slowly expand agent scope as LLM context windows become more reliable. (If you&#39;ve refactored large deterministic code bases before, you may be nodding your head right now).&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/12-factor-agents/1a5-agent-scope-grow.gif&quot; alt=&quot;1a5-agent-scope-grow&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Being intentional about size/scope of agents, and only growing in ways that allow you to maintain quality, is key here. As the &lt;a href=&quot;https://open.substack.com/pub/swyx/p/notebooklm?selection=08e1187c-cfee-4c63-93c9-71216640a5f8&amp;amp;utm_campaign=post-share-selection&amp;amp;utm_medium=web&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;team that built NotebookLM put it&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote class=&quot;border-l-4 pl-4 my-4 italic&quot; style=&quot;border-color:var(--accent);color:var(--text-muted)&quot;&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;I feel like consistently, the most magical moments out of AI building come about for me when I&#39;m really, really, really just close to the edge of the model capability&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Regardless of where that boundary is, if you can find that boundary and get it right consistently, you&#39;ll be building magical experiences. There are many moats to be built here, but as usual, they take some engineering rigor.&lt;/p&gt;
&lt;hr class=&quot;my-8&quot; style=&quot;border-color:var(--border-color)&quot;&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;Factor 11: Trigger from Anywhere&lt;/h2&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;If you&#39;re waiting for the &lt;a href=&quot;https://humanlayer.dev/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;humanlayer&lt;/a&gt; pitch, you made it. If you&#39;re doing &lt;a href=&quot;https://www.humanlayer.dev/blog/12-factor-agents#factor-6-launchpauseresume-with-simple-apis&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;factor 6 - launch/pause/resume with simple APIs&lt;/a&gt; and &lt;a href=&quot;https://www.humanlayer.dev/blog/12-factor-agents#factor-7-contact-humans-with-tool-calls&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;factor 7 - contact humans with tool calls&lt;/a&gt;, you&#39;re ready to incorporate this factor.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/12-factor-agents/1b0-trigger-from-anywhere.png&quot; alt=&quot;1b0-trigger-from-anywhere&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Enable users to trigger agents from slack, email, sms, or whatever other channel they want. Enable agents to respond via the same channels.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Benefits:&lt;/p&gt;
&lt;div class=&quot;pl-8 mb-6&quot;&gt;&lt;ul class=&quot;list-disc space-y-4&quot; style=&quot;color:var(--text-secondary)&quot;&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Meet users where they are&lt;/strong&gt;: This helps you build AI applications that feel like real humans, or at the very least, digital coworkers&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;Outer Loop Agents&lt;/strong&gt;: Enable agents to be triggered by non-humans, e.g. events, crons, outages, whatever else. They may work for 5, 20, 90 minutes, but when they get to a critical point, they can contact a human for help, feedback, or approval&lt;/li&gt;
&lt;li&gt;&lt;strong style=&quot;color:var(--text-primary)&quot;&gt;High Stakes Tools&lt;/strong&gt;: If you&#39;re able to quickly loop in a variety of humans, you can give agents access to higher stakes operations like sending external emails, updating production data and more. Maintaining clear standards gets you auditability and confidence in agents that &lt;a href=&quot;https://www.humanlayer.dev/blog/12-factor-agents#what-if-llms-get-smarter&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; class=&quot;underline hover:opacity-80 transition-opacity&quot; style=&quot;color:var(--accent)&quot;&gt;perform bigger better things&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;
&lt;hr class=&quot;my-8&quot; style=&quot;border-color:var(--border-color)&quot;&gt;
&lt;h2 class=&quot;text-3xl mb-3 mt-20 font-bold&quot; style=&quot;color:var(--text-primary)&quot;&gt;## &lt;!-- --&gt;Factor 12: Make Your Agent a Stateless Reducer&lt;/h2&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;Okay so we&#39;re over 1000 lines of markdown at this point. This one is mostly just for fun.&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/12-factor-agents/1c0-stateless-reducer.png&quot; alt=&quot;1c0-stateless-reducer&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p style=&quot;display:block;color:var(--text-secondary)&quot; class=&quot;mb-4&quot;&gt;&lt;/p&gt;&lt;div class=&quot;relative group my-4 inline-block&quot;&gt;&lt;img src=&quot;https://www.humanlayer.dev/blog/12-factor-agents/1c5-agent-foldl.png&quot; alt=&quot;1c5-agent-foldl&quot; class=&quot;max-w-full h-auto rounded-none&quot; style=&quot;border:1px solid var(--border-color)&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;button data-slot=&quot;button&quot; class=&quot;inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-mono font-medium cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 [&amp;amp;_svg]:pointer-events-none [&amp;amp;_svg:not([class*=&#39;size-&#39;])]:size-4 shrink-0 [&amp;amp;_svg]:shrink-0 outline-none focus-visible:ring-[3px] uppercase tracking-wider bg-transparent text-[var(--accent)] border-[var(--accent)] hover:bg-[var(--accent)] hover:text-[var(--bg-primary)] focus-visible:border-[var(--accent)] focus-visible:ring-[var(--accent)]/50 size-9 absolute top-2 right-2 h-8 w-8 border-2 transition-colors&quot; style=&quot;background-color:var(--code-bg);border-color:var(--border-color)&quot; aria-label=&quot;View full size&quot; title=&quot;View full size&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;lucide lucide-expand h-4 w-4&quot; aria-hidden=&quot;true&quot; style=&quot;color:var(--text-primary)&quot;&gt;&lt;path d=&quot;m15 15 6 6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m15 9 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 16v5h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M21 8V3h-5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 16v5h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;m3 21 6-6&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M3 8V3h5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9 9 3 3&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;</description><link>https://www.humanlayer.dev/blog/12-factor-agents</link><guid isPermaLink="false">https://www.humanlayer.dev/blog/12-factor-agents</guid><pubDate>Wed, 02 Apr 2025 16:00:00 GMT</pubDate><author>Dex</author><category>agents</category><category>llm</category><category>ai</category><category>best-practices</category><category>architecture</category></item></channel></rss>