Blog
Getting the Most Out of Your Agents
James
Mattei

The Invisible Ceiling
We all know the rate at which modern AI systems are improving is staggeringly fast. Sometimes it feels like you can’t even go one full week without a new earth-shattering release, a new architectural breakthrough, or a new never-before-seen use case pushing the boundaries of what this technology can achieve. The pace of progress has been so fast that leaders on the bleeding edge are suggesting we pace the frontier for the sake of humanity's continued persistence on Earth. This blazing speed is exciting to see for innovation’s sake, but it also cultivates a nagging, and sometimes overwhelming, feeling that you are falling behind.
All of this rapid development comes with an equally rapid shift in the vocabulary used to talk about the technology. In the span of one year, what was once Prompt Engineering evolved into Context Engineering, then became Harness Engineering, and finally mutated into Loop Engineering. If you peruse Twitter (yes, I'm still calling it Twitter), you can find dozens of Kool-Aid-native-AI grifters pontificating about how Swarm Engineering or Graph Engineering 100x’d their vibe coding effectiveness. I bring up these terms not to further exacerbate the imposter syndrome you may be feeling, but to highlight an underlying similarity between them.
All of these terms effectively describe the same idea: to get the most out of the LLM you are using, you need to be intentional and strategic about the amount, quality, and format of the additional information or instructions you give the model. Prompt Engineering focuses narrowly on the individual prompt you give your LLM at runtime. Context Engineering goes a step further by including the system prompt and any additional context you feed your model, such as using a RAG pipeline to fetch relevant documents. Harness Engineering takes yet another step, highlighting the importance of all the surrounding infrastructure supporting the LLM, especially in longer-running use cases. Loop Engineering has now become the culmination of these techniques, enabling fully automatic agentic workflows that can perform the tasks you need. Despite the different focuses between all these terms, they fundamentally adhere to the same guiding principle that has been a truism in AI for decades: Garbage in → Garbage out.
What is Context Rot?
Context rot is a natural quirk of LLMs' attention and transformer architecture. As the context window of a single session fills up, the model becomes increasingly prone to hallucinations, forgetting earlier specifications from the conversation, and subtly drifting away from the session's initial intent. For developers leveraging LLMs to write code, this degradation is gradual yet inevitable, especially as we use coding agents to tackle more complex bodies of work.
A recent paper from Stanford and MIT investigated this claim. They found that optimizing the harness, or more specifically, how the LLM stores, retrieves, modifies, and processes information, had up to a 6x performance increase. This improvement is far more impactful than any tuning you could do of the LLM model weights. This result makes sense, especially given one of the main limitations of LLMs that has plagued these systems since their inception: Context Rot.

Fortunately, most modern agentic coding platforms already equip users to fight context rot. Better yet, you don’t have to be a bleeding-edge AI researcher to leverage the principles of context or harness engineering to produce better results. This blog will show how context windows are already managed for you and how you can design custom commands to achieve repeatable, higher-quality results.
How Context Windows Secretly Fill Up
Most flagship LLM models boast large context windows in the 200 to 500 thousand token range. In reality, those context windows aren't necessarily that big. Herman Melville's iconic novel Moby Dick would consume approximately 300 thousand tokens (depending on the tokenizer). So while it may seem reasonable to assume we can have these models read the entire book and then answer questions about it, it isn’t that easy. Much like a high schooler who only skimmed through the book for their American Literature class, if you stuff all of Moby Dick into a model’s context and ask it specific questions about the text, the LLM will inevitably provide bogus, vague, or outright incorrect responses. If you really want the LLM to be able to answer your questions correctly and consistently, it needs to have the minimal text snippets that are relevant, and no more.
When working in a large codebase with a complex architecture, the natural inclination is to give the LLM as much information as possible so it knows exactly how to implement any code changes. However, as the model ingests large code files, specific project rules or style conventions, and a long 50-message conversation history debating the utility of adding a cache vs. changing your sharding strategy, the context window can easily become overloaded before a single line of code is produced.
By the time you send the agent off to implement your new feature, the majority of the model’s context will be consumed by preamble, setting it up to produce AI spaghetti-ware. The model will forget coding standards defined in the rules, propose or implement “solutions” inconsistent with the project’s architecture, and lose track of what's already been done, what remains, and what the original goal was.
Fortunately, coding platforms like Cursor implement context compaction behind the scenes. As your context window nears capacity, Cursor will auto-magically scan the chat context and condense or remove information to free up space. This works up to a point, but after several rounds of compaction, there is little to no guarantee that all the information you view as critically important still remains in the model’s context.
You could start a new chat with a fresh context window to address this, but it loses continuity, and you’ll likely copy and paste repeated instructions into the chat. The real solution is to design specific workflows so each agent invocation receives only the context it needs, as efficiently as possible. Sounds simple enough, but how do we actually go from AI-Twitter poster to an actual Harness and Loop Engineer?
Making Commands Go the Distance
By this point, everyone who develops on an agentic coding platform knows about custom commands or skills and how useful they can be. Instead of repeatedly typing out the same prompt to perform the same task you do every day, you can save that workflow in a markdown file that the agent can execute on demand.
Take this commit-msg skill as an example:
After staging your changes, you can invoke the skill to get a nice descriptive commit message adhering to best practices; no more “small changes” message with your 2000-line diff. Additionally, now that you have defined the skill, you can tune it like code; refine the language the model uses, nudge it in the direction you prefer, observe how your changes affect the output, and most importantly, share this skill with your team to alleviate their workloads and flex your Prompt Engineering prowess.
Any task you find yourself explaining the same way more than twice is a candidate for a skill. For me, this includes generating PR descriptions for my work, running our CI pipeline locally to catch issues early, and purging the scourge of wordy LLM comments or documentation from my code. I also like to have an agent review my code for repo-specific best practices: check if my PR is following modern Rust Idioms, is it making proper use of Arrow & RecordBatches, are any new ClickHouse queries are aligned with the defined schemas, did the changes introduce any concurrency or race conditions, etc.
But what if you want to go the distance and ascend to become a true Loop Engineer, and have your agents take your idea from a ticket description to a fully fleshed-out and honed PR for you to review? And how do you accomplish this without burning through your entire context window so that your agent doesn’t lose track halfway through implementation?
Case Study: ship-ticket and Multi-Agent Orchestration
Now that I’ve worked with agentic coding tools for a couple of years, I have found my general workflow for most of my development work follows a similar structure. I start by reading the ticket description I’ll tackle next and making sure I fully understand the acceptance criteria, why they matter for the broader project, and how I can satisfy them with a prototype solution in mind. Then I hand things over to Cursor to produce a plan document I can review before continuing implementation. Once the feature is code complete, I verify and review it before opening the final PR.

This approach to agentic engineering isn’t a one-size-fits all solution; depending on the complexity and size of the ticket, this process can be total overkill and expedite our journey to the heat death of the universe for little gain. If the ticket I’m working on requires a change in one function, it would likely be faster to code the solution manually myself. On the flip side, if the task is sufficiently complex, this engineering flow is unlikely to meet all the requirements. That said, good project management should ensure most tickets are scoped to a reasonable size.
This workflow got me thinking; I already have several skills that I use at various steps of the process. I typically start a new chat with a fresh context, attach the ticket description or the plan document, then invoke the skill at each transition point. I could turn this entire workflow into one larger skill that takes the ticket from description to a complete feature, using the skills I use at each phase of the process.
If you’ve taken what you have read so far to heart, this idea should immediately raise some alarm bells. If I start a new agent and launch this entire pipeline, the context window will be consumed long before it reaches the end, and for complex or critical features, that doesn’t inspire much confidence. The solution is how I ran this workflow myself: each phase in the pipeline gets its own dedicated agent; the skill itself points the agent to spawning sub-agents with the relevant context, invoking the requisite skill, and waiting for the sub-agent to report back. This format minimizes the context consumed by the orchestration agent that needs to see the process through and ensures each phase gets its own dedicated agent with fresh context tailored to the task at hand. And thus, the ship-ticket skill was born.
As I mentioned before, you need to use the appropriate tool for the job for the best results. To use an analogy, think of agentic tools as different landscaping instruments. A manual prompt is your humble hand shovel; great for minor weeds, bugs, and patches, but it won’t be able to help with larger projects like removing a stump. Manually following the workflow diagram above is upgrading to a handaxe; probably overkill for removing some weeds, but is the right tool for the job to remove that stump with a bit of effort. Lastly, ship-ticket is another upgrade to a chainsaw; definitely overkill for any weeding or gardening, makes removing the stump much easier, but still isn’t the right tool for larger deforestation projects like the Bun rewrite to Rust.
Maintaining finer-grained control
Most people who have worked with various different models also know you should use different models for different tasks, both from a cost savings perspective and an efficiency standpoint. While Opus 5 and Fable 5.1 are both incredibly strong models, they are also slow and expensive for coding. Both Composer 2.5 and the Cursor Grok line of models are much more efficient for producing code and use far fewer tokens to do so. Therefore, I wanted to define different models for different phases, and Cursor is smart enough to choose the right model per the skill specification:
Now, depending on where you fall on the manual engineer to full-vibe-coder spectrum, and depending on the importance of the project you’re working on, you will want to review what the agent is cooking up at different stages. I like to imagine I haven’t fully surrendered my critical thinking to the agents yet, so I designed the skill with optional Human-In-The-Loop review gates at different handoffs.
I have the orchestration agent pause just before implementation, so I can review the plan before any code is produced. I then have the agent pause after it runs the tests and the local CI pipeline. Then, I pause again after the agentic code review so I can give it my final look. And just like that, I went from Prompt Engineer to a full-blown Loop Engineer!
Stay tuned for an upcoming blog where I'll dive deeper and share my process for building and improving it. Until then, thanks for reading!




