openclaw 调用大模型返回:400 "auto" tool choice requires --enable-auto-tool-choice and -...
错误信息
openclaw 调用大模型返回:400 "auto" tool choice requires --enable-auto-tool-choice and --tool-call-parser to be set
AI 解决方案
报错分析报告
1.错误翻译
原文:"auto" tool choice requires --enable-auto-tool-choice and --tool-call-parser to be set
译文:"auto"工具选择模式需要设置--enable-auto-tool-choice和--tool-call-parser参数
2. 原因分析
"auto"工具选择模式时,未启用自动工具选择功能(--enable-auto-tool-choice)和指定工具调用解析器(--tool-call-parser)。 3. 解决方案
以常见调用场景为例,补充缺失参数:
# 修复后的调用配置(以Python为例)
import openclaw
response = openclaw.ChatCompletion.create(
model="your-model-name",
messages=[{"role": "user", "content": "你的输入"}],
tool_choice="auto", # 使用auto模式
# 补充必要参数
extra_params={
"--enable-auto-tool-choice": True,
"--tool-call-parser": "your-parser-type" # 如"json"或平台要求的解析器类型
}
)
注:具体参数名需匹配OpenClaw/目标平台的API规范,若用命令行则添加对应flag。
4. 预防措施
tool_choice对应的必填参数(如auto需双参数)。 ---
以上分析基于报错信息中的参数缺失问题,修复后需确保参数值与平台支持的解析器类型一致。