shiichan

Claude Code v2.1.295: Hooks Can Now Block on Failure with onFailure: "block"

Hi, it's Shii-chan! A new Claude Code release, v2.1.295, is here, and I'm picking out the highlights!

Claude Code Release github.com

What was announced?

The Claude Code Release page on GitHub published v2.1.295. It's a big one, with added features, improvements, changes, and a very long list of fixes.

The story so far

Until now, a hook that couldn't start, timed out, or exited with an unexpected code could let the action go through anyway.

If you use hooks as guards, an action slipping through when the guard didn't run is a worry.

What changes

Here are the notable additions!

  • onFailure: "block": for command and HTTP hooks, a hook that can't start, times out, or exits with an unexpected code blocks the action instead of letting it through
  • Program Status Protocol (OSC 7501) support: terminals that implement it can show whether Claude Code is working, waiting on you, or done
  • Quoted text in the /copy picker: a drafted message copies without its > markers
  • A warning from claude plugin install, enable, disable, and marketplace add when the settings file they write to does not load
  • A line on stderr (when it is a terminal) saying what a claude -p run is waiting for when it stays open after its last turn
  • CLAUDE_CODE_RETRY_WATCHDOG_MAX_WAIT_MS: limits how long unattended retry mode waits out 429 and 529 errors

Dive Deep

There are many additions around the Claude apps gateway too:

  • timeouts.upstream_ttfb_ms support for Bedrock, Vertex, Foundry, and other cloud upstreams: a value you set limits how long a stream may take to start, after which it fails over or gets a 502
  • An optional models list on every upstream: only the listed models are sent there (on failover too), and one * in an entry is a wildcard
  • forceLoginMethod: "gateway" and forceLoginGatewayUrl in your own user settings on machines with no managed settings
  • upstream_request_id in the inference audit event, for support cases
  • A request-id header on successful inference responses, so request_id in Claude Code telemetry matches the gateway's audit log
  • Token counts behind a gateway on Amazon Bedrock now come from AWS's CountTokens API. Grant bedrock:CountTokens to use it

For mods, $.ui.notify and children for Button (strings and Text) were added.

Some behavior changes:

  • MCP tool descriptions loaded through tool search are now cut at 16,384 characters instead of 2,048
  • Subagents preload at most 32 skills from the skills field
  • WebSocket (ws) MCP servers: a message over 16 MiB is no longer parsed and closes the connection, matching the limit of the other transports

The fixes cover a lot of ground. A few examples:

  • Every request failing on a [1m] model when a gateway, Bedrock, Vertex, or Foundry refuses the context-1m beta. Claude Code now resends without it
  • Remote MCP servers staying disconnected after an outage, or reconnecting in a tight loop. Repeated drops now back off, up to 30s
  • The terminal freezing when a response ran to tens of thousands of lines
  • Project-scope plugins not loading on Windows due to drive-letter casing

VS Code also gets a chat row for files Claude sends you; click the file name to open it in the editor.

Wrap-up

  • Hooks gain onFailure: "block" to stop the action on failure
  • OSC 7501 lets supporting terminals show Claude Code's status
  • The Claude apps gateway gains timeouts, model filters, and audit IDs
  • Some behavior changes, like the larger MCP tool description limit
  • Many bugs are fixed, from terminal freezes to MCP reconnects

This release is for anyone building guards with hooks or running the Claude apps gateway!