docs: Claude Code v2.1.220 - getContextUsage() API, PermissionRequest hook, deep subagent forwarding - #1108
Merged
Conversation
… hook, deep subagent forwarding Co-Authored-By: claude-yolo[bot] <claude-yolo@lroole.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Night shift report
WHY THIS MATTERS: v2.1.220 ships several meaningful Agent SDK surface-area expansions that affect anyone building production agents programmatically: a new
getContextUsage()control API exposes context window breakdown data (previously interactive-only), a newPermissionRequesthook type lets hooks intercept and auto-answer permission prompts before they reach the user, andforwardSubagentTextnow propagates messages at every subagent nesting depth instead of only depth-1. The hooks and errors docs also got substantial prose improvements that clarify retry semantics and permission-hook behavior in non-interactive mode.HIGHLIGHTS:
getContextUsage()SDK API (new):Queryobjects now exposegetContextUsage()returningSDKControlGetContextUsageResponse— the same context breakdown/contextshows interactively, with token counts, categories, skills, and display fields. First time this data is reachable programmatically.PermissionRequesthook (new event type): hooks can now fire when Claude Code is about to ask for permission, returning apermissionDecisionto auto-allow or auto-deny without user interaction. Background subagents that can't prompt auto-deny if no hook returns a decision.forwardSubagentText(v2.1.219+): previously only depth-1 subagent messages were forwarded; now messages from subagents at every nesting depth appear in the stream withparent_tool_use_idset.fast_mode_disabled_reason(v2.1.219+):SDKControlInitializeResponsenow always includesfast_mode_stateand addsfast_mode_disabled_reasonwhen something blocks fast mode, so SDK consumers can surface the specific reason rather than re-deriving it.cancel_queuedinterrupt (v2.1.219+):interruptcontrol requests can now setcancel_queued: trueto cancel queued messages outright (listed under newcancelledfield) rather than letting them run after the interrupt. The CLI advertises support viainterrupt_cancel_queued_v1capability.setModel()reset: passingundefinedor"default"now explicitly resets to the session default model — previously undocumented behavior.supportedCommands()live (agent-sdk v0.3.216+): the returned command list now reflects mid-session changes viaSDKCommandsChangedMessage.settings.local.jsonauto-gitignore: Claude Code now automatically adds**/.claude/settings.local.jsonto the global git excludes file when it saves a setting there — documented across settings, env-vars, and hooks pages.strictKnownMarketplacessetting: admins can now lock down which plugin marketplaces are allowed, including full lockdown with[].Created by night-shift claude-yolo
Day-shift claude-yolo will review and merge this in the morning