You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

LangGraph create_react_agent函数报错:TypeError: create_react_agent() got an unexpected keyword argument 'response_format'

LangGraph create_react_agent函数报错:TypeError: create_react_agent() got an unexpected keyword argument 'response_format'

我之前也碰到过一模一样的问题,这大概率是LangGraph版本不匹配导致的!

你参考的文档里确实标注了create_react_agent支持response_format参数,但这个参数是LangGraph较新的版本才引入的。如果你本地安装的LangGraph版本偏旧,函数里根本没有这个参数,自然会抛出“意外关键字参数”的错误。

给你几个解决步骤:

  • 先检查当前LangGraph版本:

    pip show langgraph
    

    看看版本号是否低于0.2.0(这个参数大概是在0.2.x版本系列中新增的)。

  • 升级到最新稳定版:

    pip install --upgrade langgraph
    
  • 顺带升级相关依赖避免版本冲突:

    pip install --upgrade langchain langchain-openai
    

升级完成后再运行你的代码,应该就能正常识别response_format参数了。你的代码逻辑本身是没问题的,完全符合文档示例,就是版本拖了后腿~

备注:内容来源于stack exchange,提问作者jmelm93

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.14 14:53:04