mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-10-25 17:22:27 +08:00
fix(proxy): allow unforced Claude WebSearch through Codex OAuth (#7936)
This commit is contained in:
1 parent
77c6dc793d
commit
75e93281a8
4 files changed
+107
-20
No files matched your search
@@ -93,7 +93,7 @@ Inside Claude Code you can verify step by step:
|
||||
- **Tools and multimodal are fully converted**: multi-turn tool calls, image inputs, and PDF inputs are all fully converted.
|
||||
- **Context is managed against a 200K window**: Claude Code auto-compacts routed providers against a default 200K window. When the upstream's real window is larger (e.g. gpt-5.6 on ChatGPT's Codex service is 372K), anything beyond 200K currently goes unused — compaction triggers early, which is conservative but safe. The only switch to push past 200K today is the `1M` checkbox in the model mapping (a strict 1M declaration), for use only with Method 1 and only when the upstream truly serves the model at 1M or more; Method 2's upstream ceiling is 372K, short of 1M, so checking it would instead make long conversations error out at the upstream's real ceiling — keep it at the default.
|
||||
- **Output ceiling**: for Method 2, the output ceiling is controlled by the ChatGPT server (the `max_tokens` in Claude Code's request is not sent downstream); for Method 1, Claude Code's `max_tokens` is passed through as-is — no configuration needed.
|
||||
- **Built-in web search depends on upstream support**: the router translates Claude Code's hosted WebSearch tool into the Responses API hosted `web_search` tool. It works with Codex OAuth and compatible Responses gateways that implement that tool. `allowed_domains` is preserved. On API-key Responses routes, `max_uses` maps to the upstream `max_tool_calls` hard limit. The Codex OAuth request contract rejects that field, so forced hosted-search requests are capped by the bridge instead: it adds the limit to the model instructions, stops the upstream stream when an extra call starts, and returns `max_uses_exceeded`; non-forced Codex requests with `max_uses` fail closed because their per-tool budget cannot be represented safely. Because Responses has no equivalent deny-list, a request with a non-empty `blocked_domains` also fails explicitly. Locally executed WebFetch is unaffected.
|
||||
- **Built-in web search depends on upstream support**: the router translates Claude Code's hosted WebSearch tool into the Responses API hosted `web_search` tool. It works with Codex OAuth and compatible Responses gateways that implement that tool. `allowed_domains` is preserved. On API-key Responses routes, `max_uses` maps to the upstream `max_tool_calls` hard limit. The Codex OAuth request contract rejects that field, so the bridge uses a local response-side limit instead: it adds the limit to the model instructions and, when it observes an extra search call, stops the upstream stream and returns `max_uses_exceeded`, whether or not the request forces the hosted tool. This cuts off the entire response, including later text and function calls; if another content block is incomplete, the stream fails with `stream_truncated` rather than returning a partial tool call. This is not a server-enforced quota: excess searches may already have executed upstream before the proxy sees their events. Because Responses has no equivalent deny-list, a request with a non-empty `blocked_domains` also fails explicitly. Locally executed WebFetch is unaffected.
|
||||
- **Dashboard dollar amounts are for reference**: token counts are accurate, but the dollar figures are estimates converted at public API prices — Method 2's subscription traffic is estimated at GPT-5.6's public price, and Method 1's third-party gateways bill at their own rates, so both may differ from what you're actually charged and serve only for comparison. For Method 2, treat the window utilization on the provider card as authoritative for quota consumption.
|
||||
|
||||
## FAQ
|
||||
|
||||
@@ -93,7 +93,7 @@ Claude Code に入ったら、段階的に確認できます:
|
||||
- **ツールとマルチモーダルを完全変換**: 複数ターンのツール呼び出し、画像、PDF 入力はすべて完全に変換されます。
|
||||
- **コンテキストは 200K ウィンドウで管理**: Claude Code はルーティングプロバイダーに対して、デフォルトの 200K ウィンドウで自動圧縮を行います。上流の実際のウィンドウがより大きい場合(たとえば ChatGPT Codex サービスの gpt-5.6 は 372K)でも、200K を超える部分は現状では使われません——圧縮が早めにトリガーされ、保守的ですが安全です。200K を突破したい場合、現在唯一のスイッチはモデルマッピングの `1M` チェックボックス(厳密に 1M を宣言)で、方式 1 に限り、かつ上流が実際に 1M 以上でそのモデルを提供している場合にのみ使用します。方式 2 の上流上限は 372K で 1M には届かないため、チェックするとかえって長い対話が上流の実際の上限でエラーになります。デフォルトのままにしてください。
|
||||
- **出力上限**: 方式 2 の出力上限は ChatGPT サーバー側が制御します(Claude Code のリクエスト内の `max_tokens` は下流に送られません)。方式 1 は Claude Code の `max_tokens` をそのまま透過するため、設定は不要です。
|
||||
- **組み込み Web 検索は上流の対応状況に依存**: ルーターは Claude Code のホスト型 WebSearch ツールを Responses API のホスト型 `web_search` ツールへ変換します。このツールを実装する Codex OAuth および互換 Responses ゲートウェイで利用できます。`allowed_domains` は維持されます。API キーを使う Responses ルートでは、`max_uses` を上流の `max_tool_calls` ハード上限へ変換します。Codex OAuth のリクエスト仕様はこのフィールドを拒否するため、ホスト型検索を強制するリクエストはブリッジ側で制限します。上限をモデル指示へ追加し、超過呼び出しが始まった時点で上流ストリームを停止して `max_uses_exceeded` を返します。ツールごとの予算を安全に表現できない非強制 Codex リクエストは明示的に失敗します。Responses には同等の拒否リストもないため、空でない `blocked_domains` を含むリクエストも明示的に失敗します。ローカルで実行される WebFetch は影響を受けません。
|
||||
- **組み込み Web 検索は上流の対応状況に依存**: ルーターは Claude Code のホスト型 WebSearch ツールを Responses API のホスト型 `web_search` ツールへ変換します。このツールを実装する Codex OAuth および互換 Responses ゲートウェイで利用できます。`allowed_domains` は維持されます。API キーを使う Responses ルートでは、`max_uses` を上流の `max_tool_calls` ハード上限へ変換します。Codex OAuth のリクエスト仕様はこのフィールドを拒否するため、ブリッジはレスポンス側で制限します。上限をモデル指示へ追加し、超過検索を観測した時点で上流ストリームを停止して `max_uses_exceeded` を返します。ツールを強制するかどうかに関係なく適用されます。後続のテキストや関数呼び出しを含むレスポンス全体が打ち切られ、別のコンテンツブロックが未完了なら、不完全なツール呼び出しを返さず `stream_truncated` エラーにします。これはサーバー側のハード上限ではありません。プロキシがイベントを受信する前に、超過検索が上流で実行済みの場合があります。Responses には同等の拒否リストもないため、空でない `blocked_domains` を含むリクエストも明示的に失敗します。ローカルで実行される WebFetch は影響を受けません。
|
||||
- **使用量ダッシュボードの金額は参考値**: token カウントは正確ですが、ドル金額は公開 API 価格に基づく概算です——方式 2 のサブスクリプショントラフィックは GPT-5.6 の公開価格で換算され、方式 1 のサードパーティゲートウェイはそれぞれのレートで課金されます。どちらも実際の請求額と一致しない可能性があり、比較用途に留めてください。方式 2 の枠の消費は、プロバイダーカード上のウィンドウ利用率を基準にしてください。
|
||||
|
||||
## よくある質問
|
||||
|
||||
@@ -93,7 +93,7 @@ CC Switch 的做法是让 Claude Code 始终连本机路由,仍以 Anthropic M
|
||||
- **工具与多模态完整转换**:多轮工具调用、图片与 PDF 输入都被完整转换。
|
||||
- **上下文按 200K 窗口管理**:Claude Code 对路由供应商按默认 200K 窗口做自动压缩。上游实际窗口更大时(如 ChatGPT Codex 服务的 gpt-5.6 为 372K),超出 200K 的部分当前不会被用到——压缩会提前触发,保守但安全。想突破 200K,目前唯一的开关是模型映射里的 `1M` 复选框(严格声明 1M),仅限方式一且上游真按 1M 及以上服务该模型时使用;方式二的上游上限是 372K、够不到 1M,勾选反而会让长对话在上游真实上限处报错,请维持默认。
|
||||
- **输出上限**:方式二的输出上限由 ChatGPT 服务端控制(Claude Code 请求里的 `max_tokens` 不会下发);方式一则原样透传 Claude Code 的 `max_tokens`,无需配置。
|
||||
- **内置联网搜索取决于上游支持**:路由会把 Claude Code 的托管 WebSearch 工具转换为 Responses API 的托管 `web_search` 工具,可用于 Codex OAuth 和实现该工具的兼容 Responses 网关。`allowed_domains` 会保留;在 API Key Responses 路由中,`max_uses` 会映射为上游的 `max_tool_calls` 硬限制。Codex OAuth 请求协议会拒绝该字段,因此桥接层会对强制使用托管搜索的请求本地限流:把上限写入模型指令,在额外调用开始时立即终止上游流,并返回 `max_uses_exceeded`;无法安全表示逐工具预算的非强制 Codex 请求则明确失败。由于 Responses 没有等价的拒绝列表,带有非空 `blocked_domains` 的请求也会明确失败。本地执行的 WebFetch 不受影响。
|
||||
- **内置联网搜索取决于上游支持**:路由会把 Claude Code 的托管 WebSearch 工具转换为 Responses API 的托管 `web_search` 工具,可用于 Codex OAuth 和实现该工具的兼容 Responses 网关。`allowed_domains` 会保留;在 API Key Responses 路由中,`max_uses` 会映射为上游的 `max_tool_calls` 硬限制。Codex OAuth 请求协议会拒绝该字段,因此桥接层采用本地响应侧限制:把上限写入模型指令,在观察到额外搜索调用时终止上游流,并返回 `max_uses_exceeded`,无论请求是否强制使用托管搜索都同样生效。超限会截断整轮响应,包括后续文本和函数调用;如果还有未完成的内容块,则返回 `stream_truncated` 错误,避免交付残缺的工具调用。这并非服务端硬配额:代理收到事件前,额外搜索可能已经在上游执行。由于 Responses 没有等价的拒绝列表,带有非空 `blocked_domains` 的请求也会明确失败。本地执行的 WebFetch 不受影响。
|
||||
- **用量看板金额是参考值**:token 计数准确,但美元金额是按公开 API 价折算的估算——方式二订阅流量按 GPT-5.6 公开价折算,方式一的第三方网关按各自费率计费,两者都可能与真实扣费不符,仅供对比。方式二的额度消耗以供应商卡片上的窗口利用率为准。
|
||||
|
||||
## 常见问题
|
||||
|
||||
Reference in new issue
Block a user