Claude Code v2.1.281:新增Bedrock网关与MCP elicitation
v2.1.281
推荐理由
本次更新修复了多个会导致核心工作流中断的破坏性 Bug(如会话恢复丢失上下文、Prompt Cache 失效),建议开发者尽快升级以保障自动化流程稳定。
What's changed
变更内容
- Added Claude apps gateway support for newer Claude Desktop keys in desktop policy blocks, including blockReadsOutsideWorkingDirectories and disableBypassPermissionsMode
- Added assume_role on Claude apps gateway Bedrock upstreams: the gateway calls Bedrock as an IAM role it assumes through STS, in another AWS account if needed, optionally one session per developer
- Added guardrail: {id, version} on Claude apps gateway Bedrock upstreams to apply an Amazon Bedrock guardrail to every request sent through them (set it on all Bedrock upstreams or none)
- Added telemetry.resource_attributes to the Claude apps gateway config, to put fixed labels on the telemetry of Claude Desktop and /login sessions
- Added "attribution": false in settings.json to hide all commit and PR attribution; older CLI versions skip a settings file that holds it, so keep the object form in files shared across versions
- Added MCP URL-mode elicitation on 2026-07-28 protocol connections, so servers can ask Claude Code to open a browser-based flow; no waiting dialog is left on screen when the server has no way to confirm completion
- Added MCP server checks to claude plugin validate: it reports .mcp.json entries that would be silently dropped at load, undeclared ${user_config.*} references, and insecure URLs
- Added an auto mode recommendation to /insights that estimates how many permission prompts auto mode could have handled in your recent sessions
- Added a scrollbar to the /skills, /mcp and /plugin Installed lists in fullscreen mode, like the one /workflows now has: it appears while the mouse is over the list and can be clicked or dragged
- Fixed a crash ("unrecoverable interface error") that could end a session while an API request was being retried
- Fixed a turn that could retry indefinitely, ignoring --max-turns, when the model alternated unparseable tool calls and output-limit truncation
- Fixed resumed sessions re-sending earlier turns in a changed form (a parallel tool-call turn, an MCP tool call's input or a tool-search result while its server was still reconnecting, or a tool-search result whose loading turn was interrupted), which could make the API drop the conversation's prior reasoning
- Fixed resuming a very large session sometimes restoring only its last few messages
- Fixed a session resumed after a restart during a pending permission prompt sending a different history than before, which broke the prompt cache from that point
- Fixed resuming a session that ended during a tool call: Claude now sees the call and is told its outcome is unknown, and a manual resume no longer adds a hidden "Continue" message
- Fixed sessions with an earlier advisor result the API could no longer read failing one request every turn and repeatedly losing earlier reasoning; the history is now repaired once
- Fixed the prompt cache being lost when an MCP server disconnects mid-conversation, or is still connecting after a resume, while tool search is off (for example behind a proxy or gateway)
- Fixed responses cut short by a proxy or gateway that closes the stream cleanly being shown as complete with no warning, and tool calls running twice on duplicated stream events
- Fixed responses failing with "Content block not found" when a proxy drops a stream event mid-response; the partial response is now kept, and web search keeps results that already arrived
- Fixed an empty completed response being requested twice when the connection dropped before the stream's final event
- Fixed the stop reason being lost when a proxy sends a trailing usage-only frame
- Fixed CLAUDE_CODE_RETRY_WATCHDOG sessions failing on the first 5xx or dropped connection after a run of 429/529 waits, and sleeping uncapped and silently on a long Retry-After from a 5xx
- Fixed fast mode retrying rate-limited requests back to back when the server sent Retry-After: 0
- Fixed a tool that returned an oversized image leaving sibling tool calls unanswered and still running, or ending the turn with no final message
- Fixed conversations getting permanently stuck on "tool_use.name: String should have at most 200 characters" after the model called a tool by an overlong name
- Fixed tool calls failing with "Failed to get memory usage", or being reported as failed after they ran, when Claude Code cannot read its own memory usage, for example when it has run out of file descriptors
- Fixed --input-format stream-json sessions (Agent SDK, VS Code extension) and scheduled cloud sessions failing every turn with an error when an earlier assistant message had plain-string content
- Fixed non-interactive sessions (-p, Agent SDK) failing on the next turn after the directory they were started in was deleted mid-session
- Fixed headless sessions with host-side (SDK) MCP servers stalling on the first message when the host stops responding mid-handshake; remote sessions now wait a few seconds at most
- Fixed interactive startup waiting on the managed-settings network request (about 80 ms, 17+ seconds when the network is unreachable) when no MCP servers or plugins are configured
- Fixed a delay of up to two minutes before responding when reading or @-mentioning a PDF larger than 3 MB
- Fixed an interrupted Read of specific PDF pages leaving its page render running for up to two minutes
- Fixed permission dialogs and attachment checks reading a path under macOS's /.vol, /.nofollow or /.resolve (which can reach a network mount) before approval
- Fixed a recursive rm whose target is only command-substitution output, such as rm -rf "$(pwd)", running unprompted in auto and --dangerously-skip-permissions mode; it now asks even with a Bash allow rule, unless run with CLAUDE_CODE_DISABLE_SUBSTITUTION_RM_PROMPT=1
- Fixed a permission rule containing a NUL byte being expanded into a wildcard match; such a rule now matches nothing
- Fixed sandbox excludedCommands entries not matching git rev-parse --git-dir, programs named like shell builtins, and commit messages containing [WIP] or # lines
- Fixed sandboxed Bash commands being unable to write to $TMPDIR when CLAUDE_CODE_TMPDIR is set
- Fixed claude --bg starting a background session, and running its project hooks, in a directory that had not passed the workspace trust prompt; it now asks for trust first, or exits when not run interactively
- Fixed --setting-sources (and SDK settingSources) not being forwarded to spawned sessions: teammates, /bg, claude agents sessions and --worktree --tmux now start with the parent's restriction
- Fixed Read, Write, Edit and NotebookEdit: a file path containing a null byte now fails that tool call with a clear error instead of ending the whole turn
- Fixed Write refusing a call that gives the file path or content twice under two parameter names with identical values
- Fixed CLAUDE.md and rules files from an --add-dir directory inside the working directory being sent to the model twice in headless and SDK sessions
- Fixed remote sessions staying on "needs approval" with a stale prompt after a permission prompt and a sandbox network-access prompt overlapped and both were answered
- Fixed cloud sessions not telling Claude about background agents that finished just before a worker restart
- Fixed scheduled routine and notification turns in remote sessions not receiving turn-start notices (newly available tools, MCP changes, date, todos) until after the first tool call
- Fixed scheduled tasks and /loop wakeups being fired again every second when their delivery failed, which could make Claude Code exit at the end of a turn
- Fixed Remote Control reporting "disabled by your organization's policy" when the org policy simply hadn't loaded yet; it now retries the fetch and says it couldn't verify
- Fixed the Artifact tool missing from Remote Control sessions that claude remote-control starts for you to open from Claude Desktop, claude.ai or the mobile app
- 在桌面策略块中,为较新的 Claude Desktop 密钥添加了 Claude apps gateway 支持,包括 blockReadsOutsideWorkingDirectories 和 disableBypassPermissionsMode
- 在 Claude apps gateway Bedrock 上游中添加了 assume_role:网关通过 STS 以 IAM 角色身份调用 Bedrock(如有需要,可假设另一个 AWS 账户中的角色),可选地为每位开发者创建一个会话
- 在 Claude apps gateway Bedrock 上游中添加了 guardrail: {id, version},以便对通过它们发送的每个请求应用 Amazon Bedrock 护栏(在所有 Bedrock 上游上设置或不设置)
- 在 Claude apps gateway 配置中添加了 telemetry.resource_attributes,用于为 Claude Desktop 和 /login 会话的遥测数据添加固定标签
- 在 settings.json 中添加 "attribution": false 以隐藏所有提交和 PR 归属信息;旧版 CLI 会跳过包含该设置的配置文件,因此在跨版本共享的文件中保留对象形式
- 在 2026-07-28 协议连接中添加了 MCP URL 模式 elicitation,使服务器能够要求 Claude Code 打开基于浏览器的流程;当服务器无法确认完成时,屏幕上不会留下等待对话框
- 在 claude plugin validate 中添加了 MCP 服务器检查:它会报告加载时会被静默丢弃的 .mcp.json 条目、未声明的 ${user_config.*} 引用以及不安全的 URL
- 在 /insights 中添加了自动模式推荐,估算自动模式在最近会话中可能处理了多少权限提示
- 在全屏模式下为 /skills、/mcp 和 /plugin 已安装列表添加了滚动条,类似于 /workflows 现在拥有的样式:鼠标悬停在列表上时会出现,并可点击或拖动
- 修复了一个可能导致会话结束的崩溃问题("unrecoverable interface error"),该问题发生在 API 请求重试期间
- 修复了一个可能无限重试的轮次,忽略 --max-turns 参数,当模型交替出现无法解析的工具调用和输出限制截断时
- 修复了恢复的会话以更改的形式重新发送早期轮次的问题(并行工具调用轮次、MCP 工具调用的输入或工具搜索结果,而其服务器仍在重连中,或加载轮次被中断的工具搜索结果),这可能导致 API 丢弃对话之前的推理
- 修复了有时仅恢复非常大的会话的最后几条消息的问题
- 修复了在待处理的权限提示期间重启后恢复的会话发送不同历史记录的问题,这会从那时起破坏提示缓存
- 修复了工具调用期间会话中断后恢复的问题:Claude 现在能看到该调用,并被告知其结果未知,手动恢复不再添加隐藏的“继续”消息
- 修复了早期顾问结果导致 API 在每轮中无法读取失败请求并反复丢失早期推理的会话;历史记录现仅修复一次
- 修复了在对话中途 MCP 服务器断开连接,或在恢复后仍在连接且关闭工具搜索(例如位于代理或网关之后)时提示词缓存丢失的问题
- 修复了由代理或网关干净关闭流导致的响应被截断却被显示为完成且无警告,以及因重复的流事件导致工具调用运行两次的问题
- 修复了当代理在响应中途丢弃流事件时响应因“未找到内容块”而失败的问题;现保留部分响应,且网络搜索保留已到达的结果
- 修复了当连接在流的最后一个事件之前断开时,空完成响应被请求两次的问题
- 修复了当代理发送仅包含使用情况的尾随帧时停止原因丢失的问题
- 修复了 CLAUDE_CODE_RETRY_WATCHDOG 会话在经历一系列 429/529 等待后,首次出现 5xx 错误或连接断开时失败,以及在收到来自 5xx 的长 Retry-After 时无限制且静默休眠的问题
- 修复了快速模式下当服务器发送 Retry-After: 0 时连续重试速率受限请求的问题
- 修复了返回超大图像的工具导致同级工具调用未得到回答且仍在运行,或在结束时没有最终消息的问题
- 修复了模型通过过长名称调用工具后,对话永久卡在“tool_use.name: String should have at most 200 characters”上的问题
- 修复了当 Claude Code 无法读取自身内存使用情况(例如文件描述符耗尽)时,工具调用因“获取内存使用情况失败”而失败,或在运行后被报告为失败的问题
- 修复了 --input-format stream-json 会话(Agent SDK、VS Code 扩展)和计划中的云会话在早期助手消息包含纯字符串内容时,每轮都因错误而失败的问题
- 修复了非交互式会话(-p、Agent SDK)在会话中途启动目录被删除后,下一轮失败的问题
- 修复了具有主机端(SDK)MCP 服务器的无头会话在握手中途主机停止响应时在第一消息处停滞的问题;远程会话现在最多等待几秒钟
- 修复了未配置 MCP 服务器或插件时,交互式启动过程中因等待 managed-settings 网络请求而阻塞的问题(约 80 毫秒,在网络不可达时可能长达 17+ 秒)
- 修复了读取或 @提及大于 3 MB 的 PDF 文件时,响应延迟高达两分钟的问题
- 修复了特定 PDF 页面读取中断后,其页面渲染进程仍持续运行长达两分钟的问题
- 修复了在批准前读取 macOS 的 /.vol、/.nofollow 或 /.resolve 下的路径(可能指向网络挂载点)时,权限对话框和附件检查异常的问题
- 修复了递归 rm 命令(目标仅为命令替换输出,如 rm -rf "$(pwd)")在 auto 和 --dangerously-skip-permissions 模式下未经提示直接执行的问题;现在即使存在 Bash 允许规则也会进行提示,除非设置 CLAUDE_CODE_DISABLE_SUBSTITUTION_RM_PROMPT=1
- 修复了包含 NUL 字节的权限规则被错误扩展为通配符匹配的问题;此类规则现在将不匹配任何内容
- 修复了沙箱 excludedCommands 条目未能正确匹配 git rev-parse --git-dir、类似 shell 内置程序的名称以及包含 [WIP] 或 # 行的提交消息的问题
- 修复了当设置 CLAUDE_CODE_TMPDIR 时,沙箱化的 Bash 命令无法写入 $TMPDIR 的问题
- 修复了 claude --bg 在未通过工作区信任提示的目录中启动后台会话并运行项目钩子的问题;现在会先请求信任,若为非交互式运行则退出
- 修复了 --setting-sources(及 SDK settingSources)未转发至派生会话的问题:队友、/bg、claude agents 会话以及 --worktree --tmux 现在将继承父会话的限制
- 修复了 Read、Write、Edit 和 NotebookEdit:包含空字节(null byte)的文件路径现在会在该工具调用时报出清晰错误,而非导致整个回合结束
- 修复了 Write 拒绝接受在同一参数名下提供两次相同值(即文件路径或内容重复指定)的调用问题
- 修复了在工作目录内的 --add-dir 目录中的 CLAUDE.md 和 rules 文件在无头模式和 SDK 会话中被向模型发送两次的问题
- 修复了远程会话在权限提示与沙箱网络访问提示重叠且两者均被回答后,仍停留在“需要批准”状态并使用过时提示的问题
- 修复了云会话未在工作者重启前通知 Claude 有关刚完成的后台代理的问题
- 修复了远程会话中的计划例行任务和通知回合未收到回合开始通知(新可用工具、MCP 变更、日期、待办事项),直到首次工具调用后才收到的问题
- 修复了计划任务及 /loop 唤醒在投递失败时每秒重新触发的问题,这可能导致 Claude Code 在一轮操作结束时退出
- 修复了远程控制在组织策略尚未加载时报告“被组织的策略禁用”的问题;现在它会重试获取并提示无法验证
- 修复了在通过 claude remote-control 启动的远程控制会话中缺少 Artifact 工具的问题,这些会话旨在供用户在 Claude Desktop、claude.ai 或移动应用中打开
更进一步:量化金融体系
看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力