Blog · November 5, 2026 · 8 min read · by Vilva Athiban P B

What Happens When You Step Away From a Claude Code Session: Prompt Cache Expiry, Idle Compaction, and When to Come Back

You give Claude Code a task, it starts working, and you walk away: coffee, a meeting, lunch, the end of the day. The session looks the same when you come back. Underneath, a few things have happened on a clock you did not set. The prompt cache that makes a long conversation affordable has stayed warm or gone cold, the conversation may have been summarised without you, and the first message you type back is either cheap and fast or the most expensive turn of the day. This post walks through that timeline minute by minute, using what Anthropic's own prompt caching, costs and changelog pages say as of 5 November 2026, and ends with a short decision table for what to do before you step away.

The one fact everything else follows from

Claude Code re-sends the full conversation with every request. What keeps that affordable is prompt caching: the unchanged prefix (system prompt, tools, everything said so far) is served from a cache at a fraction of the normal input rate, and only the new tokens are processed at full price. Cached prefixes expire after a period of inactivity, and every cache hit resets that timer. There are two lifetimes: five minutes and one hour. The one-hour version charges a higher rate for cache writes, which is why it is not simply on for everyone.

Which one you get depends on how you pay. On a Claude subscription, within your plan's included usage, the main conversation uses the one-hour lifetime, while everything else (subagents, compaction, session titles, forks, workflows) uses five minutes. With usage credits, an API key, or a cloud provider such as Bedrock, Vertex (Agent Platform) or Foundry, everything is five minutes by default. You can override this with the promptCacheTtl setting or the CLAUDE_CODE_PROMPT_CACHE_TTL environment variable (5m or 1h), and subagentPromptCacheTtl / CLAUDE_CODE_SUBAGENT_PROMPT_CACHE_TTL for the rest; FORCE_PROMPT_CACHING_5M=1 forces five minutes everywhere and ENABLE_PROMPT_CACHING_1H=1 requests one hour for both. These need Claude Code v2.1.242 or later.

// ~/.claude/settings.json
{
  "promptCacheTtl": "1h",
  "subagentPromptCacheTtl": "5m",
  "idleCompaction": false
}

Not sure which bucket you are in? Run one headless request and read the usage block: on a subscription the tokens land under ephemeral_1h_input_tokens; on API billing they land under ephemeral_5m_input_tokens. /usage on Pro, Max, Team and Enterprise also shows a Prompt cache (main) line (v2.1.251 and later) with the hit ratio, the misses, and whether the cache is warm or cold.

$ claude -p "hello" --output-format json
# ... "usage": { "cache_creation": {
#        "ephemeral_1h_input_tokens": 18240,
#        "ephemeral_5m_input_tokens": 0 } ... }

# inside a session:
/usage
Prompt cache (main)   warm (1h TTL, last activity 40s ago)
30%  Compact before you step away · run /compact

The timeline

Minute 0: you step away

Claude is mid-task, or has just finished and is waiting. The cache is warm because the last request was seconds ago. Background token usage in an idle session is small, typically under $0.04 per session for summarisation and command processing. The timer, however, is now running from the last request.

Minute 5: the five-minute cliff (API, credits, cloud providers)

If you are on API billing, usage credits, Bedrock, Vertex or Foundry, and have not changed the default, this is where the cache expires. On a subscription the main conversation sails past; only the five-minute buckets (a subagent you left running, for instance) go cold here. Note that “idle” means no requests at all. A session-scoped /loop task that fires while you are away, a cross-session message delivered as a new turn, or a goal check-in all count as requests: they keep the cache warm, but each one also sends the full context, which is why the costs page lists them under “why usage climbs in a long session.” (crossSessionInbound: hold holds inbound messages; goal check-ins are capped at three per goal from v2.1.246 and CLAUDE_CODE_GOAL_CHECKIN_MINUTES=0 turns them off.)

Minute 54: idle compaction fires (subscription, terminal, 200K+ tokens)

