使用自定义 provider(type: custom,apiFormat: openai-chat),走 opencode 链路(https://opencode.ai/zen/go/v1),调用 kimi-k2.6 模型时报错:
AI_APICallError: Error from provider: 2 request validation errors: Extra inputs are not permitted, field: 'messages[0].cache_control';
Extra inputs are not permitted, field: 'messages[1].cache_control'
复现步骤:
添加 custom provider,baseURL 为 https://opencode.ai/zen/go/v1
apiFormat 设为 openai-chat
选择该 provider 下的 kimi-k2.6 模型发消息
每次请求必现 400
根因分析:
Alma 在构造消息请求时,给所有 provider 的消息体里加了 Anthropic 专有的 cache_control 字段(prompt caching 标记),但没有按 apiFormat 做字段过滤。对于 openai-chat 格式的 provider,应该剥离 cache_control,但目前被原样发送了。OpenCode 网关严格校验 OpenAI 格式,直接拒绝。
同类案例(供参考):
OpenOmniBot #301:同问题,修复方式是 buildOpenAICompatibleRequestBody() 中递归清除 cache_control
earendil-works/pi #3779:同样走 opencode 链路,同样 cache_control 报 400,修复方式是给非 Anthropic 模型加 compat 标记
环境:
Alma 版本:127
Provider 类型:custom,apiFormat: openai-chat
目标模型:kimi-k2.6(via opencode)
Please authenticate to join the conversation.
In Review
Bug Reports
About 1 hour ago

钱军
Get notified by email when there are changes.
In Review
Bug Reports
About 1 hour ago

钱军
Get notified by email when there are changes.