LangChain JS: .content in chain's output returns array of objects instead of string when tool call is requested #8238
Replies: 1 comment
-
Yes, this is expected behavior in LangChain JS when tools are used. When a tool call is triggered, the
There is currently no configuration option to suppress or automatically exclude the rationale from the If you only want to send the final response after the tool call (and not the rationale), your current approach—checking For more details and community discussion on handling tool calls and output, see this GitHub discussion. If you have a specific output format you want, you may need to post-process the To continue talking to Dosu, mention @dosu-bot. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug 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'm using LangChain JS with an LLM chain that combines a
PromptTemplate
and an LLM bound to a tool via.bindTools()
.Everything works fine when the user input doesn't require a tool — the response from the chain is a string in
.content
,However, when the input does trigger a tool call (e.g., providing the user's name), the
.content
field becomes an array of objects:This
text
field seems to be the model's rationale before making the tool call.Question:
Is this expected behavior when tools are used? I do not need the model's rationale. Right now I am checking the .content field everytime, and when there is a tool call, I call the tool and send the new response rather than sending tool's rationale.
System Info
"@langchain/aws": "^0.1.8",
"@langchain/community": "^0.3.41",
"@langchain/core": "^0.3.45",
"@langchain/langgraph": "^0.2.64",
$ node -v
v20.17.0
Beta Was this translation helpful? Give feedback.
All reactions