Added in v2.1.299 on 14 October 2026: when a terminal session on the one-hour lifetime holds 200K or more tokens and has been idle for roughly 54 minutes, Claude Code compacts it before the cache expires, so your next message does not have to reprocess the whole history uncached. A community write-up by dsebastien.net (16 October 2026) reports that the trigger is about 54 minutes after the last request and that the machine has to be awake at that moment; that detail is from the write-up, not the docs. Compaction is lossy by design: the transcript is replaced by a summary, and rejected approaches, exact error messages and constraints you set early on can drop out. CLAUDE_CODE_IDLE_COMPACT_MIN_TOKENS changes the 200K floor and "idleCompaction": false in settings.json turns it off (both need v2.1.290 or later). Since v2.1.302 there is an Idle compaction row in /config, and the notice after a compaction tells you how to switch it off.

Minute 60: the one-hour cliff

For a subscription session below 200K tokens, or with idle compaction disabled, the cache now expires. The conversation is intact, but the next request is processed from scratch; the docs put it plainly: the first turn back after stepping away can be noticeably slower. It is also the worst moment to run /compact, because the summarisation request has to reprocess the entire uncached history first.

The next morning

Whatever bucket you are in, the cache is cold. If idle compaction ran, you resume from a summary and the first message is cheap but some detail is gone. If it did not, you resume with the full transcript and pay to re-read all of it once, after which the cache is warm again. One wrinkle fixed in v2.1.304: self-paced /loop wakeups scheduled at the one-hour maximum used to land just after the cache expired and re-read the conversation uncached every time; they no longer do.

What to do before you leave: a decision table in prose

Back within the hour (five minutes on API billing). Do nothing. This is the cheapest outcome: the cache is warm, the first message is fast, and no summary has thrown anything away. The practical problem is knowing when to come back, which is what a “Claude is done” or “needs permission” alert is for; see the notifications guide.

Away longer, and the session is ordinary. Run /compact Focus on the migration and the failing tests at the natural break before you go, while the cache is warm and the summary is cheap, rather than mid-task. Or let idle compaction do it for you at minute 54 if the session is over 200K tokens. The context management guide covers writing a focus that keeps what you will need.

Away longer, and the session is precious. If the conversation holds reasoning you cannot afford to lose to a summary, set idleCompaction to false and accept one slow, uncached turn when you return. Do not switch model or effort on that first turn back: either change invalidates the cache again on most models.

Done with the task. /clear costs nothing and gives the next task a fresh start. If you overshot, /rewind truncates back to a cached prefix, which is cheaper than compacting.

Something will run while you are gone. A background task or scheduled loop keeps the cache warm but bills the full context on every wakeup, and goal check-ins do the same; use the limits above, and if you are watching a usage limit rather than a cache, the usage-reset notification post covers that side.

One note on /usage: rows such as 30% Compact before you step away · run /compact are recommendations. The f fix shortcut (v2.1.305 and later) does not run /compact for you; a row ending in run and a command is one you run yourself.

Getting back inside the window

All of this reduces to one observation: on a subscription, the hour after your last message is the window in which coming back carries no penalty; on API billing it is five minutes. Claude usually finishes or stalls on a permission prompt well inside it. The expensive sessions are the ones where it finished at minute eight and you noticed at minute ninety.

Keep reading

Desk Exercises for Programmers: 15 Moves to Do While Your AI Agent Codes

7 min read

Exercise While Coding: Turn Claude Code Wait Time Into Micro-Workouts

7 min read

Claude Code Notch Notifications on Mac: See When Claude Is Done Without Watching the Terminal

7 min read

Claude Code Tips and Tricks: 12 Ways to Use Claude Code Effectively

8 min read

Claude Code Multiple Sessions: How to Run Agents in Parallel Without Losing Track

6 min read

A Claude Code Workflow That Doesn't Involve Watching the Terminal

5 min read

Claude Code Hooks: A Practical Guide to Automating Your Agent Workflow

7 min read

Claude Code Auto Mode: Fewer Permission Prompts Without Living Dangerously

7 min read

Claude Code Subagents: How to Delegate Work to Specialized Agents

