Claude Code v2.1.307: safety-event telemetry, MCP calls stop double-firing#
Published by Alex Sorokoletov
Part of the Claude Code Version Tracker series. | Official Env Vars | Official Changelog
Claude Code v2.1.307, the release after v2.1.306, adds the claude_code.safety_event telemetry event for every tool call a permission rule, auto mode, a safety check, a hook, or the sandbox stops or sends back; retries an HTTP MCP tool call only when it is read-only or idempotent, so a connection dropped mid-call no longer fires it twice; and adds /claude-api api-version to move API code to version 2026-10-21.[1]
A telemetry event for every blocked tool call#
The new claude_code.safety_event OpenTelemetry event records each tool call that a permission rule, auto mode, a safety check, a hook, or the sandbox stopped, prompted on, or sent back.[1] Each event carries the tool class and name, the tool-use id, a classifier category, a sandbox-violation count, and whether sandboxing was enabled, so an operator can count how often a session's calls are blocked or prompted and which tools trigger it. The event first ships in this build.
MCP connections survive locks, sleep, and dropped calls#
Several MCP paths that failed quietly now recover:
- An HTTP MCP tool call is retried only when it is read-only or idempotent, so a connection that closes mid-call no longer sends the same call twice.[1]
- On macOS, MCP servers that showed "needs authentication" in
claude -pwhile the login keychain was locked now say why, and the next run after an unlock connects without a new sign-in.[1] - MCP servers no longer get reported as timed out, or stay failed in headless runs, when a macOS or Linux machine sleeps while they are connecting.[1]
- A turn no longer starts without an SDK MCP server's latest tools while a background task is running.[1]
Compaction, /clear, and 1M-context fixes#
A conversation cleared with /clear no longer reappears when a cloud or self-hosted runner session restarts, and /autocompact in a cloud session keeps its window across a restart instead of reverting to the default.[1] Turns that read many PDF pages, images, or other large results drop some "Autocompact is thrashing" errors.[1] Requests no longer fail with model-not-found when CLAUDE_CODE_DISABLE_1M_CONTEXT is set and the model is an alias carrying the [1m] suffix, such as opus[1m].[1]
Agents, forks, and the SDK#
Claude Code now retries an unparseable tool call up to twice before ending the turn with an error.[1] Fork subagents launched together are each told which launch is its own, so forks are less likely to start each other's work.[1] A model switch through the Agent SDK's setModel() now waits up to 15 seconds for the API to confirm the model, where it was refused after 5.[1] Subagent transcripts no longer record placeholder token usage and an empty stop reason for streamed responses.[1]
Self-hosted runner#
A runner's checkout hook is now stopped after 30 minutes by default, failing the session's setup; raise --checkout-hook-timeout-min or set it to 0 for a longer hook.[1] Archiving or requeueing a session, or stopping the runner, during a checkout hook no longer leaves the hook's processes running and the slot held.[1] Sessions started with --use-anthropic-git-proxy no longer commit a .claude/settings.local.json left behind by an earlier session.[1]
New Environment Variables#
| Variable | What It Does |
|---|---|
CLAUDE_CODE_SUBAGENT_HISTORY | Gates a subagent history view; when unset the view falls back to the tengu_rustling_crescent feature gate, which is off by default. Present in v2.1.307, with no mention in that release's changelog. |
CLAUDE_CODE_IGNORE_PERSISTED_TRUST | When set, no persisted workspace-trust record counts in the process. A self-hosted runner sets it when started with --trust-workspace false. |
CLAUDE_CODE_DISABLE_LAUNCHER_SIGN_IN | When set, the launcher sign-in path reports switched_off and does not offer launcher sign-in. |
CLAUDE_CODE_DIFF_COPY_ROOT | A self-hosted runner names, in this variable, the folder holding the checked copy of a repository's git settings that Claude Code reads for a workspace diff and nested-repository detection. |
Unattended sessions get more reliable and more observable#
Most of v2.1.307 lands on sessions that run with no one watching. The MCP recovery for a locked keychain, a sleeping machine, and a connection dropped mid-call all target claude -p and headless runs; the /clear and /autocompact fixes target cloud and self-hosted runner sessions that restart; and the 30-minute checkout-hook timeout bounds how long a runner slot stays held by a hook that never returns.[1]
The claude_code.safety_event event is the measurement side of that work. Because it carries both a classifier category and a sandbox-violation count, an operator can tell a permission-rule refusal from a sandbox block across a fleet, and count either without opening a transcript. A blocked call becomes a metric a dashboard can read rather than a line someone has to find.
Sources#
- Claude Code Official Changelog, v2.1.307 release notes
This analysis is conducted for educational and research purposes under fair use principles. All trademarks and software referenced belong to their respective owners.
Related Versions#
- Claude Code v2.1.304: rm on mounted drives asks first, a usage warning when you resume
- Claude Code v2.1.303: fork subagents on by default, idle compaction toggle, classifier model pick
- Claude Code v2.1.301: retry wait cap, safer model downgrades
- Claude Code v2.1.300: prompt-cache TTL control, PDF read caps, gzip on by default
- Claude Code v2.1.299: idle compaction, @-mention paths, relaxed rm prompts
Previous Claude Code analysis: v2.1.306 (October 21, 2026)
All 78 Claude Code analyses: Claude Code Version Tracker · Official Claude Code changelog