Safeguard
AI Security•

What state survives when a Claude Code cloud session goes idle?

Idle Claude Code cloud sessions pause, then expire. What is restored, what is lost, and what that means for secrets, caches, and long running agent tasks.

Safeguard Security Team
6 min read

According to Anthropic's documentation, a Claude Code cloud session's VM pauses with its files saved after a few minutes of inactivity, and your next message restores the same VM. After a longer inactivity period the VM is reclaimed. Reopening the session provisions a fresh VM and restores conversation history, but not background work such as running subagents or shell commands.

The lifecycle in three stages

  1. Active. The VM runs your session. Commands execute, files change, the agent works.
  2. Paused. After a few minutes without activity, the VM pauses with its files saved. The next message restores the same VM and starts Claude Code again.
  3. Expired. Cloud sessions stop after a period of inactivity and the VM is reclaimed. Reopening the session from the web interface provisions a fresh VM.

The documentation adds that a session counts as inactive while it waits for you to approve an MCP connector tool call or to sign in to an MCP server, and it can expire during that wait. So a session blocked on a human approval can lose its VM.

What is restored and what is not

ItemAfter pauseAfter expiry and reopen
Files in the VMKeptA fresh VM, not the old files
Conversation historyKeptRestored
Running shell commandsResumed with the VM state, per restoreNot restored
Background subagentsNot documented for pauseNot restored
Scheduled loop wakeupsNot documented for pauseNot restored, rerun the loop
Permission modeKeptSession resumes in the mode it was in
Environment variablesDefined by the environmentDefined by the environment

The expiry rows come directly from the documentation's list of what is and is not restored. The pause rows rely on the documented statement that files are saved and the same VM is restored.

Why this matters for security

Fresh VM means a clean slate for files. If an agent left credentials or data in files, expiry removes them with the VM. That is a useful property, but do not rely on it as your only cleanup, since a paused VM keeps files until reclaimed.

Pause keeps whatever is in the VM. If a token was written to a file during the session, it sits there while the session is idle. A shared or forgotten session is a place for that to hide.

History persists separately. Conversation history is restored even after expiry, and the documentation notes shared sessions may contain code and credentials. Anything printed into the conversation outlives the VM.

Long approvals can expire the session. If your policy requires human approval for tool calls, plan for the possibility that the VM is gone by the time someone answers. Design tasks so they can be resumed from a branch and conversation, not from in-VM state.

Setup caching has its own rule. The documentation says an environment cache stores files only, not running processes, and a setup script is cached only when it finishes in roughly five minutes. A slow setup script is rerun more often, which is a cost and a consistency issue.

A worked example: an overnight task with an approval gate

An illustrative scenario. A team starts a long refactoring task late in the day. Their policy requires approval before the agent calls an MCP connector that writes to the ticket system.

  1. At 6 pm the agent works and pushes a branch every hour.
  2. At 8 pm it reaches the connector call and waits for approval.
  3. Nobody answers. The session sits idle, pauses, and later expires.
  4. At 9 am a developer opens the session. The conversation is there. The VM is fresh. A background test run is gone.
  5. The developer checks the pushed branch, which holds the earlier work, and asks the agent to continue from it.

Lessons: push progress to a branch regularly, keep approvals in a window when someone is available, and do not store task state only in the VM.

Practices that follow

  1. Commit and push to the task branch at natural checkpoints, so expiry loses nothing important.
  2. Never write credentials to files in the VM. Use a network secret or proxy.
  3. End sessions when the work is done instead of leaving them paused.
  4. Archive or delete finished sessions according to your retention policy.
  5. Keep setup scripts under about five minutes so caching applies.
  6. Document the idle behavior in your runbook, so reviewers know what to expect.
  7. Treat the session link as sensitive for as long as the session exists.

Questions for your own vendor review

QuestionWhy
How long until a paused VM is reclaimed?Sets how long files sit
Are files encrypted at rest while paused?Affects stored data risk
Who can restore a paused session?Access control on state
What persists after deletion?Retention
Are approval waits counted as inactivity?Planning for human gates

Try it yourself

Click through it at your own pace, or open it full screen.

Look at how monitoring keeps checking after the first scan, which is the habit you want for long lived agent sessions and cached environments.

Where Safeguard fits

Safeguard does not manage Claude Code sessions. Its agent identity and compliance and evidence automation help you attribute and record agent activity, and dependency scanning covers what cached environments contain.

Quick check

Is a paused cloud session safe to leave overnight?

Files stay saved while it is paused, so anything sensitive in the VM stays there. Remove credentials from files and end sessions you no longer need.

Is a background test run restored after expiry?

No. The documentation says background work, such as subagents and shell commands, is not restored when a fresh VM is provisioned.

Does expiry delete the conversation?

No. Conversation history is restored on reopen. Treat anything printed in it as long lived.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.