7 min read

Claude Code Context Management: Treat the Context Window Like a Budget

6 min read

Per-Subagent Model Selection: Route the Grunt Work Down, Keep the Judgment Up Top

7 min read

Skills and Plugins: How to Teach Claude Code Your Way of Working

7 min read

Claude Code Background Tasks: Run Long Commands Without Blocking Your Session

6 min read

Codex CLI Notifications: How to Get a Ding When Codex Is Done or Needs Input

7 min read

Cursor Notification When Done: Every Way to Get Notified When Cursor Finishes

6 min read

Claude Code Notifications: How to Get Notified When Claude Code Finishes or Needs Your Input

6 min read

Want to Be Notified When Claude Responds? How Claude Notifications Work on Web, Desktop, and Mobile

5 min read

Claude Code Notification Scripts: Copy-Paste Recipes for Every Platform

6 min read

Get a Ding the Moment Codex Needs Your Response

6 min read

Get Notified the Moment Claude Code Is Waiting for Your Input

6 min read

“Notifications Are Turned Off for Claude” — Here Is the Fix

6 min read

Codex Sound When Done: Make Codex CLI Play a Sound When It Finishes

6 min read

terminal-notifier + Claude Code: Native macOS Alerts When Your Agent Finishes

6 min read

Gemini CLI Notifications: How to Get a Sound or Alert When Gemini Finishes

6 min read

Get Claude Code Notifications on Your Phone

6 min read

Claude Code Remote Control, Explained

7 min read

preferredNotifChannel: Claude Code's Built-In Notification Setting

6 min read

Claude Code Notifications in tmux and Over SSH

7 min read

Claude Code Effort Levels: Why Your Setting Keeps Getting Ignored

8 min read

Codex vs Claude Code Notifications: How Each One Tells You It Is Done

8 min read

Claude Code Notifications Not Working: A Diagnostic Checklist

10 min read

Claude Code Notifications Inside Your Editor's Terminal

7 min read

CLAUDE_CODE_DISABLE_BACKGROUND_TASKS Explained

7 min read

CLAUDE_CODE_DISABLE_BG_SHELL_PRESSURE_REAP Explained

8 min read

Cursor Alerts Explained: Every Alert Cursor Raises, and How to Control Them

7 min read

Claude Code Environment Variables: The Groups That Actually Matter

10 min read

Claude Code Notifications on WSL and Windows

9 min read

Claude Code Checkpoints and /rewind

8 min read

Claude Remote Control: How It Works, Turning It Off, and Auto Mode

7 min read

Claude Code /loop: Poll a Deploy, Babysit a PR, and Get Told When It's Done

8 min read

Setting Up NotchFit With OpenAI Codex CLI: Hooks, $notchfit-plan, and the Daily Flow

7 min read

Claude Mods Explained: What the New Plugin Layer Can Do, and How to Turn On 'You Should Know'

9 min read

NotchFit vs Mac Break Reminder Apps: A Clock or a Signal From Your Coding Agent?

8 min read

Claude Code Headless Mode: Running claude -p in Scripts and CI, and the Three Signals That It Finished

10 min read

Building a Movement Habit at a Desk: Use the Agent Run as the Cue, One Set as the Unit, and Streaks Carefully

8 min read

Claude Code MCP Servers Explained: Adding Servers, Choosing a Scope, Handling Secrets, and Why Long Tool Calls Go to the Background

10 min read

/notchfit:plan Explained: How Claude Code or Codex Writes a Weekly Workout Plan the Notch Can Actually Run

8 min read

Claude Code Spinner Verbs Explained: What “Pondering” and “Brewing” Mean, How to Change Them, and Why You Should Stop Watching the Spinner

7 min read

Why NotchFit's Done and Permission Alerts Wait Until Your Set Ends, When That Costs You, and How to Turn the Workout Off

7 min read

How to Resume a Claude Code Session: --continue vs --resume, Naming Sessions, the Session Picker, Branching, and What Comes Back

9 min read

