How to separate reasoning(chain of thoughts) and final response in LangChain v1 Agent (create_agent)?

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:
:right_arrow: 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! :folded_hands:

Hello @UK59
Have you tried the example provided at Models - Docs by LangChain?

1 Like

Hey @mcavdar!
Sorry for the confusion, so I’m not kinda looking for reasoning, but what I meant when I say reasoning is actually the chain of thoughts the AI does before giving back the final answer. Like how it thinks, and how it interpret the tool response and so on…

1 Like

Yes, having the same issue.
I checked docs:

  1. Models - Docs by LangChain
  2. Streaming API - Docs by LangChain
    and it’s not clear how to get intermediate reasoning events.