From 2d30ebb53b2dc1e93c047c094c3bf4de37f9de7e Mon Sep 17 00:00:00 2001 From: Shanto Mathew Date: Mon, 27 Oct 2025 10:18:10 -0500 Subject: [PATCH] docs(langchain): clarify create_tool_calling_agent system_prompt formatting and add troubleshooting (#33679) --- .../langchain_classic/agents/tool_calling_agent/base.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libs/langchain/langchain_classic/agents/tool_calling_agent/base.py b/libs/langchain/langchain_classic/agents/tool_calling_agent/base.py index 1c8b23ae669..d23ccb68cf9 100644 --- a/libs/langchain/langchain_classic/agents/tool_calling_agent/base.py +++ b/libs/langchain/langchain_classic/agents/tool_calling_agent/base.py @@ -83,11 +83,15 @@ def create_tool_calling_agent( ``` Prompt: - The agent prompt must have an `agent_scratchpad` key that is a `MessagesPlaceholder`. Intermediate agent actions and tool output messages will be passed in here. + Troubleshooting: + - If you encounter `invalid_tool_calls` errors, ensure that your tool + functions return properly formatted responses. Tool outputs should be + serializable to JSON. For custom objects, implement proper __str__ or + to_dict methods. """ missing_vars = {"agent_scratchpad"}.difference( prompt.input_variables + list(prompt.partial_variables),