NotchFit on a Mac Without a Notch: How Pill Mode Works on Mac mini, iMac, Mac Studio and a MacBook With the Lid Closed

6 min read

How to Run a Claude Code Session in the Background: /background, claude --bg, Agent View, and Getting Back to It

9 min read

What a Notch App Can See: NotchFit's Local-First Design, What the Claude Code and Codex Hooks Send, and What Stays on Your Mac

7 min read

Why Codex CLI Asks for Permission Every Time, and How to Tune the Sandbox and Approval Policy Without Going Full Access

8 min read

What to Do While Claude Code or Codex Works: A Simple Protocol for the Two-to-Twenty-Minute Gap in Every Agent Run

7 min read

Is It Possible to Get a Notification When Claude Code or Codex Hits a Reset? Yes for Claude Code: the quota_auto_resume Hooks, Explained

8 min read

What a MacBook Notch App Can Actually Do: The Five Kinds of Notch Utility, Their Trade-offs, and Where NotchFit Fits

7 min read

How to Make MCP Servers Not Take Up as Much Context in Claude Code: Tool Search, alwaysLoad, Scopes and Output Caps

8 min read

The notchfit Command Line: Drive Your Workout, Read Status as JSON, Validate Plans and Test the Notch Without Leaving the Terminal

7 min read

How to Audit MCP Tool Calls Made by Claude Code: A Five-Minute Hook Audit Log, OpenTelemetry Tool Events, and the Transcript for Investigations

9 min read

Exercise Snacks: What the Research Actually Says About One-Minute Vigorous Breaks, What It Does Not, and How NotchFit's Agent-Run Sets Compare

8 min read

How Long Until a Claude Code MCP Tool Call Times Out? The Four Timers (Startup, Two-Minute Backgrounding, Idle, Wall-Clock), Their Defaults, and Which One to Change

8 min read

Sitting Too Long as a Developer: The Posture Problems Coding Agents Made Worse, What the Research Says About Breaking Up Sitting, and How NotchFit Turns an Agent Run Into the Break

8 min read

Claude Code .mcp.json Explained: Where Project-Scoped MCP Servers Are Read From, What Happens in Subfolders and Monorepos, and Why a Committed Server Shows Pending Approval

8 min read

Standing Desk Exercises for Developers: Why Standing Still Is Not the Goal, Eight Movements That Fit a Thirty-Second Agent Run, and How NotchFit Cues Them From the Notch

8 min read

The claude mcp Command Reference: add Syntax by Transport, What --scope local, project and user Actually Mean, add-json and add-from-claude-desktop, list, get, remove, login and serve

9 min read

Your First Week With NotchFit: Install and Simulate, Run Real Tasks, Write a Smaller Plan Than You Want, Tune the Alerts, Survive the First Skipped Day, and Decide What Stays

8 min read

How to Stop a Running Claude Code Task: Esc vs Ctrl+C, Background Tasks, Subagents, and Disconnecting Remote Control

8 min read

Pomodoro vs Agent-Driven Breaks: Timing Movement to Claude Code and Codex Runs Instead of a Timer

7 min read

Claude Desktop MCP Configuration: claude_desktop_config.json, Logs, Extensions, and the Difference From Claude Code

9 min read

The 20-20-20 Rule for Developers: Eye Strain, the Evidence, and Agent Runs as the Cue

8 min read

Claude Agent SDK + MCP Servers: mcpServers, allowedTools, Status Checks and Auth

9 min read

Discreet Desk Exercises for an Open-Plan Office While Claude Code Runs

7 min read

claude remote-control Server Mode: Run Claude Code as a Session Server

9 min read

Wrist and Forearm Stretches for Developers: A 60-Second Routine for Every Claude Code Run

7 min read

Claude Remote Control vs Claude Code on the Web: Which to Use and How They Differ

9 min read

Neck and Shoulder Stretches for Developers: A 90-Second Routine Between Agent Runs

7 min read

Hip Flexor and Lower Back Stretches for Developers: A Two-Minute Standing Routine Between Agent Runs

7 min read