Compact, Clear or Hand Off? Running Long Agent Sessions Without Burning Your Limit
This article first appeared on Medium: https://medium.com/@r3dtuxedo/compact-clear-or-hand-off-running-long-agent-sessions-without-burning-your-limit-21c26def6bae Compaction and "continue" both re-read your whole conversation. Treat agent sessions as disposable and keep the state in files. TL;DR Every turn re-sends the whole conversation. Prompt caching keeps that cheap only while the cache is…
This article explains how to run long agent sessions without exhausting your usage limit on Claude AI. The key points are that every turn in an agent session reads the entire conversation so far, including the system prompt, tool definitions, and all previous messages. This can make each turn expensive.
The article recommends treating each agent session as disposable and storing any necessary state in files instead. It walks through the three main options: compacting the conversation, clearing the session, or handing off to a new session. Compaction is most expensive when resuming a session that has been sitting idle. Clearing a session costs nothing but starts the next conversation from scratch. Handing off allows the agent to write a "handoff" file summarizing the current state, which can be loaded for the next session.
The article emphasizes treating agent sessions as scratch space rather than a place to store your work. Compaction on a warm cache costs less than on a cold cache, but both still involve reprocessing the full conversation at least once. Clearing costs nothing but resets progress. Handing off is the most efficient when starting a new task, as it avoids reprocessing the entire history.
The conclusion is to run multi-day work as separate sessions that each fit within a single context window, using handoff files to keep track of progress across sessions. The key takeaway is to stop thinking of agent sessions as a place for your work to live and start thinking of them as temporary scratch space that should be compacted, cleared, or handed off as appropriate.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.