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

Langchain AgentExecutor无法调用任何工具的问题求助

Falcon-40B-Instruct与LangChain ReAct框架集成的工具调用异常问题

我正在使用Hugging Face上的tiiuae/falcon-40b-instruct模型,尝试将其与LangChain的ReAct框架结合。具体实现为:通过包含标准Thought/Action/Action Input/Observation提示及少量示例的StringPromptTemplate构建常规LLMChain(有无示例均无效果),将该LLMChain纳入LLMSingleActionAgent,最终由AgentExecutor运行。

当前遇到的核心问题:

  • AgentExecutor无法实际调用任何工具,多数情况下能选中正确工具,但会直接生成工具输出的幻觉内容;
  • 开启调试模式后可明确看到,模型大多不会进入tool/start或tool/end链;
  • 按照此前相关建议调高模型temperature后,仅5%-10%的概率会进入工具链,但返回内容仅为“Invalid or incomplete response.”;
  • 尝试过使用结构化工具、调整提示内容等方法,问题仍未解决。

相关代码定义如下:

# LLM chain consisting of the LLM and a prompt
llm_chain = LLMChain(llm=local_llm, prompt=prompt)

tool_names = [tool.name for tool in tools]

agent = LLMSingleActionAgent(
    llm_chain=llm_chain, 
    output_parser=CustomOutputParser(),
    stop=["\nObservation:"], 
    allowed_tools=tool_names
)
# handle_parsing_errors="Check your output and make sure it conforms!"
agent_executor = AgentExecutor.from_agent_and_tools(agent=agent, 
                                                    tools=tools, 
                                                    verbose=True)

内容的提问来源于stack exchange,提问作者linw

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.13 09:22:36