Claude Code compacts long idle sessions before the cache expires
In the terminal, Claude Code 2.1.299 compacts a conversation of at least 200,000 tokens once it has been idle for about 54 minutes. Version 2.1.300 and Agent SDK 0.3.300 validate tool inputs changed by hooks in the same way as inputs Claude generates itself.
On 14 October Anthropic released two versions of its Claude Code coding agent on GitHub, 2.1.299 and 2.1.300. On the same day it also released version 0.3.300 of the Claude Agent SDK for TypeScript. The changelogs list hundreds of items. For agent work, the changes that matter most concern the cost of long sessions and hooks. Hooks are users' own scripts that Claude Code runs at set points, for example before a tool call.
The API stores the already-processed start of a conversation in the prompt cache, so it does not have to be processed again on the next request. However, cached content expires after a set time. Version 2.1.299 adds idle compaction, which works in the terminal. When a conversation of at least 200,000 tokens has been idle for about 54 minutes, Claude Code compacts it before the one-hour cache expires. According to Anthropic, this means the whole conversation does not have to be processed again when the next message is sent.
Users can change the threshold with the environment variable CLAUDE_CODE_IDLE_COMPACT_MIN_TOKENS. To turn the feature off, add "idleCompaction": false to the settings.json file. According to the changelog, both settings require version 2.1.290 or later.
Version 2.1.300 adds the fields cache_creation_5m_tokens and cache_creation_1h_tokens to the OpenTelemetry api_request event. They show how many tokens were written to the five-minute cache and how many to the one-hour cache. The environment variable CLAUDE_CODE_DISABLE_FILE_MENTIONS, which arrived in version 2.1.299, changes how @-mentions work. When a user references a file with @, Claude receives the file path and reads the file itself with its file tools. Claude Code no longer attaches the file's contents directly to the message.
PreToolUse and PermissionRequest hooks can change a tool's input through the updatedInput field. From version 2.1.300, Claude Code validates this input in the same way as input Claude generates itself. It removes fields the tool does not recognise and blocks the call if the tool rejects the input. Agent SDK 0.3.300 applies the same check to hook callbacks. The SDK's canUseTool callback behaves as before.
Version 2.1.299 also makes other changes to permissions. An MCP server allow rule now applies only to the named server: mcp__a no longer allows a server called a__b. Claude Code now runs UserPromptSubmit hooks before it adds the content of a skill or custom slash command to the prompt. As a result, a hook that blocks a prompt also stops any shell commands embedded in the command. The release also fixes a bug that could let a write operation happen in plan mode if a hook had allowed it.