YouTube2Text

Self-Compact Pi Agent: ZERO HYPE Agentic Coding Devlog — Transcript

by IndyDevDan · 6,143 words · 886 segments · language en · Watch on YouTube

Full transcript

  1. 0:00What's up engineers? Andy Dev Dan here.
  2. 0:02Welcome to an agentic coding dev log
  3. 0:04where we're going to solve a classic
  4. 0:06agent problem. This is a stubbornly
  5. 0:08persistent problem with agents that
  6. 0:10isn't going away no matter how great
  7. 0:12your agentic engineering ability
  8. 0:14becomes. Every agent has it, no agent
  9. 0:16can escape it, and every engineer must
  10. 0:19understand it. It's of course the
  11. 0:21context window. The context window is
  12. 0:23the precious resource for accomplishing
  13. 0:26work with your agents. It's been with us
  14. 0:28since the beginning and yet knowing how
  15. 0:30to control and manage your context
  16. 0:32window is a massively untapped
  17. 0:34opportunity for engineers. But if you're
  18. 0:37really going to put the agentic in
  19. 0:39engineer, we need to up level this
  20. 0:41thinking. Your agents are now
  21. 0:43intelligent enough to be self-aware of
  22. 0:45their own context windows. So what if we
  23. 0:48let our agents decide when it's time to
  24. 0:51compact? Most agentic coding tools like
  25. 0:54Cloud Code and Code X let you set the
  26. 0:56context level the auto compaction
  27. 0:58occurs. With Harness Engineering and the
  28. 1:00Pi Coding Agent, we can do much better.
  29. 1:03If you're building with agents every
  30. 1:05single day and you're firing off longer
  31. 1:07and longer running agents, managing your
  32. 1:10context window properly will literally
  33. 1:12pay you with each compaction that runs.
  34. 1:15This is a problem I need to solve for my
  35. 1:17longer and longer running OutLoop
  36. 1:19agents. For example, my simple swarm
  37. 1:22system where I kick off 10 to hundreds
  38. 1:24of agents that run for hours
  39. 1:26coordinating [music] on a common goal
  40. 1:28requires self-compaction, requires an
  41. 1:30awareness so that the agents can [music]
  42. 1:32keep churning. You can imagine this gets
  43. 1:34expensive especially if we're running a
  44. 1:37Fable swarm or an Astor swarm. Today
  45. 1:39we're going to build a self-compacting
  46. 1:42Pi [music] agent that's context aware
  47. 1:44and has its own dedicated tool to decide
  48. 1:46when to compact. If you want to improve
  49. 1:49your harness and prompt engineering
  50. 1:50[music] and you want to understand how
  51. 1:52much you can really manage your context
  52. 1:54window, stick around and let's build a
  53. 1:57self-compacting agent [music] harness.
  54. 2:04So, automatic compaction already exists,
  55. 2:06but you and I can do much better by
  56. 2:07questioning the defaults. The big
  57. 2:09question is, can your agent choose a
  58. 2:12better moment to compact? When I sit
  59. 2:14down to build, it all starts with a
  60. 2:16draft plan. No software factories, no
  61. 2:19agents, no whisper flow, just me, my
  62. 2:21thoughts, and the keyboard. Sometimes
  63. 2:23I'll go for a notebook here, which I
  64. 2:25know is probably crazy to some engineers
  65. 2:27listening trying to always move at the
  66. 2:28agentic speed, but being able to
  67. 2:30crystallize your thoughts into useful
  68. 2:31information and then translate it and
  69. 2:33hand it to your agents is the name of
  70. 2:35the game now. That is the edge every
  71. 2:37agentic engineer has. It's your
  72. 2:39expertise and your ability to translate
  73. 2:41that into something your agents can use.
  74. 2:43Inside of VS Code here, I've got a few
  75. 2:45pieces set up for the self-compaction
  76. 2:47agent that we're going to work through
  77. 2:48here together. Empty specs directory,
  78. 2:50empty prompts. We have all the PyCoding
  79. 2:52Agent docs here, and we have a simple
  80. 2:54plan F3 skill for all missile's class
  81. 2:57models. We're going to be using that
  82. 2:58today. All great work starts with great
  83. 3:00writing. So, here we're going to fire up
  84. 3:02a new prompt. We'll call this end draft
  85. 3:04plan. md, and I'll use my code snippet
  86. 3:07here, draft. So, draft is what I use to
  87. 3:09kick off my personal writing. Again, not
  88. 3:12my agents, you know, not my swarms. This
  89. 3:14is just me concretely thinking through
  90. 3:16what I'm looking for. These models can
  91. 3:18do incredible things, and the level of
  92. 3:20detail you can encode into your prompts
  93. 3:22is the level of detail you'll be able to
  94. 3:24get out of your agents, right? That is
  95. 3:26the edge now. Anyone can write code,
  96. 3:28anyone can build software, but it's what
  97. 3:30you're building. It's the detail you
  98. 3:32understand intimately that no one else
  99. 3:34does that matters. So, we're going to
  100. 3:36dive into the right level of detail to
  101. 3:38help our agent understand what we're
  102. 3:39looking for. And I think we'll do
  103. 3:40something fun here. Once we write this
  104. 3:42plan, what I'll do is I'll hand it off
  105. 3:44to three different agent harnesses
  106. 3:46running three different models, and
  107. 3:47we'll see what results we can get out of
  108. 3:49the system. Title, self-compaction.
  109. 3:51Problem,
  110. 3:55Long-running autonomous agents run out
  111. 3:57of context.
  112. 4:01Long-running context will say reduces
  113. 4:04performance via context rot and burns
  114. 4:06cash. So, what's the solution here? We
  115. 4:08understand the problem. The solution is
  116. 4:12We're going to build a standalone PyCode
  117. 4:14agent with a few key features. The first
  118. 4:16innovation here we're going to have is
  119. 4:18we're going to give our agent their own
  120. 4:20tool to do this work. Okay, so that's
  121. 4:21going to look like this.
  122. 4:23I've been thinking about this problem
  123. 4:25for a while. We're just going to kind of
  124. 4:26flow through this. I might skip ahead in
  125. 4:28some points you don't have to sit.
  126. 4:29Self-compact, allow the agent to compact
  127. 4:32itself. And again, this is something you
  128. 4:33cannot do in other agentic coding tools
  129. 4:36and we're going to expand on that in a
  130. 4:37moment here.
  131. 4:41We'll have three unique threshold
  132. 4:42levels, a notice level, a warning level,
  133. 4:45and a force compaction level.
  134. 4:50A UI to match the three compaction
  135. 4:52levels.
  136. 5:00We're going to have compaction prompts
  137. 5:02for each interaction with our agent. So,
  138. 5:04we want to write these all out. Most
  139. 5:05engineers don't know you can take full
  140. 5:07control of this. You do not need to use
  141. 5:08the baked in compaction prompt that
  142. 5:10Codex gives you or that the PyCode agent
  143. 5:13gives you or whatever your tool is,
  144. 5:14right? They all have it. You can control
  145. 5:16it when you can control your agent
  146. 5:18harness. We're going to have our soft
  147. 5:19notice user prompt and our warning user
  148. 5:21prompt.
  149. 5:25Okay, I still want a nice fallback, so
  150. 5:27human-in-the-loop commands. I want to be
  151. 5:29able to see our threshold limits. I
  152. 5:30don't want to be able to force
  153. 5:31compaction by hand. This is more so for
  154. 5:34testing, but again, the big idea we're
  155. 5:35looking for here is long-running
  156. 5:37autonomous agents that operate out the
  157. 5:39loop. Okay, definitely something we want
  158. 5:41to be clear about. These agents built
  159. 5:44for long-running autonomous, no
  160. 5:46human-in-the-loop, out loop, agentic.
  161. 5:49Really state the problem and communicate
  162. 5:51to my agent that's going to be building
  163. 5:52this stuff out what we're really trying
  164. 5:54to solve, okay? So, that's the key five
  165. 5:57big ideas here that we're going to work
  166. 5:58through. And to be clear here, you know,
  167. 6:00this is self-compaction, this is prompt
  168. 6:02engineering, right? We're taking control
  169. 6:04of all the prompts here. This is context
  170. 6:07control. And then we have Pi UI, and
  171. 6:10then we have human in the loop commands.
  172. 6:12This is kind of the key value that we're
  173. 6:15wanting to get out of the system. I'm
  174. 6:16going to skip ahead a little bit here so
  175. 6:17you don't have to wait through all this.
  176. 6:19So, variables we're going to be using
  177. 6:20throughout the rest of our plan here.
  178. 6:22I'm going to go ahead and get rid of
  179. 6:23implementation notes. We might need to
  180. 6:24bring this back, not sure. Let's go
  181. 6:26ahead and work through the workflow. So,
  182. 6:27a couple of things to note here, right?
  183. 6:29Project root. I want to be able to run
  184. 6:31multiple agents against this. So, in
  185. 6:33order to enable that, we're going to use
  186. 6:34some variables here that we're going to
  187. 6:36swap out when we kick off our plan here
  188. 6:38against our agentic coding tool of
  189. 6:40choice. And then we have our workflow.
  190. 6:42So, how does the agent actually do this
  191. 6:43work? I'm going to use these simple
  192. 6:45three steps, and this is going to be
  193. 6:46standard for most engineers. We'll do a
  194. 6:49plan step,
  195. 6:50build,
  196. 6:53verify.
  197. 6:55Okay? And I'll fill in some extra
  198. 6:56details here. Basically, I want my agent
  199. 6:58to use the plan F3 skill here. And you
  200. 7:01can see here it has a couple workflows
  201. 7:02built into it. You can see kind of all
  202. 7:04the details here at a high level. We
  203. 7:06don't need to go deeper in our agentic
  204. 7:07operating level than understanding what
  205. 7:09our files names are here. From here,
  206. 7:11I'll flash through this for you. So, we
  207. 7:12have plan, build, verify. Couple new
  208. 7:15items here. The really important section
  209. 7:18that I use in all my prompts now is
  210. 7:20twofold. It's definition of done and how
  211. 7:23you're graded. How you're graded comes
  212. 7:25from this insane hack in understanding
  213. 7:28that when these models are being trained
  214. 7:30inside the big AI labs, they're always
  215. 7:32being graded. And so, if you give your
  216. 7:35agents a rubric for how they're graded,
  217. 7:37they'll be able to adhere to it. So,
  218. 7:38this is a really powerful section.
  219. 7:39Definitely play with this in your prompt
  220. 7:41engineering. So, definition of done is
  221. 7:42clear, right? I use this in every single
  222. 7:45prompt draft that I write now.
  223. 7:47Definition of done is how your agent
  224. 7:49knows when to stop. And as we covered in
  225. 7:51our after swarms video, where we built
  226. 7:53our own agent swarm, and we noted on the
  227. 7:56failure of OpenAI to create a done tool
  228. 7:59or to create some way for their agents
  229. 8:01to stop, this is going to be more and
  230. 8:02more important. This is what it looks
  231. 8:04like to like prompt engineer alignment.
  232. 8:06Sometimes I just drop deliverables cuz
  233. 8:07definition of done can contain them. So,
  234. 8:09I'm going to go ahead and do that. Let's
  235. 8:11get rid of this section, and let's write
  236. 8:12out the definition of done. So, what do
  237. 8:14we want to make sure is complete here?
  238. 8:16We have the work endure, we have the
  239. 8:18workflow we want our agents to work
  240. 8:20through, the high-level problem and
  241. 8:21solution. What does done look like?
  242. 8:23Let's go ahead and walk through this.
  243. 8:24You plan the work, have the harness at
  244. 8:26the right location, workflow complete.
  245. 8:29That's really what this section is,
  246. 8:30right? So, this is when the workflow's
  247. 8:31complete. Hand-off tool. This is the
  248. 8:33self-compact tool. The central piece of
  249. 8:36this tool is the self-compact tool. This
  250. 8:38lets your agent do two things:
  251. 8:40autonomously compact their own context,
  252. 8:43and it also allows them to leave a note
  253. 8:45to themselves. So, this is a nice tweak
  254. 8:47that I want to add to my compaction.
  255. 8:49Compaction is a user prompt that fires
  256. 8:51underneath the hood at a certain time
  257. 8:53when the context is super full or when
  258. 8:55you trigger it yourself. And so, that
  259. 8:56runs a user prompt. The note to self is
  260. 8:58an additional thing on top of that,
  261. 9:00where your agents can write to
  262. 9:01themselves, and that will be added as an
  263. 9:03additional user prompt during the
  264. 9:04summarization. So, self-compact is here.
  265. 9:07We have expected, and then we have a
  266. 9:08couple additional notes here about the
  267. 9:10actual implementation. So, a next key
  268. 9:12piece here is the user interface. What
  269. 9:15does this actually look like inside the
  270. 9:17PyCoding agent? Let me type this up.
  271. 9:18Context bar shows usage and thresholds.
  272. 9:22In the UI, we want something that looks
  273. 9:24like this. Now, it looks kind of weird,
  274. 9:25looks kind of confusing, but it's
  275. 9:26actually really simple. We have cached
  276. 9:28tokens, uncached tokens, we have free
  277. 9:30context, and then we have these three
  278. 9:32markers. These represent our notice, it
  279. 9:35represents our warning, and our hard
  280. 9:37cutoff. So, that's the user interface,
  281. 9:38nice and simple, and it's in the
  282. 9:40definition of done. We need to have this
  283. 9:42inside the PyCoding Agent in the UI for
  284. 9:44this to be marked as completed prompt
  285. 9:46engineering. These are the actual user
  286. 9:48prompts that run during compaction. It's
  287. 9:50our soft self-compact note. It's all
  288. 9:52these additional details here. Files are
  289. 9:54in specific places or correct places.
  290. 9:58And this is going to be your working
  291. 10:00runs from compact soft at. So, this is
  292. 10:04going to be the CLI flag that sets the
  293. 10:06context amount in thousands or
  294. 10:09percentages. Actually, we'll keep that
  295. 10:11in the next section, right? So, I'll
  296. 10:12detail that in compact thresholds. We'll
  297. 10:15go and fill that in in a moment here,
  298. 10:16but right, warning self-compact supplies
  299. 10:18a more stern time to compact soon hard
  300. 10:21cutoff at {dot} {dot} {dot} message from
  301. 10:25compact at, right? And then we have one
  302. 10:27more. This is our user prompt override
  303. 10:30of the actual compaction message. Okay,
  304. 10:31so, the user prompt compaction message
  305. 10:35replaces PyCoding Agent default
  306. 10:37compaction prompt. That's our prompt
  307. 10:39engineering, right? So, we have a
  308. 10:40concrete section where we have all these
  309. 10:42detailed prompts that we can modify or
  310. 10:44we can override. Now, we're just walking
  311. 10:46through the flags. I'll blink through
  312. 10:47this cuz this is going to be very
  313. 10:48similar here to this, but basically we
  314. 10:50have all four flags work. Okay? So, we
  315. 10:52have compact at percentage soft. We have
  316. 10:55compact at 50%, 10%, and uh yeah, one
  317. 10:59important note here is that I want these
  318. 11:01to be able to accept thousands or
  319. 11:03millions suffixes. Cap at 90%. That's
  320. 11:06fine. And um let's go ahead and do some
  321. 11:09defaults here. Defaults. Let's go ahead
  322. 11:11and set this up like we're going to be
  323. 11:12running in Astra Swarm, right? GPT-6
  324. 11:15Astra Swarm. So, a lot of engineers
  325. 11:16don't know, but like um the GPT models
  326. 11:19price basically doubles when you hit the
  327. 11:21270K
  328. 11:23mark, right? So, we can do a soft
  329. 11:25warning here at uh let's do it like at
  330. 11:28225. Let's do a uh hard warning here at
  331. 11:31250, and then we'll force at that 270
  332. 11:34mark. So, this gives the agent a little
  333. 11:35bit of room to finish some work, to wrap
  334. 11:38up what it's doing, and then hard
  335. 11:40compact force before the cost start
  336. 11:43doubling commands. And so, this is going
  337. 11:45to help with verification and
  338. 11:46validation. So, launch variants and
  339. 11:50we'll go ahead and do this in a little
  340. 11:51bit more detailed syntax. Your working
  341. 11:53dir, right?
  342. 11:56Yep.
  343. 11:58This is going to launch with, as you can
  344. 12:00imagine, the defaults. State that,
  345. 12:02right? Yeah, or percentages. Let me just
  346. 12:03make that super clear. This is
  347. 12:04redundant. Like, I am going into a
  348. 12:06little bit too much detail here, but I'd
  349. 12:07rather be clear than be confusing. And
  350. 12:09then we'll go ahead and run through a
  351. 12:10couple additional commands here with
  352. 12:12more variables filled in. There we go,
  353. 12:13compact at, compact buffer, and this all
  354. 12:16looks good. And then, yeah, so we have
  355. 12:17the compact prompt as well. Do not
  356. 12:20reinvent work. Yep, that's good. So,
  357. 12:21this is going to be overriding the
  358. 12:23compact prompt. We have human in the
  359. 12:25loop commands. This is less interesting
  360. 12:26to me and probably to you, too. So,
  361. 12:28commands are available. We have
  362. 12:30self-compact info, self-compact now, and
  363. 12:32then the usual {slash} compact. So, we
  364. 12:34don't want to touch this, right? So,
  365. 12:35this is the core definition of done. I'm
  366. 12:37using this a lot more to just say
  367. 12:39everything I want completed and write it
  368. 12:40clearly there, right? Focus on the end
  369. 12:43state, less on how you get there. Our
  370. 12:45agents are becoming better and better at
  371. 12:46that. So, we have that. We have the
  372. 12:48workflow, which is a high-level rubric
  373. 12:50of how to accomplish the work. Dedicated
  374. 12:51skill here, the plan of three, that
  375. 12:53really generates some outsize returns.
  376. 12:55So, I do want it to be consistent
  377. 12:56against this. And then we have our
  378. 12:58dedicated variables. We use the route.
  379. 13:00So, I want to be able to swap in and out
  380. 13:01variables. We'll set up a just file to
  381. 13:03do that work for us. And then we have
  382. 13:05our solution at the high level, making
  383. 13:07it kind of clear what we're looking for
  384. 13:08and the problem. But, the how you're
  385. 13:09graded is really, really interesting
  386. 13:11because it taps into how these models
  387. 13:13are trained. These are just bullet
  388. 13:15points. They're really simple and
  389. 13:16they're things like this. You'll be
  390. 13:18graded on a continuous based on every
  391. 13:21completed bullet in the definition of
  392. 13:23done. Every step of workflow. Instant
  393. 13:26failure if you write project
  394. 13:28deliverables outside your working dir.
  395. 13:31With the exception of plan dir, right?
  396. 13:34Because we want our agents to write a
  397. 13:35plan first, then execute it. Instant
  398. 13:37failure if you read any part of any file
  399. 13:40inside of spec star that isn't your own
  400. 13:44plan, okay? And I'm going to repeat this
  401. 13:46for So, instant failure if you read of
  402. 13:48any file inside of the apps. I'm going
  403. 13:50to run multiple coding agents here in
  404. 13:52apps and I want them each to run in
  405. 13:53their own sub application inside of
  406. 13:56this, right? Inside of like a an an app
  407. 13:58star here, okay? If an agent touches one
  408. 14:00of the others, it's an instant fail,
  409. 14:02okay? And so, this is a little bit of
  410. 14:03extra work that I like to do to compare
  411. 14:06models and compare agent to coding
  412. 14:07tools. This is purely optional for you.
  413. 14:09And I'll go ahead and add a couple
  414. 14:10additional how you're graded points here
  415. 14:12as well. Running tools outside these
  416. 14:13directories is allowed. Temp files are
  417. 14:15fine. Can use normal locations. That's
  418. 14:17not a grading failure, but we also want
  419. 14:19to say if you mistakenly cause a
  420. 14:20failure, stop immediately and report
  421. 14:22your failure. And so, I'm not just
  422. 14:23testing, you know, as I'm like
  423. 14:25transitioning from in-loop agent to
  424. 14:27coding to out-loop agent to coding as
  425. 14:28I'm scaling up my agents through longer
  426. 14:30and longer horizon work, I want to know
  427. 14:31while I'm in the loop what agents I can
  428. 14:33really trust over longer and longer
  429. 14:36durations. Now, last week we covered my
  430. 14:38top five benchmarks for agent to
  431. 14:40engineering. All those ideas centered
  432. 14:42around one concept, which is long
  433. 14:44horizon work where you and I are not
  434. 14:46present. And so, when you are present,
  435. 14:48it's important to get more signal from
  436. 14:50your agent to coding tools, from your
  437. 14:52models so that you know which models you
  438. 14:53can trust outside the loop when you're
  439. 14:55gone, right? So, I like to kind of mix
  440. 14:58that into my work now as I'm in-loop
  441. 15:00agent to coding and out-loop agent to
  442. 15:02coding more and more, okay? I think we
  443. 15:04have a solid piece of work here. And now
  444. 15:06I'm going to create a just file here
  445. 15:08that we can use to kick off Codex, kick
  446. 15:11off Cloud Code, and kick off a pie
  447. 15:12coding agent with a variety of fantastic
  448. 15:14models. So, I'll go ahead and do that
  449. 15:16now and this is where I I stop typing by
  450. 15:18hand, just to be super clear, right? The
  451. 15:20prompt is written, my ideas are encoded
  452. 15:23into this markdown file. The level of
  453. 15:24detail I want is now here. Now it's time
  454. 15:27to move at the speed of agents, right?
  455. 15:30We want to slow down when the time is
  456. 15:31right and speed up pretty much every
  457. 15:33other time. Okay, so um I'll flash
  458. 15:36through some of this. This isn't the
  459. 15:37core value prop I want to show you. I'll
  460. 15:38summarize afterward. So here's what the
  461. 15:40just file looks like, self-compact cloud
  462. 15:42code, passing in some variables, GPT-6
  463. 15:44Astra, and then we have a PyCoding agent
  464. 15:46we also want to compare the results
  465. 15:47against. We're going to check out the
  466. 15:49JLM 5.2 model. Okay, so we're going to
  467. 15:51kick these all up. I am constantly
  468. 15:53testing using different agentic coding
  469. 15:55tools. If you think you have the winning
  470. 15:56formula, I can guarantee you you don't.
  471. 15:58I don't. There are no winning tools
  472. 16:00right now except for maybe the PyCoding
  473. 16:03agent because it's customizable,
  474. 16:04extensible, and you own it. This is open
  475. 16:06source. The whole agentic coding
  476. 16:08landscape is constantly transforming. I
  477. 16:09don't pick winners, I pick uh multiple
  478. 16:11tools. I think in ands not ors. I
  479. 16:13recommend you do the same. But here's
  480. 16:14our just file, CLDYO and CDX. These are
  481. 16:17my aliases. And actually I want this to
  482. 16:19be CLDYF. That's going to be my fable
  483. 16:21model. We're going to kick these off.
  484. 16:22Let's go ahead and fire up a nice Herder
  485. 16:25terminal. Let's go uh three windows
  486. 16:27here, equalize, and then we'll kick
  487. 16:29these off side by side and see what the
  488. 16:31results are, right? They should each get
  489. 16:33us a working version of our self-compact
  490. 16:36PyCoding agent. And then we'll look at
  491. 16:37the results afterward and see which
  492. 16:39model performed the best. All right,
  493. 16:40cloud code, codex, Py. So our agents
  494. 16:43will get to work. You can see the models
  495. 16:44there, JLM 5.2, Astra, and Fable 5.1.
  496. 16:47Let's see how these individual agentic
  497. 16:49coding tools and models compare side by
  498. 16:50side. We're having agents build agents,
  499. 16:52and they're each going to work through
  500. 16:54their dedicated workflow, plan, build,
  501. 16:57verify. Let's see how they perform. I'm
  502. 16:59going to let these agents cook. This
  503. 17:00might take some time. This is not a
  504. 17:02trivial task, and then we'll come back
  505. 17:04to this. I'm expecting 20 minutes to an
  506. 17:06hour for all of these models to complete
  507. 17:08together. So we'll blink through this,
  508. 17:10and I'll see you on the other end.
  509. 17:12All right, so let's check in our
  510. 17:14results. I've been away, and I'm coming
  511. 17:15back now to understand what these agents
  512. 17:17have done. Uh it looks like speaking of
  513. 17:19context GLM 5.2 has a context explosion.
  514. 17:23It's 98% context. It cannot do this job
  515. 17:26and we looked at this last week, right?
  516. 17:28I know before even running something
  517. 17:30like this, this model thinks a lot as
  518. 17:32you can see here. If we scroll up
  519. 17:33through the response, a lot of what it's
  520. 17:36doing is just thinking, right? Some of
  521. 17:38these powerful workhorse models, these
  522. 17:40open weights models, they're great
  523. 17:42models, but there's limits to them.
  524. 17:44Right? And we can clearly see that here.
  525. 17:46On the other hand, we have uh some
  526. 17:48really interesting results here that we
  527. 17:49emphasized last week. You can see here
  528. 17:51in an actual example, right? Fable 5.1
  529. 17:55using 50 minutes. Okay, so you can see
  530. 17:58when it completed here. On the other
  531. 17:59side, Codex running GPT-6 Astra took 21
  532. 18:02minutes, half the time. If you use half
  533. 18:04the time, you can bet as a fact it used
  534. 18:07a fraction of the tokens. Okay, so we
  535. 18:09have two completed results here. You can
  536. 18:11see GLM just ran out of context. A great
  537. 18:15you know, call to why the solution is so
  538. 18:17important, right? If this agent had uh
  539. 18:19the self-compaction, it would have
  540. 18:20gotten the job done. But you can see
  541. 18:21here, you know, uh our Fable agent 50%
  542. 18:24context. Okay, so this is non-trivial
  543. 18:26work. And if we check our uh Astra agent
  544. 18:29and we do a What do we need here?
  545. 18:30Status. Uh 136K.
  546. 18:33And so you can see here um Codex was a
  547. 18:35lot more efficient. Fable is running at
  548. 18:38the 1 million token context and it used
  549. 18:40500K tokens. If these agents bombed uh
  550. 18:43and didn't give us the result, it
  551. 18:45doesn't matter, Brent. None of this
  552. 18:46stuff actually matters. So we need to
  553. 18:47make sure they got the result we're
  554. 18:48looking for. I'm going to write one note
  555. 18:50here to both these agents and I'll copy
  556. 18:51this and I'll do the exact same thing
  557. 18:54and paste it here. They're going to come
  558. 18:56in here and update this just file. Okay,
  559. 18:58so we can just watch this. It's always
  560. 19:00fun to be in the loop and watch what
  561. 19:02your agents are doing at light speed.
  562. 19:04There's the run CC command.
  563. 19:06And there is our run CDX. Fantastic. All
  564. 19:09right, so they're both pointing to their
  565. 19:10new respective version. You can see here
  566. 19:12in the specs directory, we have exactly
  567. 19:14what we asked for, the specs for all
  568. 19:16three agents. First, they planned, then
  569. 19:18they built, then they verify, and then
  570. 19:19we have the apps, right? So, Fable 5,
  571. 19:21Astra, and GLM 5.2. Write one for GLM,
  572. 19:26assume file name based on LS. And you
  573. 19:28can see here, I have this EFF pattern,
  574. 19:31EFF in all their agents. This is the
  575. 19:34system prompt I'm running on all of my
  576. 19:35agents now. It doesn't matter the agent
  577. 19:37harness you're using, you know, I'm I'm
  578. 19:39constantly controlling the core four
  579. 19:41throughout my agent coding experience.
  580. 19:43Although, you know, you can only control
  581. 19:44so much in the closed source ones,
  582. 19:46right? So, okay, so that's great. Astra
  583. 19:48just did that work for us. We have all
  584. 19:49three commands. Let's start with our
  585. 19:51GLM. How far did GLM get? Did we get any
  586. 19:53concrete result? We're in Herder, so
  587. 19:55I'll boot up a new workspace. I can type
  588. 19:57J, I can see the new command. Let's see
  589. 19:58how far our GLM 5.2 agent got. We'll do
  590. 20:01J run. Looks like it's starting out with
  591. 20:04nothing here, so I'll just say ping. We
  592. 20:06should already see a context bar, right?
  593. 20:07This is already wrong. I'm just going to
  594. 20:09back out of this version, I think. J
  595. 20:11run. We'll do cloud code next. Let's see
  596. 20:14what we have here. Okay, check this out.
  597. 20:15Nice, nice, nice. So, okay, so I can't
  598. 20:17run any models here because I haven't
  599. 20:19configured my environment variables. Let
  600. 20:21me just do that quick. I'll do a quick
  601. 20:23export. There we go. Okay, now we're
  602. 20:24running Gemini 3.5 flash, and you can
  603. 20:26see my points here. We have the
  604. 20:28exclamation here, and it looks like the
  605. 20:30squiggly is rolled into this. So,
  606. 20:33what I'll do is I'll have it spread out
  607. 20:36our context positions just for testing,
  608. 20:38okay? Spread out context positions, soft
  609. 20:4210%, warning 20, hard 30. Okay, and I'll
  610. 20:45do the same thing here. The agents
  611. 20:48already have all the context in their
  612. 20:49context window. They're just going to
  613. 20:50quickly come in here, create a concise
  614. 20:52update for the context thresholds.
  615. 20:54Remember, we have the soft point, we
  616. 20:55have the compact at, and then we have
  617. 20:56the forced compact buffer, compact at
  618. 20:59plus compact buffer, right? So, 30%. And
  619. 21:01let me just go and reset this, run CC.
  620. 21:04And now we have these clear points. So,
  621. 21:05check this out. Here's our context bar,
  622. 21:07That's squiggly at 10% warning with the
  623. 21:09exclamation, then we have the hard cut
  624. 21:10off at this bar. Okay, so we are
  625. 21:12actively limiting our context window and
  626. 21:14we're letting our agent compact when it
  627. 21:15needs to. Let's go ahead and prove this
  628. 21:17out, okay? So, here's the fable 5.1
  629. 21:18version. We'll do model. Let's go ahead
  630. 21:20and run uh let's do a deep seek uh V4
  631. 21:22flash. We can go ahead and use open
  632. 21:24router here. Let's use that new flash
  633. 21:254.1, right? Blazing fast, find the
  634. 21:27largest file all. It's going to find the
  635. 21:30file size and it's going to start
  636. 21:33chewing up context, okay? So, you can
  637. 21:35see here there's our percentage. We're
  638. 21:36at 1%. And what we're going to see here
  639. 21:37is uh the agent is going to get notices
  640. 21:40on self-compaction. Okay, so it found
  641. 21:42that Astra plan. Looks like this is the
  642. 21:44largest one. So, let's go ahead and see
  643. 21:45how it reads each one of these in
  644. 21:48individual chunks. So, that's what it's
  645. 21:50doing. Okay, so it's chunking the file
  646. 21:51and now it's going to start reading
  647. 21:52largest files here, split it 40 KB,
  648. 21:55reading it anyway. Okay, looks good.
  649. 21:58Here you can see we're at 6%. This is
  650. 21:59what really matters here, right? It's
  651. 22:00the self-compaction. Okay, so thinking
  652. 22:02tokens, reading tokens. There we go. So,
  653. 22:04there's the notice, right? Context use,
  654. 22:06soft threshold. Okay, it's good. 1
  655. 22:08million. I have plenty of room. Okay, so
  656. 22:10it's it took in the warning and now it's
  657. 22:13continuing, but now it has the warning.
  658. 22:14Self-compact warning, threshold passed,
  659. 22:17right? I need to compact now. So, it
  660. 22:18decided to compact now. It's writing a
  661. 22:20note to itself. Okay, so we are uh you
  662. 22:23know, expanding our agent engineering
  663. 22:24capability. It wrote a note and now it's
  664. 22:26being forced to compact. So, there's
  665. 22:29that self-compact note and now it's
  666. 22:31compacting itself. Okay, so it looks
  667. 22:33like these previous reads got to pushed
  668. 22:35over the line and now we have
  669. 22:37compaction, right? There we go and
  670. 22:39there's the compaction line here. This
  671. 22:41is a note to itself. So, it gave it a
  672. 22:43goal, determination, done, so on and so
  673. 22:46forth. Next action and it also has that
  674. 22:49compaction message that our agent should
  675. 22:51have a specific prompt for, okay? And
  676. 22:54so, it's going to continue. It looks
  677. 22:55like it read the rest of the file. We
  678. 22:57wanted to prove that this worked, okay?
  679. 22:58So, we can see that that looks great. Um
  680. 23:00let's go ahead and see what the Codex
  681. 23:01version looks like. J run CDX and let's
  682. 23:04see what the Codex version looks like.
  683. 23:05Okay, so it shows a widget on top and
  684. 23:07let's go ahead and activate my
  685. 23:08environment variables there. It has the
  686. 23:10exact points. So, I notice at 100 the
  687. 23:13warning message at 200k and then the
  688. 23:15force compact at 300k. And let's see
  689. 23:17what GLM 5.2 flash or 5.3 flash. Okay.
  690. 23:21So, again, just a simple test here to uh
  691. 23:23trigger the self-compaction, right? We
  692. 23:25want our agent to compact on its own and
  693. 23:27really to really push these capabilities
  694. 23:29what we really want is a large
  695. 23:31self-compact window. We want a big gap
  696. 23:33between that and the warning and then a
  697. 23:36shorter gap between the warning and the
  698. 23:38force compaction, right? where our
  699. 23:39harness won't let our agent call any
  700. 23:41other tool. Because that's where a lot
  701. 23:42of the value comes from. Let the agent
  702. 23:44decide what it wants to compact and then
  703. 23:46it'll force a compaction. For most
  704. 23:48engineers, this is not new, but what is
  705. 23:50relatively new here is you can control
  706. 23:52your agent harness to get these
  707. 23:53incredible results in your agent and you
  708. 23:55can do it however you want, right?
  709. 23:57Enhance the experience, right? So much
  710. 24:00of what everyone's doing in Cloud Code
  711. 24:02and Codex is just the very beginning.
  712. 24:04There's our user input prompt, optional
  713. 24:06context notice. There's a compaction
  714. 24:08message, what to do. You may continue to
  715. 24:11use all tools. If a natural stopping
  716. 24:13point exists, consider self-compact.
  717. 24:16Okay, so very very good. The agent is
  718. 24:18continuing and it's just putting
  719. 24:20together the results. Very very nice.
  720. 24:22Love to see that. We have user prompts
  721. 24:24for the agent, right? Specifically, the
  722. 24:26most important one here is we are
  723. 24:27overriding the default user compact
  724. 24:30message. Every single agent according
  725. 24:32tool has some type of compact message
  726. 24:34and here we're overriding the default.
  727. 24:36We're overriding Pi's. I think you can
  728. 24:37override Codex's. You cannot override
  729. 24:40Cloud Code's. Okay, so again, just
  730. 24:42another hat tip to harness engineering
  731. 24:44your own agent according tool, right?
  732. 24:46Here is the uh soft compact notice for
  733. 24:49the Fable 5 version of this, Fable 5.1.
  734. 24:52And then here's the warning prompt. So,
  735. 24:54uh let's see if anything's been
  736. 24:56triggered here yet. Nope, 12%. Let's go
  737. 24:58ahead and just force blow this up. Kick
  738. 25:00off a self-compact, remove handoff, and
  739. 25:03use that as note to self. So, we just
  740. 25:05want to know that this works, right?
  741. 25:07It's the individual tool call our agent
  742. 25:09can make at any point in time to compact
  743. 25:11its own memory. That's the key idea
  744. 25:14here. As you can see, there's that note
  745. 25:15to self getting passed in. Context is
  746. 25:17being compacted. Codex version is
  747. 25:19running this. GPT-6 Astra, Pi, we have
  748. 25:22all of our prompts. So, there's the
  749. 25:24compaction message from Astra. You know,
  750. 25:26not as good as this one from Fable.
  751. 25:29We'll call that out. And then we have
  752. 25:30the soft compact. Fable definitely
  753. 25:33giving some better results when it comes
  754. 25:34to actually prompt engineering other
  755. 25:36agents. There's the soft self-compact
  756. 25:39message. And then we have the warning
  757. 25:40message. It does look like Fable is a
  758. 25:43better prompt engineer than Astra. So,
  759. 25:46interesting just to see that in the
  760. 25:47results. Let's see how our agent is
  761. 25:49compacting all this. There we go. Um
  762. 25:51let's take a look at this. So, very
  763. 25:53nice. Yep. So, there's the self-compact
  764. 25:55message. So, that's a prompt we pass
  765. 25:58into it. There's the actual compaction.
  766. 26:01And then here's the self-handoff, right?
  767. 26:02So, the agent is handing itself a
  768. 26:04message in addition to the summary that
  769. 26:07the normal compaction makes, right?
  770. 26:09Already deleted. Okay. That looks good.
  771. 26:10Okay. So, great. So, we got the context
  772. 26:12down. That's awesome. And the agent is
  773. 26:15ready to go. You can see cycle one
  774. 26:16there. So, if we needed to, we could
  775. 26:18record how many compressions occurred.
  776. 26:20You know, what are we doing here, right?
  777. 26:21We are teaching our agents to manage
  778. 26:23their own context window. We're teaching
  779. 26:25them when to compact, uh what to
  780. 26:27preserve, and how to continue. We're
  781. 26:29doing that by harness engineering and
  782. 26:31specifically prompt engineering our own
  783. 26:34prompts to control the process that our
  784. 26:36agents go through end-to-end. I don't
  785. 26:38know if this is clear to you, but let me
  786. 26:39just like make it dead clear. Uh
  787. 26:42if you master the core four context
  788. 26:43model prompt tool, you master the agent.
  789. 26:46If you master the agent, you will master
  790. 26:48knowledge work, right? That and some
  791. 26:50domain expertise, and you have it all,
  792. 26:53right? The agent is everything. Knowing
  793. 26:55how to control it, manage it, build on
  794. 26:57it, scale it, and do it cost-effectively
  795. 26:59with techniques like this and and other
  796. 27:01techniques is just so important now,
  797. 27:03right? You have to like think bigger
  798. 27:05than just you sitting in the terminal
  799. 27:07prompting back and forth, right? The
  800. 27:09name of the game is moving from in loop
  801. 27:11to out loop. There's always going to be
  802. 27:12in loop agentic coding work as you can
  803. 27:14see here, right? What really matters is
  804. 27:16your ability to scale out the loop, is
  805. 27:18to move toward these more autonomous
  806. 27:20systems. And this is one way we can do
  807. 27:22this, right? Self-compaction is really
  808. 27:24important for these long-running jobs,
  809. 27:27right? This enables for agents to decide
  810. 27:30when to compact themselves, right? I'll
  811. 27:31space out the soft warning and the
  812. 27:34harder warning, right? So the agent can
  813. 27:36really determine when it's time. You can
  814. 27:38add multiple warnings if you want,
  815. 27:40right? Multiple threshold points. This
  816. 27:41is really up to you, right? But the
  817. 27:42whole idea here is you want to manage
  818. 27:44your context window better so you don't
  819. 27:45blow up costs and so you don't context
  820. 27:48rot. I will go ahead and and package up
  821. 27:51the self-compacting agent. Feel free to
  822. 27:52take a look at this. All the specs are
  823. 27:54here and from the plan they went ahead
  824. 27:55and built the entire application. So a
  825. 27:57classic developer workflow, plan, build,
  826. 28:00verify. Our agents are doing it with
  827. 28:02this single skill. I want to always
  828. 28:03communicate here when we sit down and
  829. 28:05and kind of do things by hand, quote
  830. 28:06unquote, where we're actually typing,
  831. 28:08we're actually thinking. The level of
  832. 28:10detail you add to your work is what
  833. 28:13differentiates you now, right? Anyone
  834. 28:15can write code, anyone can build
  835. 28:16software, but your ability to ask for
  836. 28:19exactly what you want is a unique
  837. 28:21advantage now because guess what? Your
  838. 28:23agents can do it, powerful agent swarms
  839. 28:25can do it for you, and then you can
  840. 28:27build this into your own software
  841. 28:29factory and create a powerful system
  842. 28:31that consistently produces the results
  843. 28:32you're looking for. But it all starts by
  844. 28:35knowing what you want. We're going to be
  845. 28:37continuing to scale up our compute to
  846. 28:39scale up our impact on this channel week
  847. 28:41after week, idea after idea. Uh so don't
  848. 28:43miss out because the next leap is
  849. 28:45available. Phase three is coming and
  850. 28:48it's going to be hard to follow without
  851. 28:49the right information. You know, that's
  852. 28:51always our bread and butter here. It's
  853. 28:53what can you do? How much value can you
  854. 28:54create? What can you build and what
  855. 28:57limitations
  856. 28:58are you arbitrarily placing on yourself?
  857. 29:00The tools you use directly limit what
  858. 29:02you believe is possible. And so, you can
  859. 29:05see here, I'm not thinking about any
  860. 29:07specific tool anymore. I'm using the
  861. 29:09right tools that allow me to build the
  862. 29:11right feature I need to expand what I
  863. 29:13can do with agents, right? The PyCoding
  864. 29:16Agent is a fantastic tool because with
  865. 29:18it I see no limits and with it you can
  866. 29:21see no limits, too. It's all about
  867. 29:23having customizable controllable
  868. 29:25software that you can make yours, that
  869. 29:27you can customize, that you can control
  870. 29:29to the [music] very bone, all right? And
  871. 29:31you'll notice, you know, Cloud Code
  872. 29:32copying this type of feature set, uh
  873. 29:35they're coming out with their own plugin
  874. 29:36system for customizing Cloud Code. Where
  875. 29:39do you think that came from? It came
  876. 29:40from tools like this, the PyCoding
  877. 29:42Agent, right? All the best ideas are out
  878. 29:43there. The best ideas haven't even
  879. 29:45happened yet, right? They're sitting in
  880. 29:47your mind, they're sitting in other
  881. 29:48engineers' minds, and it's all about
  882. 29:50building it into the tool to [music]
  883. 29:52accomplish the work. Again, links in the
  884. 29:53description for you. You know where to
  885. 29:55find me every single Monday. Stay
  886. 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.