From 81c7a207f3723b4dde15a8832f29500430759ee2 Mon Sep 17 00:00:00 2001 From: yuanhaitao Date: Wed, 25 Feb 2026 23:27:53 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8B=A6=E6=88=AA=201M=20=E4=B8=8A?= =?UTF-8?q?=E4=B8=8B=E6=96=87=E7=AA=97=E5=8F=A3=E8=AF=B7=E6=B1=82=EF=BC=8C?= =?UTF-8?q?=E9=81=BF=E5=85=8D=E4=B8=8D=E6=94=AF=E6=8C=81=E7=9A=84=E8=B4=A6?= =?UTF-8?q?=E6=88=B7=E8=A2=AB=E8=AF=AF=E6=A0=87=E8=AE=B0=E4=B8=BA=E9=99=90?= =?UTF-8?q?=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 当客户端使用 [1m] 模型时,请求会携带 anthropic-beta: context-1m 头。 部分账户订阅(如 Max)不支持 1M 上下文,上游返回 429 后系统会误将 账户标记为限流,导致后续所有请求被拦截。 现在在路由层直接检测 context-1m beta header,返回 403 提示用户 切换模型,不转发请求、不触发限流标记。 Co-Authored-By: Claude Opus 4.6 --- src/routes/api.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/routes/api.js b/src/routes/api.js index 85ad01f5..d022c43d 100644 --- a/src/routes/api.js +++ b/src/routes/api.js @@ -189,6 +189,17 @@ async function handleMessagesRequest(req, res) { } } + // 拦截 1M 上下文窗口请求(anthropic-beta 包含 context-1m) + const betaHeader = (req.headers['anthropic-beta'] || '').toLowerCase() + if (betaHeader.includes('context-1m')) { + return res.status(403).json({ + error: { + type: 'forbidden', + message: '暂不支持 1M 上下文窗口,请切换为非 [1m] 模型' + } + }) + } + logger.api('📥 /v1/messages request received', { model: req.body.model || null, forcedVendor,