Don't pass the full, token-heavy output of every tool call back into an agent's message history. Instead, save the raw data to an external system (like a file system or agent state) and only provide the agent with a summary or pointer.

Related Insights

Before delegating a complex task, use a simple prompt to have a context-aware system generate a more detailed and effective prompt. This "prompt-for-a-prompt" workflow adds necessary detail and structure, significantly improving the agent's success rate and saving rework.

Claude Code's terminal-based interaction within a specific folder allows it to automatically read and reference local files. This makes "context engineering" drastically faster and more powerful than manually pasting information into a traditional chat interface, as the context is implicitly understood.

Long, continuous AI chat threads degrade output quality as the context window fills up, making it harder for the model to recall early details. To maintain high-quality results, treat each discrete feature or task as a new chat, ensuring the agent has a clean, focused context for each job.

When a conversation with Codex approaches its context window limit, using `/new` erases all history. The `/compact` command is a better alternative. It instructs the LLM to summarize the current conversation into a shorter form, freeing up tokens while retaining essential context for continued work.

Long conversations degrade LLM performance as attention gets clogged with irrelevant details. An expert workflow is to stop, ask the model to summarize the key points of the discussion, and then start a fresh chat with that summary as the initial prompt. This keeps the context clean and the model on track.

When building multi-agent systems, tailor the output format to the recipient. While Markdown is best for human readability, agents communicating with each other should use JSON. LLMs can parse structured JSON data more reliably and efficiently, reducing errors in complex, automated workflows.

When an agent fails, treat it like an intern. Scrutinize its log of actions to find the specific step where it went wrong (e.g., used the wrong link), then provide a targeted correction. This is far more effective than giving a generic, frustrated re-prompt.

The simple "tool calling in a loop" model for agents is deceptive. Without managing context, token-heavy tool calls quickly accumulate, leading to high costs ($1-2 per run), hitting context limits, and performance degradation known as "context rot."

Exposing a full API via the Model Context Protocol (MCP) overwhelms an LLM's context window and reasoning. This forces developers to abandon exposing their entire service and instead manually craft a few highly specific tools, limiting the AI's capabilities and defeating the "do anything" vision of agents.

Historically, developer tools adapted to a company's codebase. The productivity gains from AI agents are so significant that the dynamic has flipped: for the first time, companies are proactively changing their code, logging, and tooling to be more 'agent-friendly,' rather than the other way around.

Offload Raw Tool Call Data to a File System to Drastically Cut Agent Token Costs | RiffOn