Observability

Observability shows what an agent actually did on a run: its prompts, its tool calls, and where the time and tokens went. You can trace runs to LangSmith, or watch the dev server's live SSE stream.

LangSmith tracingCopy link to section: LangSmith tracing

B4.run runs on LangGraph, which sends traces to LangSmith when tracing is enabled. One agent run produces a nested trace under a single root run. It includes every LLM call (prompts, token counts and latency), every tool call (input and output) and every subagent child run. You don't need to add any instrumentation code to your routes.

Enabling tracingCopy link to section: Enabling tracing

Put your LANGSMITH_API_KEY in .env (or export it in your shell). When b4 dev loads the environment and finds LANGSMITH_API_KEY with no LANGCHAIN_TRACING_V2, it sets LANGCHAIN_TRACING_V2=true for you:

.env
LANGSMITH_API_KEY=lsv2_...
LANGCHAIN_PROJECT=my-research-agent   # optional: names the project in LangSmith

To opt out, set LANGCHAIN_TRACING_V2=false in your shell or .env. The auto-enable only fills unset variables, so an explicit false wins.

Reading a traceCopy link to section: Reading a trace

Open any run in the LangSmith UI. The hierarchy follows the LangGraph execution graph:

  • Root run: the full agent turn. Status is success when the turn completes normally.
  • LLM runs: one per model call, with the full prompt, sampled output, token usage, and latency.
  • Tool runs: one per tool call, with input and output. Subagent tool runs appear nested under the subagent's run.
  • Subagent runs: each task({ subagent, input }) dispatch appears as a child of the root run.

Human-in-the-loop interrupts in LangSmithCopy link to section: Human-in-the-loop interrupts in LangSmith

A HITL permission interrupt appears in LangSmith as a tool run with status interrupted and a GraphInterrupt in the error field. This is a pause, not a failure. The root run stays success, and the agent continues once the interrupt is resolved. A real error has status error and an exception string in the error field.

Live SSE streaming (no account required)Copy link to section: Live SSE streaming (no account required)

No LangSmith account? You can use the dev server's runs/stream endpoint, which streams every event in real time over SSE. Each event has a type (chunk, tool_call, tool_result, plan_update, interrupt, subagent.*, done) and a JSON payload you can pipe to any terminal or client. See Agent Protocol for the full event-type table and connection instructions.