Hi everyone,
I’m using LangChain v1 and creating an agent using create_agent with a set of tools.
The agent works as expected — it reasons through the problem, makes tool calls, and eventually generates an answer.
However, I’m facing an issue:
The agent doesn’t clearly bifurcate between its reasoning steps(by reasoning I mean the chain of thoughts) and the final response.
I’m using an async stream handler that invokes the agent like this:
async for token, metadata in agent.astream(
{"messages": [{"role": "user", "content": request.query}]},
stream_mode="messages",
):
print(f"node: {metadata['langgraph_node']}")
print(f"content: {token.content_blocks}")
I want to know if there’s a way to distinguish or separate:
- The agent’s thought process / reasoning trace, and
- The final response returned to the user.
Basically, how can I capture or output both — one for internal logs and another for user-facing response?
Has anyone implemented something similar or found a recommended pattern for this in LangChain v1?
Any insights, code snippets, or best practices would be greatly appreciated! ![]()