fix: 移除 1M 上下文的账户类型限制,信任 admin 的 allow1mContext 授权

部分 Claude 订阅类型(Pro/Team/Enterprise)原生支持 1M 上下文,
之前的实现仅允许 Bedrock 账户类型通过,过于保守。

现在当 admin 为 API Key 启用 allow1mContext 后,任何账户类型
(claude-official、claude-console、bedrock)均可使用 1M 上下文。
This commit is contained in:
yptse123
2026-03-02 17:12:44 +08:00
parent 5d3456911b
commit b2e4187ea3

View File

@@ -389,14 +389,11 @@ async function handleMessagesRequest(req, res) {
throw error
}
// 1M 上下文窗口:检查调度到的账户类型是否支持
if (is1mContextRequest && accountType !== 'bedrock') {
return res.status(403).json({
error: {
type: 'forbidden',
message: `1M 上下文窗口仅支持 Bedrock 账户类型,当前调度到 ${accountType},请绑定 Bedrock 账户`
}
})
// 1M 上下文窗口:记录日志admin 已通过 allow1mContext 授权,信任其决定)
if (is1mContextRequest) {
logger.api(
`📐 1M context request allowed for key: ${req.apiKey.name}, accountType: ${accountType}`
)
}
// 🔗 在成功调度后建立会话绑定(仅 claude-official 类型)