From deb0e874ffeba534ae715c1bfaf7e7c2b2543152 Mon Sep 17 00:00:00 2001 From: Jason Date: Thu, 10 Sep 2026 11:09:06 +0800 Subject: [PATCH] feat(claude): add "Disable Artifact Tool" quick toggle to provider editor Some third-party Anthropic-compatible gateways (e.g. DeepSeek) validate tool JSON Schemas with a strict regex checker and reject the Unicode property escapes (\p{Cc}...) that Claude Code's Artifact tool emits when its str_replace db capability is rolled out, failing every request with 400 "Invalid schema for function 'Artifact'". The failure is independent of the model selected. Add a sixth checkbox next to the existing Claude quick toggles that sets env.CLAUDE_CODE_DISABLE_ARTIFACT="1" on the provider, which keeps the Artifact tool out of the tools array entirely. Unchecking removes the key like the other toggles do. Labels added for zh/en/ja/zh-TW and the user manual toggle table updated in zh/en/ja. --- docs/user-manual/en/2-providers/2.1-add.md | 1 + docs/user-manual/ja/2-providers/2.1-add.md | 1 + docs/user-manual/zh/2-providers/2.1-add.md | 1 + .../providers/forms/CommonConfigEditor.tsx | 27 +++++++++++++++++++ src/i18n/locales/en.json | 3 ++- src/i18n/locales/ja.json | 3 ++- src/i18n/locales/zh-TW.json | 3 ++- src/i18n/locales/zh.json | 3 ++- 8 files changed, 38 insertions(+), 4 deletions(-) diff --git a/docs/user-manual/en/2-providers/2.1-add.md b/docs/user-manual/en/2-providers/2.1-add.md index 7d5eb916a..c704d0e44 100644 --- a/docs/user-manual/en/2-providers/2.1-add.md +++ b/docs/user-manual/en/2-providers/2.1-add.md @@ -548,6 +548,7 @@ When editing Claude providers, a set of **quick toggles** is available above the | **Enable Tool Search** | Enables tool search functionality | Sets `env.ENABLE_TOOL_SEARCH = "true"` | | **Max Effort** | Sets effort level to max | Sets `env.CLAUDE_CODE_EFFORT_LEVEL = "max"` | | **Disable Auto Upgrade** | Prevents Claude Code auto-updates | Sets `env.DISABLE_AUTOUPDATER = "1"` | +| **Disable Artifact Tool** | Keeps the Artifact tool out of the request's tools array (some third-party gateways reject its schema and return 400 on every request) | Sets `env.CLAUDE_CODE_DISABLE_ARTIFACT = "1"` | When a toggle is unchecked, its corresponding config entry is removed entirely. Changes are reflected in the JSON editor in real-time. diff --git a/docs/user-manual/ja/2-providers/2.1-add.md b/docs/user-manual/ja/2-providers/2.1-add.md index e39fbb6af..8539cbf8c 100644 --- a/docs/user-manual/ja/2-providers/2.1-add.md +++ b/docs/user-manual/ja/2-providers/2.1-add.md @@ -548,6 +548,7 @@ Claude プロバイダーの編集時、JSON エディタの上部に **クイ | **ツール検索を有効化** | ツール検索機能を有効化 | `env.ENABLE_TOOL_SEARCH = "true"` を設定 | | **最大強度思考** | エフォートレベルを max に設定 | `env.CLAUDE_CODE_EFFORT_LEVEL = "max"` を設定 | | **自動アップグレードを無効化** | Claude Code の自動更新を防止 | `env.DISABLE_AUTOUPDATER = "1"` を設定 | +| **Artifact ツールを無効化** | Artifact ツールをリクエストの tools 配列に含めない(一部のサードパーティゲートウェイはそのスキーマ検証に失敗し、すべてのリクエストで 400 を返す) | `env.CLAUDE_CODE_DISABLE_ARTIFACT = "1"` を設定 | トグルのチェックを外すと、対応する設定エントリが完全に削除されます。変更は JSON エディタにリアルタイムで反映されます。 diff --git a/docs/user-manual/zh/2-providers/2.1-add.md b/docs/user-manual/zh/2-providers/2.1-add.md index 0cacd0410..fb16e9e49 100644 --- a/docs/user-manual/zh/2-providers/2.1-add.md +++ b/docs/user-manual/zh/2-providers/2.1-add.md @@ -548,6 +548,7 @@ v3.13.0 起新增的高级选项。默认情况下,CC Switch 会把配置的 ` | **启用工具搜索** | 启用工具搜索功能 | 设置 `env.ENABLE_TOOL_SEARCH = "true"` | | **最大强度思考** | 将 effort 级别设为 max | 设置 `env.CLAUDE_CODE_EFFORT_LEVEL = "max"` | | **禁用自动更新** | 阻止 Claude Code 自动更新 | 设置 `env.DISABLE_AUTOUPDATER = "1"` | +| **禁用 Artifact 工具** | 不把 Artifact 工具放进请求的 tools 数组(部分第三方网关会因其 schema 校验失败而对每个请求返回 400) | 设置 `env.CLAUDE_CODE_DISABLE_ARTIFACT = "1"` | 取消勾选开关时,对应的配置项会被完全移除。更改会实时反映在 JSON 编辑器中。 diff --git a/src/components/providers/forms/CommonConfigEditor.tsx b/src/components/providers/forms/CommonConfigEditor.tsx index 814309d59..82eef4078 100644 --- a/src/components/providers/forms/CommonConfigEditor.tsx +++ b/src/components/providers/forms/CommonConfigEditor.tsx @@ -85,6 +85,9 @@ export function CommonConfigEditor({ disableAutoUpgrade: config?.env?.DISABLE_AUTOUPDATER === "1" || config?.env?.DISABLE_AUTOUPDATER === 1, + disableArtifact: + config?.env?.CLAUDE_CODE_DISABLE_ARTIFACT === "1" || + config?.env?.CLAUDE_CODE_DISABLE_ARTIFACT === 1, }; } catch { return { @@ -93,6 +96,7 @@ export function CommonConfigEditor({ enableToolSearch: false, effortMax: false, disableAutoUpgrade: false, + disableArtifact: false, }; } }, [localValue]); @@ -146,6 +150,18 @@ export function CommonConfigEditor({ if (Object.keys(config.env).length === 0) delete config.env; } break; + case "disableArtifact": + // 第三方网关(如 DeepSeek)用严格 JSON Schema 校验工具定义, + // Artifact 工具灰度中的 \p{..} 正则会让每个请求 400; + // 该变量让 Claude Code 压根不把 Artifact 放进 tools 数组。 + if (!config.env) config.env = {}; + if (checked) { + config.env.CLAUDE_CODE_DISABLE_ARTIFACT = "1"; + } else { + delete config.env.CLAUDE_CODE_DISABLE_ARTIFACT; + if (Object.keys(config.env).length === 0) delete config.env; + } + break; } handleLocalChange(JSON.stringify(config, null, 2)); @@ -246,6 +262,17 @@ export function CommonConfigEditor({ /> {t("claudeConfig.disableAutoUpgrade")} +