Claude Code v2.1.295:新增钩子阻塞与OSC状态,修复MCP连接及后台任务多项Bug
v2.1.295
推荐理由
v2.1.295 的 hook 阻塞机制直接改变工作流安全性,且修复了 MCP 重连死循环等高频痛点。建议开发者升级以获取更稳定的自动化体验。
What's changed
变更内容
- Added 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
- Added Program Status Protocol (OSC 7501) support: terminals that implement it can show whether Claude Code is working, waiting on you, or done
- Added quoted text to the /copy picker, so a drafted message copies without its > markers
- Added a warning to claude plugin install, enable, disable and marketplace add when the settings file they write to does not load
- Added a line on stderr, when it is a terminal, that says what a claude -p run is waiting for when it stays open after its last turn
- Added support for timeouts.upstream_ttfb_ms on the Claude apps gateway's Bedrock, Vertex, Foundry and other cloud upstreams: a value you set now limits how long a stream may take to start there, after which it fails over or gets a 502
- Added a "Backgrounding cancelled" message when you stop the turn while ← is waiting for the current tool to finish
- Added an optional models list to every Claude apps gateway upstream: only the listed models are sent there, on failover too, and one * in an entry is a wildcard
- Added support for forceLoginMethod: "gateway" and forceLoginGatewayUrl in your own user settings on machines with no managed settings, so /login opens on that Claude apps gateway
- Added advice to claude plugin validate when a plugin's README has no install line: it prints the line to paste and never changes the exit code, even with --strict
- Added upstream_request_id to the Claude apps gateway's inference audit event: the request ID from Amazon Bedrock, the Anthropic API or another upstream, for support cases
- Added $.ui.notify for mods: raises a native notification through your own notification setting and says which channel sent it
- Added children to a mod's Button: strings and Text, so a row of a list is one pressable with a chip or a dim detail inside
- Added CLAUDE_CODE_RETRY_WATCHDOG_MAX_WAIT_MS to limit how long unattended retry mode (CLAUDE_CODE_RETRY_WATCHDOG) waits out 429 and 529 errors
- Added a request-id header to the Claude apps gateway's successful inference responses, so request_id in Claude Code telemetry matches the gateway's audit log
- Fixed 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
- Fixed claude -p text output dropping earlier responses when background work started another turn; each turn's response now prints when the turn ends
- Fixed remote MCP servers in headless and SDK sessions staying disconnected after an outage longer than 15 seconds, or reconnecting in a tight loop to a server that drops each connection right after it connects; repeated drops now back off, up to 30s
- Fixed remote MCP connections being dropped when a server's error reply happened to contain a network error name
- Fixed MCP servers that repeat a pagination cursor being asked for the same page up to 20 times at every connect
- Fixed CSS, JavaScript and XML files returned by MCP tools being saved as .bin, which the Read tool refuses; font and icon files now get their own extension too
- Fixed Bash tool calls failing when the model passes command_description instead of description
- Fixed Claude in Chrome not applying a site deny rule written with port 80 (host:80) to plain http:// pages on that host
- Fixed /plugin's Errors tab removing a marketplace that failed to load, and uninstalling its plugins, on Enter without asking first
- Fixed claude plugin marketplace add reporting success for a marketplace whose name no plugin can be installed under; such an add is now refused
- Fixed CLAUDE_AUTO_BACKGROUND_TASKS moving a subagent to the background while an edit or shell command waited behind it, which started that call before the subagent finished
- Fixed PushNotification saying a push was not sent in claude remote-control sessions right after a phone message, without the /config toggle, or when started from inside Claude Code
- Fixed files sent from remote sessions being refused as "could not be vouched for" when more than 256 were sent at once
- Fixed a rare failure to load managed settings at startup right after a login refresh
- Fixed /tui exiting without a message, or with a raw system error, when Claude Code could not be started again
- Fixed a link address shown as text being hidden by a colour or conceal style a reply left on, including where it wraps in a table or a question preview
- Fixed Fable models listed in availableModels not appearing in the /model picker for sessions signed in to a Claude apps gateway; such a model now shows its built-in row in place of a modelPicker row added for the same model
- Fixed the Claude apps gateway's admin spend view showing a developer's old groups and group cap after their session stopped carrying groups
- Fixed CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC hiding the Claude apps gateway spend limit in /usage and the status line. The spend limit request goes to the gateway the session is signed in to
- Fixed subagents in their own linked worktree being shown the parent session's git branch, status and recent commits
- Fixed Claude stopping at the end of the current tool when text typed in the prompt cancelled backgrounding with ←; Claude now keeps working in the foreground
- Fixed --tools and --restricted not applying to built-in tools that register after launch, and deprecated tool names reaching tools outside the caller's tool set
- Fixed an interrupt not ending the turn until a timeout while Claude waited for an MCP server's resource list
- Fixed a mod's hook being handed a deeply nested tool input cut short with no error, so a guard could pass content it never saw
- Fixed Esc not stopping a self-paced /loop that was moved to the background with ←; cancelling a pending wakeup now shows a notice
- Fixed commands and hooks in background sessions inheriting FORCE_COLOR=3, which put color escape codes into the output Claude reads
- Fixed claude agents starting a new background service as it exited when both were stopped with a session open (for example at a reboot), which could delay shutdown and restart an interrupted session
- Fixed a custom agent named worker being shown as "Agent" in auto-mode denial notices and in the activity lists of task detail views
- Fixed Bash permission checks for for-loops over glob patterns, improving permission-check accuracy
- Fixed forked skills invoked from Workflow subagents delivering their results to the main conversation instead of the invoking agent
- Fixed in-process agent teammates failing their first SendMessage call until they loaded the tool through tool search
- Fixed Claude being told on resume that an unfinished background workflow may have been stopped by TaskStop, which can never be the cause
- Fixed Claude not being told when you stop a long-running MCP tool call from the tasks panel or a connected client
- Fixed a background session's /loop stopping without notice when its next wakeup came due while the session's process was down; the session now says so and Claude is told
- Fixed raw terminal hyperlink bytes in a reply or a teammate's message being drawn as a clickable link with a hidden address
- Fixed plugin marketplaces whose repository has large git submodules failing to add or refresh: only the submodules that hold plugin files are now fetched
- Fixed the /advisor dialog showing a checkmark on a saved advisor model that is no longer available; it now opens on "No advisor"
- Fixed the notification for an MCP tool call that moved to the background showing a shortened task id
- Fixed vim mode's ~ moving the cursor past the last character of a line, so x after it did nothing, and 3~ running on into the next line
- 为命令和 HTTP 钩子添加了 onFailure: "block":无法启动、超时或以意外代码退出的钩子将阻止操作,而不是放行
- 添加了对程序状态协议 (OSC 7501) 的支持:实现该协议的终端可以显示 Claude Code 正在工作、等待用户操作或已完成
- 在 /copy 选择器中添加了引用文本,以便复制草稿消息时不包含其 > 标记
- 当 claude plugin install、enable、disable 和 marketplace add 写入的设置文件无法加载时,添加了警告信息
- 当 claude -p 运行在最后一轮之后保持打开状态时,如果标准错误输出是终端,则输出一行说明它正在等待的内容
- 为 Claude apps 网关的 Bedrock、Vertex、Foundry 及其他云上游服务添加了 timeouts.upstream_ttfb_ms 支持:设置的值现在限制了流在这些地方开始所需的最长时间,超过后将会故障转移或返回 502
- 当你在 ← 等待当前工具完成时停止回合,会显示一条“Backgrounding cancelled”(后台处理已取消)的消息
- 为每个 Claude apps 网关上游添加了可选的模型列表:仅发送列出的模型,故障转移时也如此,条目中的 * 表示通配符
- 在未配置管理设置的本机上的个人用户设置中,添加了 forceLoginMethod: "gateway" 和 forceLoginGatewayUrl 支持,使 /login 在该 Claude apps 网关上打开
- 当插件的 README 缺少安装行时,claude plugin validate 会提供建议:它会打印出需要粘贴的行,并且即使使用 --strict 也不会更改退出码
- 为 Claude apps 网关的推理审计事件添加了 upstream_request_id:来自 Amazon Bedrock、Anthropic API 或其他上游的请求 ID,用于支持案例
- 为 mods 添加了 $.ui.notify:通过你自己的通知设置触发原生通知,并说明是哪个频道发送的
- 为 mod 的 Button 添加了 children:字符串和 Text,使得列表的一行成为一个可点击项,内部包含芯片或淡化细节
- 添加了 CLAUDE_CODE_RETRY_WATCHDOG_MAX_WAIT_MS 以限制无人值守重试模式 (CLAUDE_CODE_RETRY_WATCHDOG) 等待 429 和 529 错误的最大时长
- 为 Claude apps 网关的成功推理响应添加了 request-id 头,使 Claude Code 遥测数据中的 request_id 与网关的审计日志匹配
- 修复了当网关、Bedrock、Vertex 或 Foundry 拒绝 context-1m beta 时,[1m] 模型导致所有请求失败的问题;Claude Code 现在会重新发送而不包含该参数
- 修复了 claude -p 文本输出在后台工作启动新回合时丢弃早期回复的问题;现在每个回合的回复会在该回合结束时打印
- 修复了无头模式和 SDK 会话中的远程 MCP 服务器在断网超过 15 秒后保持断开,或在连接后立即被服务器断开连接的循环中不断重连的问题;重复断开连接现在会进行退避处理,最长退避时间为 30 秒
- 修复了当服务器的错误回复恰好包含网络错误名称时,远程 MCP 连接被丢弃的问题
- 修复了重复分页游标的 MCP 服务器在每次连接时被请求同一页最多 20 次的问题
- 修复了 MCP 工具返回的 CSS、JavaScript 和 XML 文件被保存为 .bin 格式,导致 Read 工具拒绝读取的问题;字体和图标文件现在也使用各自的扩展名
- 修复了当模型传递 command_description 而非 description 时 Bash 工具调用失败的问题
- 修复了 Chrome 中的 Claude 未将使用端口 80 (host:80) 编写的站点拒绝规则应用于该主机上的纯 http:// 页面的问题
- 修复了 /plugin 的 Errors 标签页在未事先询问的情况下,因按 Enter 而移除加载失败的插件市场并卸载其插件的问题
- 修复了 claude 插件市场添加功能对无法安装任何插件的市场报告成功的问题;此类添加操作现在会被拒绝
- 修复了 CLAUDE_AUTO_BACKGROUND_TASKS 在编辑或 shell 命令等待在其后方时,将子代理移至后台,从而导致在该子代理完成之前就开始调用该命令的问题
- 修复了 claude 远程控制会话在手机消息之后且没有 /config 切换开关,或从 Claude Code 内部启动时,PushNotification 错误提示推送未发送的问题
- 修复了当一次性发送超过 256 个文件时,来自远程会话的文件因“无法获得担保”而被拒绝的问题
- 修复了登录刷新后启动时偶尔无法加载托管设置的问题
- 修复了当无法重新启动 Claude Code 时,/tui 退出时无消息或显示原始系统错误的问题
- 修复了作为文本显示的链接地址被回复遗留的颜色或隐藏样式遮盖的问题,包括在表格或问题预览中换行的情况
- 修复了 availableModels 中列出的 Fable 模型未出现在登录到 Claude apps 网关的会话的 /model 选择器中的问题;此类模型现在会显示其内置行,以替代为该模型添加的 modelPicker 行
- 修复了 Claude apps 网关的管理员支出视图在会话停止携带组信息后,仍显示开发者的旧组和组上限的问题
- 修复了 CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC 隐藏 /usage 和状态栏中 Claude 应用网关支出限额的问题。支出限额请求会发送至会话登录的网关
- 修复了子代理(subagents)在其独立链接工作树(worktree)中显示父会话的 git 分支、状态和最近提交记录的问题
- 修复了当在提示符中输入的文本通过按 ← 取消后台化时,Claude 在当前工具结束时停止响应的问题;现在 Claude 会在前台继续工作
- 修复了 --tools 和 --restricted 未应用于启动后注册的内置工具,以及已弃用的工具名称触及调用方工具集之外工具的问题
- 修复了中断未在超时前结束回合的问题,当时 Claude 正在等待 MCP 服务器的资源列表
- 修复了模块钩子(hook)接收被截断的深度嵌套工具输入且无报错,导致守卫逻辑通过了其从未见过的内容的问题
- 修复了 Esc 无法停止通过按 ← 移至后台的自定速 /loop 的问题;取消待处理的唤醒操作现在会显示通知
- 修复了后台会话中的命令和钩子继承 FORCE_COLOR=3,导致颜色转义代码进入 Claude 读取的输出中的问题
- 修复了 claude agents 在退出时启动新后台服务的问题,当两者均因有打开的会话(例如重启时)而停止时,这可能导致关机延迟并重新启动被中断的会话
- 修复了名为 worker 的自定义智能体在自动模式拒绝通知和活动列表中显示为“Agent”的问题
- 修复了针对通配符模式的 for 循环的 Bash 权限检查,提高了权限检查的准确性
- 修复了从 Workflow 子代理调用的 forked skills 将其结果交付给主对话而非调用代理的问题
- 修复了进程内代理队友在通过工具搜索加载工具之前,首次 SendMessage 调用失败的问题
- 修复了恢复时被告知未完成的工作流可能被 TaskStop 停止的问题,而这永远不可能是原因
- 修复了当从任务面板或连接客户端停止长时间运行的 MCP 工具调用时,未告知 Claude 的问题
- 修复了后台会话的 /loop 在其下次唤醒时间到达但会话进程处于关闭状态时无通知停止的问题;现在会话会说明此情况并告知 Claude
- 修复了回复或队友消息中的原始终端超链接字节被绘制为带有隐藏地址的可点击链接的问题
- 修复了仓库包含大型 git 子模块的插件市场无法添加或刷新的问题:现在仅获取包含插件文件的子模块
- 修复了 /advisor 对话框在保存的顾问模型不再可用时仍显示勾选标记的问题;现在会打开“无顾问”界面
- 修复了 MCP 工具调用通知在移至后台时显示缩短的任务 ID 的问题
- 修复了 vim 模式下 ~ 键将光标移动到行尾字符之后的问题,导致其后的 x 键无效,且连续按 3~ 会跳到下一行
更进一步:量化金融体系
看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力