Skip to content

Common Config Snippet 中的 CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC 会静默禁用 Monitor 工具 #184

@52dyd

Description

@52dyd

问题概述

README 中推荐的 Common Config Snippet 示例:

cc-switch --app claude config common set --snippet '{"env":{"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC":1},"includeCoAuthoredBy":false}'

用户照抄后,Monitor 工具会被静默禁用,且没有任何提示。这对使用第三方 LLM 后端的用户来说是一个意外的功能损失。


逻辑论证与来源

1. cc-switch 将此变量作为唯一推荐示例

来源: README_ZH.md#L339

cc-switch --app claude config common set --snippet '{"env":{"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC":1},"includeCoAuthoredBy":false}'

CHANGELOG #11 也明确此功能的核心用例就是设置该变量。

2. common config 会被 deep merge 到 Claude Code 的 settings.json

来源: common_config.rs#L416-L432

apply_common_config_to_settings() 在每次启动时通过 json_deep_merge 将 snippet 合并进 settings.json 的 env 段,用户无感知。

3. 该变量 = 四个子变量的总开关

来源: Claude Code Env Vars 文档

"Equivalent of setting DISABLE_AUTOUPDATER, DISABLE_FEEDBACK_COMMAND, DISABLE_ERROR_REPORTING, and DISABLE_TELEMETRY"

4. 该变量会禁用 Monitor 工具(关键证据)

来源: Claude Code Tools Reference - Monitor 章节

原文: "It is also not available when DISABLE_TELEMETRY or CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC is set."

注意:不仅是总开关,单独的 DISABLE_TELEMETRY 也会禁用 Monitor。

5. Monitor 是 Claude Code 实时流式输出的唯一途径

来源: 同上文档

"The Monitor tool lets Claude watch something in the background and react when it changes, without pausing the conversation."

功能包括:tail log 监控、CI/PR 状态轮询、文件变更监控、任意长脚本的实时输出跟踪。

6. Monitor 与"非核心流量"的矛盾

来源: 同上 Tools Reference 页面

  • PushNotification 工具明确标注了 "Push delivery runs through Anthropic-hosted infrastructure"
  • Monitor 工具没有任何此类标注,说明它并非依赖 Anthropic 基础设施
  • 但 Monitor 却被 DISABLE_TELEMETRYCLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC 同时禁用
对比维度 PushNotification Monitor
标注 "runs through Anthropic infrastructure"
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC 禁用 未标注 ✗(但实际被禁用)

这意味着:一个本地进程监控工具,因为被归类到"非核心流量"范畴,被一刀切禁用了。


影响

  1. 使用 cc-switch 切换到第三方后端(DeepSeek 等)的用户,照抄 README 示例后,Monitor 工具静默失效
  2. 用户无法使用 tail -f 式日志监控、CI 轮询等实时输出功能
  3. 用户不会收到任何提示告知 Monitor 已被禁用,排查困难

建议

短期

  • README 示例中去掉 CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC,或加注释说明:"注意:此变量会禁用 Monitor 实时输出工具"
  • 引导用户按需单独设置子变量(如只需要关遥测就只设 DISABLE_TELEMETRY

长期(上游)

  • 向 Claude Code 反馈:Monitor 作为本地进程监控工具,不应被 telemetry 开关绑定,建议解耦

环境

  • cc-switch-cli: 当前 main 分支
  • Claude Code: v2.1.98+
  • 相关设置文件: ~/.claude/settings.jsonenv

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions