Post

Knowing how the agent loop actually works changed how I prompt more than any prompt-engineering tip did. Once you see the tool-call trace filling the context window, a lot of best practices suddenly make sense.

This is the kind of documentation the ecosystem desperately needs. Everyone's shipping agents but few are writing down the patterns that actually work. The gap between "agent demo" and "agent in production" is still massive. Thank you for this. 🙏

Context dilution isn't forgetting — it's statistical drift. Older tokens get weight-diluted as the window fills. Running AI agents in production continuously, externalizing all persistent state to files between turns was our single biggest reliability improvement.

Tool calls failing ambiguously — partial side effects, timeouts mid-write — is underrepresented in most architecture docs. The agent assumes success and its state model quietly diverges from reality. Explicit verification steps after tool calls helped us more than any structural change.

To generate the self-check portion of the response below though it has to have the context of what it has already generated so far though right? So it has to be looking back at generated info as it's going and producing new text (I think). Mostly just trying to understand the underlying mechanism

I've seen Claude answer a counting question one way in a response and then scrape the web page in the same output and say "nope, it's actually y instead of x", which is part of what makes me think it's generating and looking back as part of the thinking process.

the section on tool call overhead changed how I work. I started logging my agent's tool calls and realized 60% were re-reading the same files. added a summary file the agent updates as it goes and token usage dropped in half.

The real value is understanding failure modes—where agents hallucinate, loop, or misinterpret intent. That's where the operational leverage lives. What specific patterns did you find most impactful for keeping agents reliable at scale?

Looking at the session files reveal the context (and other things). With Pi coding agent: /session File: ~/.pi/agent/sessions/MYSESSION.jsonl cat ~/.pi/agent/sessions/MYSESSION.jsonl | jq . All agents should (but doesn't sadly) have easy way to see the context