Claude Code 2.1.317 adds fail-closed SDK hook callbacks and a gateway cost report API
Claude Code 2.1.317 adds onFailure: "block" for Agent SDK hook callbacks, a cost report endpoint and IdP group records on the Claude apps gateway, and gives claude -p run inside a session its own session ID.
What does this mean for me?
Engineering leadership
Cost, risk, timeline, team impact Worth knowingAdmins running a Claude apps gateway can now pull past spend per developer, day or IdP group from a cost report API, which makes chargeback easier. Nothing to decide; adopt it when you next review gateway reporting.
Engineer
What to change, what breaks, what to test Worth knowingSet onFailure: "block" on Agent SDK hook callbacks that enforce policy, so a crashing callback fails closed. If scripts on self-hosted runners rely on a nested claude -p sharing the session's transcript, set CLAUDE_CODE_DISABLE_NESTED_SESSION_ID=1.
General consumer
Using the Claude apps, not the API No impactNothing to do: this is a Claude Code release and does not change the Claude apps.
Claude Code 2.1.317 is the only new release since 2.1.316 (recorded October 31). The changelog carries no dates; this release appeared after the November 2 check, and the date is the day it was published, so it is marked approximate.
Agent SDK and permissions. Agent SDK hook callbacks accept onFailure: "block", so a callback that fails blocks the action instead of letting it run. Claude Code now asks before a web or shell tool call sends your account email address to the network, and /schedule warns when a new cloud scheduled task picks up connectors you did not ask for.
Claude apps gateway. A cost report, GET /v1/organizations/analytics/cost, returns past spend over a date range in total, per developer, per day or per IdP group. Gateways with admin: set keep a daily record of each developer’s IdP groups for admin.identity_retention_days, which the report groups by. OpenTelemetry metrics, events and spans gain anthropic.plan, anthropic.seat_type, anthropic.provider and anthropic.custom_base_url.
Behaviour changes. claude -p run inside a cloud or self-hosted runner session no longer shares that session’s ID and transcript; set CLAUDE_CODE_DISABLE_NESTED_SESSION_ID=1 on a self-hosted runner to keep the earlier behaviour. claude -p now exits 1 when a full disk or quota loses its transcript or ~/.claude.json writes. Subagents and teammates on a different model from the main conversation use that model’s saved effort level or its default, not the session’s. The Read tool no longer returns a “file unchanged” stub for an unchanged file; it returns the content. A message sent to a running background agent now moves its running command to the background rather than waiting.
The rest of the release is bug fixes, including OpenTelemetry exports through proxies, compaction in very long conversations, and VS Code forked conversations.
Topics: Coding tools