I’m using create_react_agent for an agent that calls various tools and, at the end, gives an answer to the user. I have a system prompt that contains tools guidelines and a sizable part with personality, role etc.
I feel that this last part is not relevant when calling the tools and it should be separate, to help the model to focus better on tools calling.
Could I create a tool (like summarize_answer) that is called as the final step and return its answer to the user?
What other techniques exist for solving this?
Hi
If this is only for the user, I agree that adding a final node like summarize_answer is a better choice.
Otherwise (if your tools also require a summary instead of the full message), you’ll need to use a summarization middleware: Middleware - Docs by LangChain
For reference:
The summary for user should follow the approach shown here:
Foundation: Introduction to LangGraph, Module 4 Lesson 4: Research Assistant (write_section node)
The summary for all should follow the approach shown here:
Foundation: Introduction to LangGraph, Module 2 Lesson 5: Chatbot w/ Summarizing Messages and Memory