How do I add memory when using createToolCallingAgent? #8309
Replies: 1 comment
-
Hi @canbaoSama! I'm Dosu and I’m helping the langchainjs team. To add memory when using However, for the agent to correctly answer questions based on historical conversation records, you must ensure that the memory is properly injected into the agent's execution flow and that the chat history is updated after each interaction. The agent itself does not manage memory; this is handled by the executor or by explicitly passing the chat history as input. Here are the key points for effective memory integration:
For reference, the LangChain docs show that memory integration requires you to track the inputs and outputs as chat history, and to pass this history into the agent on each call. See the official example for adding memory to a custom agent. If your agent is not using the historical conversation records, double-check that:
There are no known issues with memory integration in the versions you listed, but effective use of memory with If you are still having trouble, consider logging the contents of your Let me know if you need a more concrete code example or have questions about a specific part of your setup! To reply, just mention my name @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Checked other resources
Commit to Help
Example Code
Description
I have tried using a local model, and chat_history can record the conversation content, but the agent cannot correctly answer questions based on the historical conversation records.
System Info
"@langchain/core": "0.3.53",
"@langchain/mcp-adapters": "0.4.2",
"@langchain/ollama": "0.2.0",
"langchain": "0.3.24",
Beta Was this translation helpful? Give feedback.
All reactions