![[Bug]: Missing supports_assistant_prefill on AWS Bedrock Claude 3.x entries in model_prices_and_context_window.json](https://www.chat-gpts.plus/wp-content/uploads/2026/06/30863-5a8096d3.jpg)
[Bug]: Missing supports_assistant_prefill on AWS Bedrock Claude 3.x entries in model_prices_and_context_window.json
快速结论:当使用 LiteLLM 调用 AWS Bedrock 上的 Claude 3 系列模型(如 Haiku、Sonnet、3.5 Sonnet 初版)时,supports_assistant_prefill 字段缺失(而非设为 false),导致预填(prefill)功能被静默禁用。优先排查 model_prices_and_context_window.json 中对应条目是否缺少该字段,并根据 Anthropic 官方文档确认这些模型实际支持该功能。
问题场景
用户在 LiteLLM SDK(Python 包,版本 v1.89.2)中加载 model_prices_and_context_window.json 模型配置时,发现多个 AWS Bedrock 上的 Claude 3 条目缺少 supports_assistant_prefill 字段。任何依赖该字段真值来启用预填功能的代码,会因字段缺失(None)而静默禁用该特性。
报错原文
# No error — the field is silently absent; callers that check truthiness treat None as False.
import litellm
info = litellm.get_model_info("anthropic.claude-3-haiku-20240307-v1:0")
print(info.get("supports_assistant_prefill")) # None (should be True)
原因分析
该问题属于数据不一致(data inconsistency)。model_prices_and_context_window.json 中多个 AWS Bedrock Claude 3 条目遗漏了 supports_assistant_prefill 字段,而这些模型(根据 Anthropic 官方迁移指南)实际支持 trailing-assistant continuation prefill。字段缺失原因可能在于多区域(us、eu、apac)模型配置维护时的疏忽,导致没有从单一源(single source of truth)同步该字段。
环境排查
- 确认 LiteLLM 版本(建议检查是否为 v1.89.2 或更早版本)
- 检查
model_prices_and_context_window.json中相关条目是否完整(如anthropic.claude-3-haiku-20240307-v1:0等) - 验证 Python 环境中
litellm包的版本号
解决步骤
- 定位
model_prices_and_context_window.json文件(通常在 LiteLLM 包目录内)。 - 搜索受影响的模型条目(如
anthropic.claude-3-haiku-20240307-v1:0、us.anthropic.claude-3-haiku-20240307-v1:0、eu.anthropic.claude-3-sonnet-20240229-v1:0等共 12 个)。 - 为每个缺失的条目添加
"supports_assistant_prefill": true字段,格式参考已正确填充的条目(例如"anthropic.claude-3-5-sonnet-20241022-v2:0": { "supports_assistant_prefill": true, ... })。 - 可优先尝试:在代码中添加验证脚本(如使用 Pydantic 进行 schema 校验),确保所有模型配置包含必要字段。
- 可优先尝试:考虑在代码中实现后备机制,当字段缺失时默认设为
true(前提是确认模型实际支持)。
验证方法
修改后,运行以下 Python 代码确认字段已正确返回 True:
info = litellm.get_model_info("anthropic.claude-3-haiku-20240307-v1:0")
print(info.get("supports_assistant_prefill")) # 应输出 True
同时,测试实际预填功能是否正常启用。



