Closed ksmooi closed 4 months ago
Yes, I meet the same issue. Even I refine the system prompt like:
You serve as an intelligent assistant. You must give your final answer in 1 rounds tool calls. And if you don't know the answer, just answer 'Sorry, I don't know'
It still repeat to call the tool until the input tokens exceed 64k context tokens limit. I leverage the langchain components to call agent to call tools. Qwen-max and Gpt-4o have a good understanding the various system prompt, but deepseek-v3 is not. It's so frustrating, even though the price is cheap.
DeepSeek V3 API function have bug
This is the underlying API issue as @jason571 pointed out, and is not related to LangGraph or LangChain. The condition for react agent termination is absence of tool calls in AI message, so if the API keeps returning tool calls, there is nothing we can do on LangGraph side.
Checked other resources
Example Code
Error Message and Stack Trace (if applicable)
Description
Describe the bug
When using
ChatOpenAI()
in LangChain with a custom tool (e.g.,DuckDuckGoSearchRun
), the API call does not terminate automatically after completing the task. Instead, it continues to make repeated tool calls indefinitely, leading to an infinite loop of search queries and responses.Expected behavior
The API call should terminate after completing the task (e.g., retrieving search results for the query) and return the final response.
System Info
Environment:
langchain-openai
,langchain-community
,langchain_experimental
,langgraph
deepseek-chat
(via DeepSeek API)