LangChain Mastery

Course Content

LangChain Mastery

7 sections · 109 lessons

What is the role of verbose mode in LangChain?


What you need to know

Three levels of "show me what happened"

OptionWhat it showsWhere it works
verbose=True / set_verbose(True)Short step summaries, agent thoughtsLegacy Chain subclasses, AgentExecutor (now in langchain-classic)
set_debug(True)Every run's full inputs, outputs, timingEverything, including LCEL and agents
LangSmith tracingNested tree, tokens, cost, errors, searchable historyEverything; also production
Python
from langchain_core.globals import set_debug, set_verboseset_debug(True)     # loud: full payloads for every step

In LangChain 1.x these functions live in langchain_core.globals; langchain.globals no longer exists.

For one call only, pass a console tracer instead of changing global state:

Python
from langchain_core.tracers import ConsoleCallbackHandlerchain.invoke(inputs, config={"callbacks": [ConsoleCallbackHandler()]})

For agents built with create_agent, create_agent(..., debug=True) prints each graph step, and agent.stream(..., stream_mode="updates") shows every model turn and tool result as it happens.

Why not in production

  • Privacy — full prompts and outputs, including personal data, go to stdout and then to log storage.
  • Noise — output from concurrent requests interleaves and becomes unreadable.
  • Cost — large payloads to stdout add I/O time and log-storage cost.
  • Global state — set_debug affects every request in the process.

In production use LangSmith (or OpenTelemetry export) with sampling, plus a callback handler that writes structured JSON logs with a request id.

A real-life example

A developer building a travel-booking agent can't see why it books the wrong date. They set verbose=True as an old tutorial suggests and get no output, because the agent is built with create_agent, not AgentExecutor.

They switch to agent.stream({"messages": [...]}, stream_mode="updates") and print each update. The output shows the model calling search_flights(date="2026-03-10") when the user wrote "3/10" and meant 3 October — the model read it as a US-style month/day date. They add "dates are DD/MM/YYYY, Indian format" to the system prompt and a date type to the tool schema. In production the same information comes from LangSmith traces, sampled at 10%.

Follow-up questions to expect

  • "Difference between verbose and debug?" — Verbose is a short, human-readable summary for legacy components; debug is everything, for every runnable.
  • "How do you see an agent's reasoning today?" — Stream the agent's messages and tool calls, or open the LangSmith trace; reasoning models may also return reasoning content blocks.
  • "Can you turn debug on for one request in production?" — Pass a callback handler in that request's config instead of global debug.