跳到主内容
@wquguru
精选80Claude Code(GitHub Releases)AI 编程与模型

Claude Code v2.1.274:修复MCP连接超时、会话状态丢失及多项Bug

v2.1.274

原文
发到 X
推荐理由

本次更新包含多项关键 MCP 连接逻辑修复(如 4xx 错误处理、超时控制),直接影响依赖 MCP 生态的开发者工作流。建议使用 Claude Code 进行自动化或复杂项目开发的读者尽快升级,以避免会话中断或工具调用失败。

What's changed

变更内容

  • Added a visible warning when memory usage is critical, with steps to free memory or restart safely
  • Added CLAUDE_CODE_MCP_STARTUP_WAIT_MS to bound how long the first non-interactive turn waits for connecting MCP servers (0 = don't wait)
  • Added effort attribute to the claude_code.llm_request OpenTelemetry trace span, matching the api_request event
  • Added claude_code.managed_settings_resolved OTel event: managed-settings sources and policy helper state; redacted settings and digests with OTEL_LOG_MANAGED_SETTINGS=1
  • Added store.connect_timeout_seconds to the Claude apps gateway config to lengthen the Postgres connect timeout (default 5 seconds), and improved the boot error when the database is unreachable to point to store.postgres_url and the configured timeout
  • Added enduser.sub, the IdP subject, to the telemetry Claude Desktop and Cowork send through a Claude apps gateway
  • Added a Claude apps gateway warning when a replica has more requests open than the 256 it sends upstream at once, and a startup log line showing that limit
  • Added click-to-expand for collapsed teammate and agent messages in fullscreen mode
  • Fixed sessions getting stuck endlessly retrying "unexpected tool_use_id" 400 errors: corrupted transcripts now self-heal where possible, and otherwise a clear error (with a /rewind hint) ends the loop
  • Fixed MCP servers configured as http that only speak legacy HTTP+SSE failing to connect when they answer the first request with 422 or another 4xx error
  • Fixed Streamable HTTP MCP tool calls timing out after about 5 minutes even when a longer per-server timeout was set
  • Fixed MCP prompts and resources not refreshing when a server sends list-changed notifications without declaring listChanged
  • Fixed MCP tool calls refused with 403 insufficient_scope being reported as an expired sign-in: the error now names the missing permissions and points to /mcp re-authentication
  • Fixed hook-driven sessions (such as an active /goal) ending with "Prompt is too long" instead of compacting when the context overflowed again after a reactive compaction
  • Fixed an active /goal being lost when resuming (--continue / --resume) a session that had compacted
  • Fixed claude agents losing --model, --effort, --permission-mode, --allow-dangerously-skip-permissions and --agent after an auto-update relaunch
  • Fixed a per-turn slowdown when a language server publishes project-wide diagnostics for thousands of files
  • Fixed subagents with model: "opus" on Bedrock, Vertex or Foundry leaving the session's model when its id has no recognizable model family (unless ANTHROPIC_DEFAULT_OPUS_MODEL is set)
  • Fixed self-hosted runner sessions failing every turn with a 401 after a few failed token refreshes, until the next scheduled refresh; the runner now keeps retrying, and fetches a new token after a 401
  • Fixed clickable links to local file paths doing nothing in VS Code and other terminals that require a file:// URI
  • Fixed the transcript renumbering ordered lists in your own messages (typing "3. 2. 1." displayed "3. 4. 5."); numbers and "N)" markers now show as typed
  • Fixed AskUserQuestion preview notes being attached to a previously chosen option instead of the highlighted one
  • Fixed AskUserQuestion preview mode dropping the highlighted option when submitting a note with Enter
  • Fixed a resumed background agent keeping half of an interrupted tool batch when one of its calls was approved with a message
  • Fixed a local claude -p --resume started with CLAUDE_CODE_RESUME_INTERRUPTED_TURN not reporting background tasks the previous process left unfinished
  • Fixed the first turn of a cloud session sometimes starting without the tools of an SDK-hosted MCP server that was still connecting
  • Fixed background agent notifications claiming the agent had no live background work when it was still waiting on its own background task and would resume
  • Fixed error hints in Claude Desktop sessions to suggest slash commands like /usage-credits instead of CLI flags that cannot be used there
  • Fixed /schedule saving a routine's prompt without its message role when Claude writes the routine in the shape that listing routines returns
  • Fixed /status not showing the apiKeyHelper failure that its own error banner told you to check
  • Fixed /fast on in non-interactive sessions reporting on and then turning off under an organization's managed fast mode policy; it now says the organization has disabled it
  • Fixed the Artifact tool asking you to approve an update to an artifact that it then refused because the session had not read the latest version
  • Fixed Cowork and claude.ai cloud sessions with network access on treating reads of a teammate's artifact as if network access were off
  • Fixed a plugin or marketplace directory with no git repository of its own taking its version from an enclosing git repository, such as a git-managed ~/.claude
  • Fixed --strict-mcp-config with an empty --mcp-config holding the first non-interactive turn for up to MCP_TIMEOUT on incidental MCP servers
  • Fixed Stop prompt hooks re-sending their whole prompt on every block in a conversation; repeat blocks now name the condition with a 500-character label
  • Fixed extra empty editor windows opening at startup on Linux under Wayland when running inside the Cursor or VS Code terminal
  • Fixed an unhandled promise rejection in the Claude apps gateway when Postgres drops a connection during a spend check
  • Fixed Claude apps gateway cutting every open stream on SIGTERM: it now lets in-flight requests finish for up to 25 seconds before exiting (CLAUDE_GATEWAY_DRAIN_TIMEOUT_MS)
  • Fixed installed_plugins.json being rewritten on nearly every start-up when plugin policy comes from remote managed settings, which made Claude Desktop reload every open session's plugins
  • Fixed headless and SDK sessions making a separate model call for every background task that finished; completions already queued are now answered by one call
  • Fixed the Bash tool re-sourcing the shell profile (a multi-second stall on the next command) after every plugin reload; it now does so only when the plugins' bin/ directories changed
  • Fixed plugins with a top-level $schema in hooks/hooks.json showing an "unknown key" notice
  • Fixed MCP connection errors and the MCP login tool's description showing secrets resolved from ${VAR} placeholders in MCP configs
  • Fixed Bash permission checks for commands that loop over or assign certain special shell variables; these commands now ask for permission
  • Fixed worktree-isolated sessions accepting Bash commands with certain nested shell expansions; these are now refused
  • Fixed the Edit permission prompt preview sometimes showing a different location than the approved edit in files with multi-byte characters
  • Fixed background commands being stopped after 30 idle minutes on machines under mild memory pressure; they're now stopped only when memory is critically low, and the debug log says why
  • Fixed a message a subagent sends to the main session disappearing from the Claude Desktop transcript after a relaunch
  • Fixed a plugin loaded from a .zip being served from a stale extraction after several overlapping reloads
  • Fixed a sub-agent's progress summary being replaced by a runaway multi-paragraph reply
  • Improved startup in --input-format stream-json sessions: the first turn no longer waits up to 2s for still-connecting MCP servers whose tools tool search defers; they arrive on a later turn
  • Improved Monitor tool notifications: a script's final output and its exit now arrive as one notification instead of two, saving a model turn
  • Improved Artifact tool errors: when you are not signed in to claude.ai the terminal now says so on the first attempt, and Claude is told to stop retrying a rejected call sooner
  • Improved artifact publishing: a publish built on an older version is stopped before it is sent, with the newer page to merge
  • 当内存使用量处于危急状态时,添加可见警告,并提供释放内存或安全重启的步骤
  • 新增 CLAUDE_CODE_MCP_STARTUP_WAIT_MS 参数,用于限制首次非交互轮次等待连接 MCP 服务器的时长(0 = 不等待)
  • 在 claude_code.llm_request OpenTelemetry 追踪跨度中新增 effort 属性,与 api_request 事件保持一致
  • 新增 claude_code.managed_settings_resolved OTel 事件:包含托管设置来源和策略助手状态;通过 OTEL_LOG_MANAGED_SETTINGS=1 对设置和摘要进行脱敏处理
  • 在 Claude 应用网关配置中新增 store.connect_timeout_seconds,以延长 Postgres 连接超时时间(默认 5 秒),并在数据库不可达时改进启动错误提示,指向 store.postgres_url 及配置的超时时间
  • 在 Claude Desktop 和 Cowork 通过 Claude 应用网关发送的遥测数据中新增 enduser.sub(身份提供商主体标识)
  • 当副本打开的请求数超过其一次性向上游发送的 256 个请求限制时,Claude 应用网关会发出警告,并在启动日志中显示该限制值
  • 在全屏模式下支持点击展开折叠的队友消息和代理消息
  • 修复会话因不断重试“unexpected tool_use_id” 400 错误而卡死的问题:损坏的转录记录现在可在可能时自我修复,否则将通过清晰错误(附带 /rewind 提示)终止循环
  • 修复配置为 http 且仅支持传统 HTTP+SSE 的 MCP 服务器在首次请求返回 422 或其他 4xx 错误时无法连接的问题
  • 修复 Streamable HTTP MCP 工具调用即使设置了更长的单服务器超时时间,仍在约 5 分钟后超时的问題
  • 修复当服务器发送 list-changed 通知但未声明 listChanged 时,MCP 提示和资源未刷新的问题
  • 修复因 403 insufficient_scope 被拒绝的 MCP 工具调用被误报为登录过期的问題:现在错误信息会指明缺失的权限,并引导至 /mcp 重新认证
  • 修复由钩子驱动的会话(如活跃的 /goal)在响应式压缩后上下文再次溢出时,以“Prompt is too long”结束而非进行压缩的问题
  • 修复在恢复已压缩的会话(--continue / --resume)时丢失活跃 /goal 的问题
  • 修复 claude agents 在自动更新重启后丢失 --model、--effort、--permission-mode、--allow-dangerously-skip-permissions 和 --agent 参数的问题
  • 修复当语言服务器发布涵盖数千个文件的整个项目诊断信息时,每轮处理速度变慢的问题
  • 修复了在 Bedrock、Vertex 或 Foundry 上使用模型 "opus" 的固定子代理,当其 ID 没有可识别的模型系列时(除非设置了 ANTHROPIC_DEFAULT_OPUS_MODEL),会离开会话的模型
  • 修复了自托管运行程序会话在几次令牌刷新失败后,直到下次计划刷新前,每次轮询都因 401 错误而失败的问题;现在运行程序会持续重试,并在遇到 401 后获取新令牌
  • 修复了在 VS Code 和其他要求使用 file:// URI 的终端中,指向本地文件路径的可点击链接无效的问题
  • 修复了转录本对您消息中的有序列表进行重新编号的问题(输入 "3. 2. 1." 会显示为 "3. 4. 5.");数字和 "N)" 标记现在按输入显示
  • 修复了 AskUserQuestion 预览笔记被附加到之前选择的选项上,而不是高亮选项上的问题
  • 修复了 AskUserQuestion 预览模式在使用 Enter 提交笔记时丢失高亮选项的问题
  • 修复了恢复后的后台代理在其中一个调用通过消息批准时,保留中断工具批次的一半内容的问题
  • 修复了使用 CLAUDE_CODE_RESUME_INTERRUPTED_TURN 启动的本地 claude -p --resume 未报告上一个进程留下的未完成后台任务的问题
  • 修复了云会话的第一轮有时在没有 SDK 托管的 MCP 服务器(仍在连接中)的工具的情况下开始的问题
  • 修复了后台代理通知声称代理没有实时后台工作,尽管它仍在等待自己的后台任务并即将恢复的问题
  • 修复了 Claude Desktop 会话中的错误提示建议像 /usage-credits 这样的斜杠命令,而不是无法在那里使用的 CLI 标志的问题
  • 修复了 /schedule 在 Claude 以列出例程返回的形状编写例程时,保存例程提示词但未包含其消息角色的问题
  • 修复了 /status 未显示其自身错误横幅告知您检查的 apiKeyHelper 失败的问题
  • 修复了非交互式会话中 /fast on 报告开启然后关闭,受组织管理的快速模式策略影响;现在它会说明组织已禁用该功能
  • 修复了 Artifact 工具要求您批准对工件的更新,但随后因会话未读取最新版本而拒绝该更新的问题
  • 修复了具有网络访问权限的 Cowork 和 claude.ai 云会话将队友工件的读取视为网络访问关闭的问题
  • 修复了没有自己 git 仓库的插件或市场目录从其包含的 git 仓库(例如由 git 管理的 ~/.claude)获取版本的问题
  • 修复了 --strict-mcp-config 与包含首个非交互回合的空的 --mcp-config 在偶发 MCP 服务器上最多等待 MCP_TIMEOUT 的问题
  • 修复了停止提示钩子(Stop prompt hooks)在对话的每个块中重新发送整个提示的问题;重复块现在使用 500 字符的标签命名条件
  • 修复了在 Linux Wayland 下于 Cursor 或 VS Code 终端内运行时,启动时打开额外空编辑器窗口的问题
  • 修复了 Claude 应用网关在支出检查期间 Postgres 断开连接时未处理的 Promise 拒绝问题
  • 修复了 Claude 应用网关在收到 SIGTERM 信号时切断所有打开流的问题:现在它在退出前允许进行中的请求完成,最长等待 25 秒(CLAUDE_GATEWAY_DRAIN_TIMEOUT_MS)
  • 修复了当插件策略来自远程托管设置时,installed_plugins.json 几乎每次启动都被重写的问题,这导致 Claude Desktop 重新加载每个打开会话的插件
  • 修复了无头模式和 SDK 会话为每个完成的后台任务发起单独的模型调用的问题;现已将已排队的补全由一次调用回答
  • 修复了 Bash 工具在每次插件重新加载后重新加载 shell 配置文件(导致下一个命令出现数秒停滞)的问题;现在仅在插件的 bin/ 目录发生变化时才执行此操作
  • 修复了 hooks/hooks.json 中包含顶层 $schema 的插件显示“未知键”通知的问题
  • 修复了 MCP 连接错误以及 MCP 登录工具的描述中显示从 MCP 配置里 ${VAR} 占位符解析出的密钥的问题
  • 修复了对循环遍历或赋值某些特殊 shell 变量的命令的 Bash 权限检查问题;这些命令现在会请求权限
  • 修复了工作树隔离会话接受带有某些嵌套 shell 展开的 Bash 命令的问题;这些命令现在会被拒绝
  • 修复了编辑权限提示预览有时在多字节字符文件中显示的位置与批准的编辑位置不同的问题
  • 修复了在轻度内存压力下机器上后台命令在空闲 30 分钟后被停止的问题;现在仅在内存严重不足时才停止它们,并且调试日志会说明原因
  • 修复了子代理发送给主会话的消息在 Claude Desktop 重启后从转录记录中消失的问题
  • 修复了从 .zip 文件加载的插件在多次重叠重新加载后仍从过期的解压内容中提供服务的问題
  • 修复了子代理的进度摘要被失控的多段落回复替换的问题
  • 优化了 --input-format stream-json 会话的启动速度:首轮不再等待连接中的 MCP 服务器(其工具搜索功能会延迟)长达 2 秒;这些服务器会在后续轮次中到达
  • 改进了 Monitor 工具的通知机制:脚本的最终输出和退出状态现在合并为一条通知,而非两条,从而节省一轮模型交互
  • 改进了 Artifact 工具的错误处理:当未登录 claude.ai 时,终端会在首次尝试时明确提示,并告知 Claude 尽早停止重试被拒绝的请求
  • 改进了 artifact 发布流程:在发送前会中止基于旧版本构建的发布任务,以便将新版本合并到页面中

更进一步:量化金融体系

看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力

进入量化体系 →

相似阅读

关联信息,但可能不是同一事件