Self-Compact Pi Agent: ZERO HYPE Agentic Coding Devlog — Transcript
Full transcript
- 0:00What's up engineers? Andy Dev Dan here.
- 0:02Welcome to an agentic coding dev log
- 0:04where we're going to solve a classic
- 0:06agent problem. This is a stubbornly
- 0:08persistent problem with agents that
- 0:10isn't going away no matter how great
- 0:12your agentic engineering ability
- 0:14becomes. Every agent has it, no agent
- 0:16can escape it, and every engineer must
- 0:19understand it. It's of course the
- 0:21context window. The context window is
- 0:23the precious resource for accomplishing
- 0:26work with your agents. It's been with us
- 0:28since the beginning and yet knowing how
- 0:30to control and manage your context
- 0:32window is a massively untapped
- 0:34opportunity for engineers. But if you're
- 0:37really going to put the agentic in
- 0:39engineer, we need to up level this
- 0:41thinking. Your agents are now
- 0:43intelligent enough to be self-aware of
- 0:45their own context windows. So what if we
- 0:48let our agents decide when it's time to
- 0:51compact? Most agentic coding tools like
- 0:54Cloud Code and Code X let you set the
- 0:56context level the auto compaction
- 0:58occurs. With Harness Engineering and the
- 1:00Pi Coding Agent, we can do much better.
- 1:03If you're building with agents every
- 1:05single day and you're firing off longer
- 1:07and longer running agents, managing your
- 1:10context window properly will literally
- 1:12pay you with each compaction that runs.
- 1:15This is a problem I need to solve for my
- 1:17longer and longer running OutLoop
- 1:19agents. For example, my simple swarm
- 1:22system where I kick off 10 to hundreds
- 1:24of agents that run for hours
- 1:26coordinating [music] on a common goal
- 1:28requires self-compaction, requires an
- 1:30awareness so that the agents can [music]
- 1:32keep churning. You can imagine this gets
- 1:34expensive especially if we're running a
- 1:37Fable swarm or an Astor swarm. Today
- 1:39we're going to build a self-compacting
- 1:42Pi [music] agent that's context aware
- 1:44and has its own dedicated tool to decide
- 1:46when to compact. If you want to improve
- 1:49your harness and prompt engineering
- 1:50[music] and you want to understand how
- 1:52much you can really manage your context
- 1:54window, stick around and let's build a
- 1:57self-compacting agent [music] harness.
- 2:04So, automatic compaction already exists,
- 2:06but you and I can do much better by
- 2:07questioning the defaults. The big
- 2:09question is, can your agent choose a
- 2:12better moment to compact? When I sit
- 2:14down to build, it all starts with a
- 2:16draft plan. No software factories, no
- 2:19agents, no whisper flow, just me, my
- 2:21thoughts, and the keyboard. Sometimes
- 2:23I'll go for a notebook here, which I
- 2:25know is probably crazy to some engineers
- 2:27listening trying to always move at the
- 2:28agentic speed, but being able to
- 2:30crystallize your thoughts into useful
- 2:31information and then translate it and
- 2:33hand it to your agents is the name of
- 2:35the game now. That is the edge every
- 2:37agentic engineer has. It's your
- 2:39expertise and your ability to translate
- 2:41that into something your agents can use.
- 2:43Inside of VS Code here, I've got a few
- 2:45pieces set up for the self-compaction
- 2:47agent that we're going to work through
- 2:48here together. Empty specs directory,
- 2:50empty prompts. We have all the PyCoding
- 2:52Agent docs here, and we have a simple
- 2:54plan F3 skill for all missile's class
- 2:57models. We're going to be using that
- 2:58today. All great work starts with great
- 3:00writing. So, here we're going to fire up
- 3:02a new prompt. We'll call this end draft
- 3:04plan. md, and I'll use my code snippet
- 3:07here, draft. So, draft is what I use to
- 3:09kick off my personal writing. Again, not
- 3:12my agents, you know, not my swarms. This
- 3:14is just me concretely thinking through
- 3:16what I'm looking for. These models can
- 3:18do incredible things, and the level of
- 3:20detail you can encode into your prompts
- 3:22is the level of detail you'll be able to
- 3:24get out of your agents, right? That is
- 3:26the edge now. Anyone can write code,
- 3:28anyone can build software, but it's what
- 3:30you're building. It's the detail you
- 3:32understand intimately that no one else
- 3:34does that matters. So, we're going to
- 3:36dive into the right level of detail to
- 3:38help our agent understand what we're
- 3:39looking for. And I think we'll do
- 3:40something fun here. Once we write this
- 3:42plan, what I'll do is I'll hand it off
- 3:44to three different agent harnesses
- 3:46running three different models, and
- 3:47we'll see what results we can get out of
- 3:49the system. Title, self-compaction.
- 3:51Problem,
- 3:55Long-running autonomous agents run out
- 3:57of context.
- 4:01Long-running context will say reduces
- 4:04performance via context rot and burns
- 4:06cash. So, what's the solution here? We
- 4:08understand the problem. The solution is
- 4:12We're going to build a standalone PyCode
- 4:14agent with a few key features. The first
- 4:16innovation here we're going to have is
- 4:18we're going to give our agent their own
- 4:20tool to do this work. Okay, so that's
- 4:21going to look like this.
- 4:23I've been thinking about this problem
- 4:25for a while. We're just going to kind of
- 4:26flow through this. I might skip ahead in
- 4:28some points you don't have to sit.
- 4:29Self-compact, allow the agent to compact
- 4:32itself. And again, this is something you
- 4:33cannot do in other agentic coding tools
- 4:36and we're going to expand on that in a
- 4:37moment here.
- 4:41We'll have three unique threshold
- 4:42levels, a notice level, a warning level,
- 4:45and a force compaction level.
- 4:50A UI to match the three compaction
- 4:52levels.
- 5:00We're going to have compaction prompts
- 5:02for each interaction with our agent. So,
- 5:04we want to write these all out. Most
- 5:05engineers don't know you can take full
- 5:07control of this. You do not need to use
- 5:08the baked in compaction prompt that
- 5:10Codex gives you or that the PyCode agent
- 5:13gives you or whatever your tool is,
- 5:14right? They all have it. You can control
- 5:16it when you can control your agent
- 5:18harness. We're going to have our soft
- 5:19notice user prompt and our warning user
- 5:21prompt.
- 5:25Okay, I still want a nice fallback, so
- 5:27human-in-the-loop commands. I want to be
- 5:29able to see our threshold limits. I
- 5:30don't want to be able to force
- 5:31compaction by hand. This is more so for
- 5:34testing, but again, the big idea we're
- 5:35looking for here is long-running
- 5:37autonomous agents that operate out the
- 5:39loop. Okay, definitely something we want
- 5:41to be clear about. These agents built
- 5:44for long-running autonomous, no
- 5:46human-in-the-loop, out loop, agentic.
- 5:49Really state the problem and communicate
- 5:51to my agent that's going to be building
- 5:52this stuff out what we're really trying
- 5:54to solve, okay? So, that's the key five
- 5:57big ideas here that we're going to work
- 5:58through. And to be clear here, you know,
- 6:00this is self-compaction, this is prompt
- 6:02engineering, right? We're taking control
- 6:04of all the prompts here. This is context
- 6:07control. And then we have Pi UI, and
- 6:10then we have human in the loop commands.
- 6:12This is kind of the key value that we're
- 6:15wanting to get out of the system. I'm
- 6:16going to skip ahead a little bit here so
- 6:17you don't have to wait through all this.
- 6:19So, variables we're going to be using
- 6:20throughout the rest of our plan here.
- 6:22I'm going to go ahead and get rid of
- 6:23implementation notes. We might need to
- 6:24bring this back, not sure. Let's go
- 6:26ahead and work through the workflow. So,
- 6:27a couple of things to note here, right?
- 6:29Project root. I want to be able to run
- 6:31multiple agents against this. So, in
- 6:33order to enable that, we're going to use
- 6:34some variables here that we're going to
- 6:36swap out when we kick off our plan here
- 6:38against our agentic coding tool of
- 6:40choice. And then we have our workflow.
- 6:42So, how does the agent actually do this
- 6:43work? I'm going to use these simple
- 6:45three steps, and this is going to be
- 6:46standard for most engineers. We'll do a
- 6:49plan step,
- 6:50build,
- 6:53verify.
- 6:55Okay? And I'll fill in some extra
- 6:56details here. Basically, I want my agent
- 6:58to use the plan F3 skill here. And you
- 7:01can see here it has a couple workflows
- 7:02built into it. You can see kind of all
- 7:04the details here at a high level. We
- 7:06don't need to go deeper in our agentic
- 7:07operating level than understanding what
- 7:09our files names are here. From here,
- 7:11I'll flash through this for you. So, we
- 7:12have plan, build, verify. Couple new
- 7:15items here. The really important section
- 7:18that I use in all my prompts now is
- 7:20twofold. It's definition of done and how
- 7:23you're graded. How you're graded comes
- 7:25from this insane hack in understanding
- 7:28that when these models are being trained
- 7:30inside the big AI labs, they're always
- 7:32being graded. And so, if you give your
- 7:35agents a rubric for how they're graded,
- 7:37they'll be able to adhere to it. So,
- 7:38this is a really powerful section.
- 7:39Definitely play with this in your prompt
- 7:41engineering. So, definition of done is
- 7:42clear, right? I use this in every single
- 7:45prompt draft that I write now.
- 7:47Definition of done is how your agent
- 7:49knows when to stop. And as we covered in
- 7:51our after swarms video, where we built
- 7:53our own agent swarm, and we noted on the
- 7:56failure of OpenAI to create a done tool
- 7:59or to create some way for their agents
- 8:01to stop, this is going to be more and
- 8:02more important. This is what it looks
- 8:04like to like prompt engineer alignment.
- 8:06Sometimes I just drop deliverables cuz
- 8:07definition of done can contain them. So,
- 8:09I'm going to go ahead and do that. Let's
- 8:11get rid of this section, and let's write
- 8:12out the definition of done. So, what do
- 8:14we want to make sure is complete here?
- 8:16We have the work endure, we have the
- 8:18workflow we want our agents to work
- 8:20through, the high-level problem and
- 8:21solution. What does done look like?
- 8:23Let's go ahead and walk through this.
- 8:24You plan the work, have the harness at
- 8:26the right location, workflow complete.
- 8:29That's really what this section is,
- 8:30right? So, this is when the workflow's
- 8:31complete. Hand-off tool. This is the
- 8:33self-compact tool. The central piece of
- 8:36this tool is the self-compact tool. This
- 8:38lets your agent do two things:
- 8:40autonomously compact their own context,
- 8:43and it also allows them to leave a note
- 8:45to themselves. So, this is a nice tweak
- 8:47that I want to add to my compaction.
- 8:49Compaction is a user prompt that fires
- 8:51underneath the hood at a certain time
- 8:53when the context is super full or when
- 8:55you trigger it yourself. And so, that
- 8:56runs a user prompt. The note to self is
- 8:58an additional thing on top of that,
- 9:00where your agents can write to
- 9:01themselves, and that will be added as an
- 9:03additional user prompt during the
- 9:04summarization. So, self-compact is here.
- 9:07We have expected, and then we have a
- 9:08couple additional notes here about the
- 9:10actual implementation. So, a next key
- 9:12piece here is the user interface. What
- 9:15does this actually look like inside the
- 9:17PyCoding agent? Let me type this up.
- 9:18Context bar shows usage and thresholds.
- 9:22In the UI, we want something that looks
- 9:24like this. Now, it looks kind of weird,
- 9:25looks kind of confusing, but it's
- 9:26actually really simple. We have cached
- 9:28tokens, uncached tokens, we have free
- 9:30context, and then we have these three
- 9:32markers. These represent our notice, it
- 9:35represents our warning, and our hard
- 9:37cutoff. So, that's the user interface,
- 9:38nice and simple, and it's in the
- 9:40definition of done. We need to have this
- 9:42inside the PyCoding Agent in the UI for
- 9:44this to be marked as completed prompt
- 9:46engineering. These are the actual user
- 9:48prompts that run during compaction. It's
- 9:50our soft self-compact note. It's all
- 9:52these additional details here. Files are
- 9:54in specific places or correct places.
- 9:58And this is going to be your working
- 10:00runs from compact soft at. So, this is
- 10:04going to be the CLI flag that sets the
- 10:06context amount in thousands or
- 10:09percentages. Actually, we'll keep that
- 10:11in the next section, right? So, I'll
- 10:12detail that in compact thresholds. We'll
- 10:15go and fill that in in a moment here,
- 10:16but right, warning self-compact supplies
- 10:18a more stern time to compact soon hard
- 10:21cutoff at {dot} {dot} {dot} message from
- 10:25compact at, right? And then we have one
- 10:27more. This is our user prompt override
- 10:30of the actual compaction message. Okay,
- 10:31so, the user prompt compaction message
- 10:35replaces PyCoding Agent default
- 10:37compaction prompt. That's our prompt
- 10:39engineering, right? So, we have a
- 10:40concrete section where we have all these
- 10:42detailed prompts that we can modify or
- 10:44we can override. Now, we're just walking
- 10:46through the flags. I'll blink through
- 10:47this cuz this is going to be very
- 10:48similar here to this, but basically we
- 10:50have all four flags work. Okay? So, we
- 10:52have compact at percentage soft. We have
- 10:55compact at 50%, 10%, and uh yeah, one
- 10:59important note here is that I want these
- 11:01to be able to accept thousands or
- 11:03millions suffixes. Cap at 90%. That's
- 11:06fine. And um let's go ahead and do some
- 11:09defaults here. Defaults. Let's go ahead
- 11:11and set this up like we're going to be
- 11:12running in Astra Swarm, right? GPT-6
- 11:15Astra Swarm. So, a lot of engineers
- 11:16don't know, but like um the GPT models
- 11:19price basically doubles when you hit the
- 11:21270K
- 11:23mark, right? So, we can do a soft
- 11:25warning here at uh let's do it like at
- 11:28225. Let's do a uh hard warning here at
- 11:31250, and then we'll force at that 270
- 11:34mark. So, this gives the agent a little
- 11:35bit of room to finish some work, to wrap
- 11:38up what it's doing, and then hard
- 11:40compact force before the cost start
- 11:43doubling commands. And so, this is going
- 11:45to help with verification and
- 11:46validation. So, launch variants and
- 11:50we'll go ahead and do this in a little
- 11:51bit more detailed syntax. Your working
- 11:53dir, right?
- 11:56Yep.
- 11:58This is going to launch with, as you can
- 12:00imagine, the defaults. State that,
- 12:02right? Yeah, or percentages. Let me just
- 12:03make that super clear. This is
- 12:04redundant. Like, I am going into a
- 12:06little bit too much detail here, but I'd
- 12:07rather be clear than be confusing. And
- 12:09then we'll go ahead and run through a
- 12:10couple additional commands here with
- 12:12more variables filled in. There we go,
- 12:13compact at, compact buffer, and this all
- 12:16looks good. And then, yeah, so we have
- 12:17the compact prompt as well. Do not
- 12:20reinvent work. Yep, that's good. So,
- 12:21this is going to be overriding the
- 12:23compact prompt. We have human in the
- 12:25loop commands. This is less interesting
- 12:26to me and probably to you, too. So,
- 12:28commands are available. We have
- 12:30self-compact info, self-compact now, and
- 12:32then the usual {slash} compact. So, we
- 12:34don't want to touch this, right? So,
- 12:35this is the core definition of done. I'm
- 12:37using this a lot more to just say
- 12:39everything I want completed and write it
- 12:40clearly there, right? Focus on the end
- 12:43state, less on how you get there. Our
- 12:45agents are becoming better and better at
- 12:46that. So, we have that. We have the
- 12:48workflow, which is a high-level rubric
- 12:50of how to accomplish the work. Dedicated
- 12:51skill here, the plan of three, that
- 12:53really generates some outsize returns.
- 12:55So, I do want it to be consistent
- 12:56against this. And then we have our
- 12:58dedicated variables. We use the route.
- 13:00So, I want to be able to swap in and out
- 13:01variables. We'll set up a just file to
- 13:03do that work for us. And then we have
- 13:05our solution at the high level, making
- 13:07it kind of clear what we're looking for
- 13:08and the problem. But, the how you're
- 13:09graded is really, really interesting
- 13:11because it taps into how these models
- 13:13are trained. These are just bullet
- 13:15points. They're really simple and
- 13:16they're things like this. You'll be
- 13:18graded on a continuous based on every
- 13:21completed bullet in the definition of
- 13:23done. Every step of workflow. Instant
- 13:26failure if you write project
- 13:28deliverables outside your working dir.
- 13:31With the exception of plan dir, right?
- 13:34Because we want our agents to write a
- 13:35plan first, then execute it. Instant
- 13:37failure if you read any part of any file
- 13:40inside of spec star that isn't your own
- 13:44plan, okay? And I'm going to repeat this
- 13:46for So, instant failure if you read of
- 13:48any file inside of the apps. I'm going
- 13:50to run multiple coding agents here in
- 13:52apps and I want them each to run in
- 13:53their own sub application inside of
- 13:56this, right? Inside of like a an an app
- 13:58star here, okay? If an agent touches one
- 14:00of the others, it's an instant fail,
- 14:02okay? And so, this is a little bit of
- 14:03extra work that I like to do to compare
- 14:06models and compare agent to coding
- 14:07tools. This is purely optional for you.
- 14:09And I'll go ahead and add a couple
- 14:10additional how you're graded points here
- 14:12as well. Running tools outside these
- 14:13directories is allowed. Temp files are
- 14:15fine. Can use normal locations. That's
- 14:17not a grading failure, but we also want
- 14:19to say if you mistakenly cause a
- 14:20failure, stop immediately and report
- 14:22your failure. And so, I'm not just
- 14:23testing, you know, as I'm like
- 14:25transitioning from in-loop agent to
- 14:27coding to out-loop agent to coding as
- 14:28I'm scaling up my agents through longer
- 14:30and longer horizon work, I want to know
- 14:31while I'm in the loop what agents I can
- 14:33really trust over longer and longer
- 14:36durations. Now, last week we covered my
- 14:38top five benchmarks for agent to
- 14:40engineering. All those ideas centered
- 14:42around one concept, which is long
- 14:44horizon work where you and I are not
- 14:46present. And so, when you are present,
- 14:48it's important to get more signal from
- 14:50your agent to coding tools, from your
- 14:52models so that you know which models you
- 14:53can trust outside the loop when you're
- 14:55gone, right? So, I like to kind of mix
- 14:58that into my work now as I'm in-loop
- 15:00agent to coding and out-loop agent to
- 15:02coding more and more, okay? I think we
- 15:04have a solid piece of work here. And now
- 15:06I'm going to create a just file here
- 15:08that we can use to kick off Codex, kick
- 15:11off Cloud Code, and kick off a pie
- 15:12coding agent with a variety of fantastic
- 15:14models. So, I'll go ahead and do that
- 15:16now and this is where I I stop typing by
- 15:18hand, just to be super clear, right? The
- 15:20prompt is written, my ideas are encoded
- 15:23into this markdown file. The level of
- 15:24detail I want is now here. Now it's time
- 15:27to move at the speed of agents, right?
- 15:30We want to slow down when the time is
- 15:31right and speed up pretty much every
- 15:33other time. Okay, so um I'll flash
- 15:36through some of this. This isn't the
- 15:37core value prop I want to show you. I'll
- 15:38summarize afterward. So here's what the
- 15:40just file looks like, self-compact cloud
- 15:42code, passing in some variables, GPT-6
- 15:44Astra, and then we have a PyCoding agent
- 15:46we also want to compare the results
- 15:47against. We're going to check out the
- 15:49JLM 5.2 model. Okay, so we're going to
- 15:51kick these all up. I am constantly
- 15:53testing using different agentic coding
- 15:55tools. If you think you have the winning
- 15:56formula, I can guarantee you you don't.
- 15:58I don't. There are no winning tools
- 16:00right now except for maybe the PyCoding
- 16:03agent because it's customizable,
- 16:04extensible, and you own it. This is open
- 16:06source. The whole agentic coding
- 16:08landscape is constantly transforming. I
- 16:09don't pick winners, I pick uh multiple
- 16:11tools. I think in ands not ors. I
- 16:13recommend you do the same. But here's
- 16:14our just file, CLDYO and CDX. These are
- 16:17my aliases. And actually I want this to
- 16:19be CLDYF. That's going to be my fable
- 16:21model. We're going to kick these off.
- 16:22Let's go ahead and fire up a nice Herder
- 16:25terminal. Let's go uh three windows
- 16:27here, equalize, and then we'll kick
- 16:29these off side by side and see what the
- 16:31results are, right? They should each get
- 16:33us a working version of our self-compact
- 16:36PyCoding agent. And then we'll look at
- 16:37the results afterward and see which
- 16:39model performed the best. All right,
- 16:40cloud code, codex, Py. So our agents
- 16:43will get to work. You can see the models
- 16:44there, JLM 5.2, Astra, and Fable 5.1.
- 16:47Let's see how these individual agentic
- 16:49coding tools and models compare side by
- 16:50side. We're having agents build agents,
- 16:52and they're each going to work through
- 16:54their dedicated workflow, plan, build,
- 16:57verify. Let's see how they perform. I'm
- 16:59going to let these agents cook. This
- 17:00might take some time. This is not a
- 17:02trivial task, and then we'll come back
- 17:04to this. I'm expecting 20 minutes to an
- 17:06hour for all of these models to complete
- 17:08together. So we'll blink through this,
- 17:10and I'll see you on the other end.
- 17:12All right, so let's check in our
- 17:14results. I've been away, and I'm coming
- 17:15back now to understand what these agents
- 17:17have done. Uh it looks like speaking of
- 17:19context GLM 5.2 has a context explosion.
- 17:23It's 98% context. It cannot do this job
- 17:26and we looked at this last week, right?
- 17:28I know before even running something
- 17:30like this, this model thinks a lot as
- 17:32you can see here. If we scroll up
- 17:33through the response, a lot of what it's
- 17:36doing is just thinking, right? Some of
- 17:38these powerful workhorse models, these
- 17:40open weights models, they're great
- 17:42models, but there's limits to them.
- 17:44Right? And we can clearly see that here.
- 17:46On the other hand, we have uh some
- 17:48really interesting results here that we
- 17:49emphasized last week. You can see here
- 17:51in an actual example, right? Fable 5.1
- 17:55using 50 minutes. Okay, so you can see
- 17:58when it completed here. On the other
- 17:59side, Codex running GPT-6 Astra took 21
- 18:02minutes, half the time. If you use half
- 18:04the time, you can bet as a fact it used
- 18:07a fraction of the tokens. Okay, so we
- 18:09have two completed results here. You can
- 18:11see GLM just ran out of context. A great
- 18:15you know, call to why the solution is so
- 18:17important, right? If this agent had uh
- 18:19the self-compaction, it would have
- 18:20gotten the job done. But you can see
- 18:21here, you know, uh our Fable agent 50%
- 18:24context. Okay, so this is non-trivial
- 18:26work. And if we check our uh Astra agent
- 18:29and we do a What do we need here?
- 18:30Status. Uh 136K.
- 18:33And so you can see here um Codex was a
- 18:35lot more efficient. Fable is running at
- 18:38the 1 million token context and it used
- 18:40500K tokens. If these agents bombed uh
- 18:43and didn't give us the result, it
- 18:45doesn't matter, Brent. None of this
- 18:46stuff actually matters. So we need to
- 18:47make sure they got the result we're
- 18:48looking for. I'm going to write one note
- 18:50here to both these agents and I'll copy
- 18:51this and I'll do the exact same thing
- 18:54and paste it here. They're going to come
- 18:56in here and update this just file. Okay,
- 18:58so we can just watch this. It's always
- 19:00fun to be in the loop and watch what
- 19:02your agents are doing at light speed.
- 19:04There's the run CC command.
- 19:06And there is our run CDX. Fantastic. All
- 19:09right, so they're both pointing to their
- 19:10new respective version. You can see here
- 19:12in the specs directory, we have exactly
- 19:14what we asked for, the specs for all
- 19:16three agents. First, they planned, then
- 19:18they built, then they verify, and then
- 19:19we have the apps, right? So, Fable 5,
- 19:21Astra, and GLM 5.2. Write one for GLM,
- 19:26assume file name based on LS. And you
- 19:28can see here, I have this EFF pattern,
- 19:31EFF in all their agents. This is the
- 19:34system prompt I'm running on all of my
- 19:35agents now. It doesn't matter the agent
- 19:37harness you're using, you know, I'm I'm
- 19:39constantly controlling the core four
- 19:41throughout my agent coding experience.
- 19:43Although, you know, you can only control
- 19:44so much in the closed source ones,
- 19:46right? So, okay, so that's great. Astra
- 19:48just did that work for us. We have all
- 19:49three commands. Let's start with our
- 19:51GLM. How far did GLM get? Did we get any
- 19:53concrete result? We're in Herder, so
- 19:55I'll boot up a new workspace. I can type
- 19:57J, I can see the new command. Let's see
- 19:58how far our GLM 5.2 agent got. We'll do
- 20:01J run. Looks like it's starting out with
- 20:04nothing here, so I'll just say ping. We
- 20:06should already see a context bar, right?
- 20:07This is already wrong. I'm just going to
- 20:09back out of this version, I think. J
- 20:11run. We'll do cloud code next. Let's see
- 20:14what we have here. Okay, check this out.
- 20:15Nice, nice, nice. So, okay, so I can't
- 20:17run any models here because I haven't
- 20:19configured my environment variables. Let
- 20:21me just do that quick. I'll do a quick
- 20:23export. There we go. Okay, now we're
- 20:24running Gemini 3.5 flash, and you can
- 20:26see my points here. We have the
- 20:28exclamation here, and it looks like the
- 20:30squiggly is rolled into this. So,
- 20:33what I'll do is I'll have it spread out
- 20:36our context positions just for testing,
- 20:38okay? Spread out context positions, soft
- 20:4210%, warning 20, hard 30. Okay, and I'll
- 20:45do the same thing here. The agents
- 20:48already have all the context in their
- 20:49context window. They're just going to
- 20:50quickly come in here, create a concise
- 20:52update for the context thresholds.
- 20:54Remember, we have the soft point, we
- 20:55have the compact at, and then we have
- 20:56the forced compact buffer, compact at
- 20:59plus compact buffer, right? So, 30%. And
- 21:01let me just go and reset this, run CC.
- 21:04And now we have these clear points. So,
- 21:05check this out. Here's our context bar,
- 21:07That's squiggly at 10% warning with the
- 21:09exclamation, then we have the hard cut
- 21:10off at this bar. Okay, so we are
- 21:12actively limiting our context window and
- 21:14we're letting our agent compact when it
- 21:15needs to. Let's go ahead and prove this
- 21:17out, okay? So, here's the fable 5.1
- 21:18version. We'll do model. Let's go ahead
- 21:20and run uh let's do a deep seek uh V4
- 21:22flash. We can go ahead and use open
- 21:24router here. Let's use that new flash
- 21:254.1, right? Blazing fast, find the
- 21:27largest file all. It's going to find the
- 21:30file size and it's going to start
- 21:33chewing up context, okay? So, you can
- 21:35see here there's our percentage. We're
- 21:36at 1%. And what we're going to see here
- 21:37is uh the agent is going to get notices
- 21:40on self-compaction. Okay, so it found
- 21:42that Astra plan. Looks like this is the
- 21:44largest one. So, let's go ahead and see
- 21:45how it reads each one of these in
- 21:48individual chunks. So, that's what it's
- 21:50doing. Okay, so it's chunking the file
- 21:51and now it's going to start reading
- 21:52largest files here, split it 40 KB,
- 21:55reading it anyway. Okay, looks good.
- 21:58Here you can see we're at 6%. This is
- 21:59what really matters here, right? It's
- 22:00the self-compaction. Okay, so thinking
- 22:02tokens, reading tokens. There we go. So,
- 22:04there's the notice, right? Context use,
- 22:06soft threshold. Okay, it's good. 1
- 22:08million. I have plenty of room. Okay, so
- 22:10it's it took in the warning and now it's
- 22:13continuing, but now it has the warning.
- 22:14Self-compact warning, threshold passed,
- 22:17right? I need to compact now. So, it
- 22:18decided to compact now. It's writing a
- 22:20note to itself. Okay, so we are uh you
- 22:23know, expanding our agent engineering
- 22:24capability. It wrote a note and now it's
- 22:26being forced to compact. So, there's
- 22:29that self-compact note and now it's
- 22:31compacting itself. Okay, so it looks
- 22:33like these previous reads got to pushed
- 22:35over the line and now we have
- 22:37compaction, right? There we go and
- 22:39there's the compaction line here. This
- 22:41is a note to itself. So, it gave it a
- 22:43goal, determination, done, so on and so
- 22:46forth. Next action and it also has that
- 22:49compaction message that our agent should
- 22:51have a specific prompt for, okay? And
- 22:54so, it's going to continue. It looks
- 22:55like it read the rest of the file. We
- 22:57wanted to prove that this worked, okay?
- 22:58So, we can see that that looks great. Um
- 23:00let's go ahead and see what the Codex
- 23:01version looks like. J run CDX and let's
- 23:04see what the Codex version looks like.
- 23:05Okay, so it shows a widget on top and
- 23:07let's go ahead and activate my
- 23:08environment variables there. It has the
- 23:10exact points. So, I notice at 100 the
- 23:13warning message at 200k and then the
- 23:15force compact at 300k. And let's see
- 23:17what GLM 5.2 flash or 5.3 flash. Okay.
- 23:21So, again, just a simple test here to uh
- 23:23trigger the self-compaction, right? We
- 23:25want our agent to compact on its own and
- 23:27really to really push these capabilities
- 23:29what we really want is a large
- 23:31self-compact window. We want a big gap
- 23:33between that and the warning and then a
- 23:36shorter gap between the warning and the
- 23:38force compaction, right? where our
- 23:39harness won't let our agent call any
- 23:41other tool. Because that's where a lot
- 23:42of the value comes from. Let the agent
- 23:44decide what it wants to compact and then
- 23:46it'll force a compaction. For most
- 23:48engineers, this is not new, but what is
- 23:50relatively new here is you can control
- 23:52your agent harness to get these
- 23:53incredible results in your agent and you
- 23:55can do it however you want, right?
- 23:57Enhance the experience, right? So much
- 24:00of what everyone's doing in Cloud Code
- 24:02and Codex is just the very beginning.
- 24:04There's our user input prompt, optional
- 24:06context notice. There's a compaction
- 24:08message, what to do. You may continue to
- 24:11use all tools. If a natural stopping
- 24:13point exists, consider self-compact.
- 24:16Okay, so very very good. The agent is
- 24:18continuing and it's just putting
- 24:20together the results. Very very nice.
- 24:22Love to see that. We have user prompts
- 24:24for the agent, right? Specifically, the
- 24:26most important one here is we are
- 24:27overriding the default user compact
- 24:30message. Every single agent according
- 24:32tool has some type of compact message
- 24:34and here we're overriding the default.
- 24:36We're overriding Pi's. I think you can
- 24:37override Codex's. You cannot override
- 24:40Cloud Code's. Okay, so again, just
- 24:42another hat tip to harness engineering
- 24:44your own agent according tool, right?
- 24:46Here is the uh soft compact notice for
- 24:49the Fable 5 version of this, Fable 5.1.
- 24:52And then here's the warning prompt. So,
- 24:54uh let's see if anything's been
- 24:56triggered here yet. Nope, 12%. Let's go
- 24:58ahead and just force blow this up. Kick
- 25:00off a self-compact, remove handoff, and
- 25:03use that as note to self. So, we just
- 25:05want to know that this works, right?
- 25:07It's the individual tool call our agent
- 25:09can make at any point in time to compact
- 25:11its own memory. That's the key idea
- 25:14here. As you can see, there's that note
- 25:15to self getting passed in. Context is
- 25:17being compacted. Codex version is
- 25:19running this. GPT-6 Astra, Pi, we have
- 25:22all of our prompts. So, there's the
- 25:24compaction message from Astra. You know,
- 25:26not as good as this one from Fable.
- 25:29We'll call that out. And then we have
- 25:30the soft compact. Fable definitely
- 25:33giving some better results when it comes
- 25:34to actually prompt engineering other
- 25:36agents. There's the soft self-compact
- 25:39message. And then we have the warning
- 25:40message. It does look like Fable is a
- 25:43better prompt engineer than Astra. So,
- 25:46interesting just to see that in the
- 25:47results. Let's see how our agent is
- 25:49compacting all this. There we go. Um
- 25:51let's take a look at this. So, very
- 25:53nice. Yep. So, there's the self-compact
- 25:55message. So, that's a prompt we pass
- 25:58into it. There's the actual compaction.
- 26:01And then here's the self-handoff, right?
- 26:02So, the agent is handing itself a
- 26:04message in addition to the summary that
- 26:07the normal compaction makes, right?
- 26:09Already deleted. Okay. That looks good.
- 26:10Okay. So, great. So, we got the context
- 26:12down. That's awesome. And the agent is
- 26:15ready to go. You can see cycle one
- 26:16there. So, if we needed to, we could
- 26:18record how many compressions occurred.
- 26:20You know, what are we doing here, right?
- 26:21We are teaching our agents to manage
- 26:23their own context window. We're teaching
- 26:25them when to compact, uh what to
- 26:27preserve, and how to continue. We're
- 26:29doing that by harness engineering and
- 26:31specifically prompt engineering our own
- 26:34prompts to control the process that our
- 26:36agents go through end-to-end. I don't
- 26:38know if this is clear to you, but let me
- 26:39just like make it dead clear. Uh
- 26:42if you master the core four context
- 26:43model prompt tool, you master the agent.
- 26:46If you master the agent, you will master
- 26:48knowledge work, right? That and some
- 26:50domain expertise, and you have it all,
- 26:53right? The agent is everything. Knowing
- 26:55how to control it, manage it, build on
- 26:57it, scale it, and do it cost-effectively
- 26:59with techniques like this and and other
- 27:01techniques is just so important now,
- 27:03right? You have to like think bigger
- 27:05than just you sitting in the terminal
- 27:07prompting back and forth, right? The
- 27:09name of the game is moving from in loop
- 27:11to out loop. There's always going to be
- 27:12in loop agentic coding work as you can
- 27:14see here, right? What really matters is
- 27:16your ability to scale out the loop, is
- 27:18to move toward these more autonomous
- 27:20systems. And this is one way we can do
- 27:22this, right? Self-compaction is really
- 27:24important for these long-running jobs,
- 27:27right? This enables for agents to decide
- 27:30when to compact themselves, right? I'll
- 27:31space out the soft warning and the
- 27:34harder warning, right? So the agent can
- 27:36really determine when it's time. You can
- 27:38add multiple warnings if you want,
- 27:40right? Multiple threshold points. This
- 27:41is really up to you, right? But the
- 27:42whole idea here is you want to manage
- 27:44your context window better so you don't
- 27:45blow up costs and so you don't context
- 27:48rot. I will go ahead and and package up
- 27:51the self-compacting agent. Feel free to
- 27:52take a look at this. All the specs are
- 27:54here and from the plan they went ahead
- 27:55and built the entire application. So a
- 27:57classic developer workflow, plan, build,
- 28:00verify. Our agents are doing it with
- 28:02this single skill. I want to always
- 28:03communicate here when we sit down and
- 28:05and kind of do things by hand, quote
- 28:06unquote, where we're actually typing,
- 28:08we're actually thinking. The level of
- 28:10detail you add to your work is what
- 28:13differentiates you now, right? Anyone
- 28:15can write code, anyone can build
- 28:16software, but your ability to ask for
- 28:19exactly what you want is a unique
- 28:21advantage now because guess what? Your
- 28:23agents can do it, powerful agent swarms
- 28:25can do it for you, and then you can
- 28:27build this into your own software
- 28:29factory and create a powerful system
- 28:31that consistently produces the results
- 28:32you're looking for. But it all starts by
- 28:35knowing what you want. We're going to be
- 28:37continuing to scale up our compute to
- 28:39scale up our impact on this channel week
- 28:41after week, idea after idea. Uh so don't
- 28:43miss out because the next leap is
- 28:45available. Phase three is coming and
- 28:48it's going to be hard to follow without
- 28:49the right information. You know, that's
- 28:51always our bread and butter here. It's
- 28:53what can you do? How much value can you
- 28:54create? What can you build and what
- 28:57limitations
- 28:58are you arbitrarily placing on yourself?
- 29:00The tools you use directly limit what
- 29:02you believe is possible. And so, you can
- 29:05see here, I'm not thinking about any
- 29:07specific tool anymore. I'm using the
- 29:09right tools that allow me to build the
- 29:11right feature I need to expand what I
- 29:13can do with agents, right? The PyCoding
- 29:16Agent is a fantastic tool because with
- 29:18it I see no limits and with it you can
- 29:21see no limits, too. It's all about
- 29:23having customizable controllable
- 29:25software that you can make yours, that
- 29:27you can customize, that you can control
- 29:29to the [music] very bone, all right? And
- 29:31you'll notice, you know, Cloud Code
- 29:32copying this type of feature set, uh
- 29:35they're coming out with their own plugin
- 29:36system for customizing Cloud Code. Where
- 29:39do you think that came from? It came
- 29:40from tools like this, the PyCoding
- 29:42Agent, right? All the best ideas are out
- 29:43there. The best ideas haven't even
- 29:45happened yet, right? They're sitting in
- 29:47your mind, they're sitting in other
- 29:48engineers' minds, and it's all about
- 29:50building it into the tool to [music]
- 29:52accomplish the work. Again, links in the
- 29:53description for you. You know where to
- 29:55find me every single Monday. Stay
- 29:57focused and keep building.
About this transcript
This page contains the full transcript of Self-Compact Pi Agent: ZERO HYPE Agentic Coding Devlog by IndyDevDan, generated from the public captions YouTube serves with the video. The transcript has 6,143 words across 886 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.
What you can do with it
Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to choose a caption track available on the video.
Free YouTube transcript tool
YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, caption language selection, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.