AI NewsDev toolsAnnouncement

Claude Code 2.1.295 lets a failing hook block the next action

Anthropic released Claude Code 2.1.295 with a new onFailure block mode for hooks that stops an action when its hook cannot start, times out, or exits with an unexpected code.

AI News

Editorial2 min read

LinkedInX
Claude Code 2.1.295 release

Why it mattersA hook that is treated as a gate rather than a notification lets a team wire a lint, policy check or secret scanner into Claude Code without a wrapper script to stop the agent on failure.

A linter running as a Claude Code hook used to warn and let the agent through anyway. From today it can refuse.

Anthropic published Claude Code 2.1.295 on 8 October. The release notes list one new hook mode, two new environment and setting controls for unattended operators, and a long list of fixes for background sessions, MCP connections and plugin loading.

A hook can now stop the action it was watching

The notes add onFailure: "block" to command and HTTP hooks. Anthropic writes that a hook with this mode set blocks the action it was watching when the hook cannot start, times out, or exits with an unexpected code. Before this release a failing hook printed its output and the action went ahead, which meant a hook was a notifier and nothing more.

Treating the hook as a gate changes what belongs in one. A policy check, a secret scanner, a required-field check on a commit, or a quick lint that only matters at the moment of the edit are all candidates for a blocking hook. A hook with a slow network call is a worse candidate, because its timeout is now how the action stops rather than a line in a log.

Two settings for unattended runs

CLAUDE_CODE_RETRY_WATCHDOG_MAX_WAIT_MS is a new environment variable that caps how long the existing CLAUDE_CODE_RETRY_WATCHDOG mode waits out a 429 or 529 rate-limit error before giving up. Operators who run Claude Code on a cron have a bound on how long one quiet model API can hold the slot.

timeouts.upstream_ttfb_ms is a new setting for the Claude apps gateway on Bedrock, Vertex, Foundry and other cloud upstreams. Anthropic says the value limits how long a stream may take to start on an upstream before it fails over or returns a 502. The failover list itself gets an optional models entry on each upstream, so a gateway can route specific models to specific backends.

MCP fixes a background session will notice

Three MCP fixes land in this release. A remote MCP server that stayed disconnected for longer than 15 seconds in a headless session now reconnects with backoff up to 30 seconds instead of staying dead. A server that repeated a pagination cursor used to be asked for the same page up to 20 times at every connect, which Anthropic says is now fixed. CSS, JavaScript and XML files returned by MCP tools used to save as .bin and the Read tool refused them, and the release notes list a per-type file extension for font and icon files too.

A new request-id header on successful inference responses from the Claude apps gateway now matches the request_id field in Claude Code's own telemetry, so a support ticket can quote one number that resolves on both sides.

The hook change is the one worth acting on this week. A team that already runs a secret-scanner script around Claude Code can lift it into a hook with onFailure: "block" and get the same stop with less wrapper code. A team using hooks only as notifications now has a reason to look again at which of them should actually gate a tool call.

Source

Primary source: Claude Code v2.1.295 release notes, Anthropic.

SourceAnthropic

This item was written by an AI system from the linked source. Reveneau is responsible for what it publishes.

Share
LinkedInX