飞书桥接 + AWS Bedrock Provider:Claude 模型被误报为协议不匹配

Open Beginner friendly
#648 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
65/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
typescript

Research direction

Read the Claude-model guard in src/lib/bridge/conversation-engine.ts and compare its protocol allowlist with CLAUDE_CODE_READY_PRESETS in runtime-compat.ts. Check how the Feishu bridge resolves the provider and model, then verify that Bedrock and Vertex Claude models no longer trigger the mismatch error while unsupported protocols still do.

Written by the indexing model from the issue text.

Description

问题描述

在飞书桥接(Feishu Bridge)中,将 Provider 配置为 AWS Bedrock(protocol: 'bedrock')并使用 Claude 模型(如 global.anthropic.claude-sonnet-5)时,发送消息会报错:

Error: Provider "AWS Bedrock" uses bedrock protocol but model "global.anthropic.claude-sonnet-5" is an Anthropic model. Please configure the correct provider for this bridge channel.

即使模型 ID 是 Bedrock 上真实存在、可用的模型,该报错依然会触发,无法正常使用。

根因

src/lib/bridge/conversation-engine.ts 附近(约第 183-191 行)有一段 fail-fast 保护逻辑:

const isAnthropicModel = modelLower.includes('claude') || ['sonnet','opus','haiku'].includes(modelLower);
const isNonAnthropicProtocol = !['anthropic', 'openai-compatible', 'openrouter'].includes(resolved.protocol);
if (isAnthropicModel && isNonAnthropicProtocol) {
  throw new Error(...);
}

问题在于协议白名单 ['anthropic', 'openai-compatible', 'openrouter'] 里漏掉了 bedrock 和 vertex。而 AWS Bedrock 和 Google Vertex AI 恰恰是官方支持、专门用来托管运行 Claude/Anthropic 模型的两个云协议——这一点可以从代码库自身另一处常量得到印证(runtime-compat.ts):

const CLAUDE_CODE_READY_PRESETS = new Set(['anthropic-official', 'bedrock', 'vertex']);

这里已经明确把 bedrock、vertex 和 anthropic-official 并列,认定它们都是能正常运行 Claude Code 的正规协议。

因此,只要 provider 的 protocol 是 bedrock(或 vertex),并且模型名包含 "claude"/"sonnet"/"opus"/"haiku",这条 guard 就会必定误报,把"协议本来就是用来服务 Anthropic 模型的"错误判断为"协议和模型不匹配"。

复现步骤

  1. 在 CodePilot 中新建一个 Provider,protocol 选择 bedrock,配置好 AWS 凭证。
  2. 将该 Provider 设为某个飞书桥接频道/群的默认 Provider,模型填一个真实存在的 Claude 模型 ID(例如 global.anthropic.claude-sonnet-5)。
  3. 在飞书里给机器人发消息。
  4. 收到报错:Provider "AWS Bedrock" uses bedrock protocol but model "..." is an Anthropic model...

建议修复

将 conversation-engine.ts 中的协议白名单补全为:

const isNonAnthropicProtocol = !['anthropic', 'openai-compatible', 'openrouter', 'bedrock', 'vertex'].includes(resolved.protocol);

环境

  • CodePilot 桌面版(macOS)
  • 触发场景:飞书消息桥接(Feishu Bridge)+ AWS Bedrock Provider
Dominant language
TypeScript
Stars
6.5k
Forks
697
PR merge metrics
No merged PRs in 30d

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from op7418/CodePilot

All issues in op7418/CodePilot

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.