
See Inside Every Claude Code Session: LangSmith Tracing in Three Commands
Chris Harper
2 min read
Jun 28, 2026 · 04:05 UTC
TL;DR: Three slash commands install the LangSmith plugin; set TRACE_TO_LANGSMITH=true and every Claude Code turn appears as a trace tree showing subagent calls, tool use, and token counts.
Claude Code sessions can run dozens of tool calls and subagent delegations in a single turn. Without observability, you are guessing at what happened after the fact. The LangSmith Claude Code plugin from LangChain changes that: every session turn becomes a trace with tool calls, subagent runs, and context compaction events as child spans.
Install in Claude Code (three commands)
/plugin marketplace add langchain-ai/langsmith-claude-code-plugins
/plugin install langsmith-tracing@langsmith-claude-code-plugins
/reload-plugins
Enable tracing
export LANGCHAIN_API_KEY=<your-langsmith-key> # free tier at langchain.com/langsmith
export TRACE_TO_LANGSMITH=true
Or add to your project's .claude/settings.local.json:
{
"env": {
"LANGCHAIN_API_KEY": "<key>",
"TRACE_TO_LANGSMITH": "true"
}
}
What you see in LangSmith
Each Claude Code turn becomes a trace tree:
- Root span: the user message + turn metadata
- Child spans: every
tool_usecall with its input, output, and latency - Subagent spans: subagent delegations appear as nested traces with their own tool call trees
- Compaction span: context compaction events show when and why the context was trimmed, with before/after token counts
Token counts and cumulative cost appear at each node, so you can see exactly which tools and subagents consume the most context.
What to look for
Runaway context growth: if a compaction span fires every 2 turns, your tool outputs are probably too verbose — tighten the output schema or summarize before returning.
Slow tools: sort spans by duration to find which tool calls are bottlenecking long sessions.
Subagent effectiveness: compare a single-agent approach vs a fan-out — the trace tree makes the token overhead of delegation visible so you can decide if it is worth it.
Caveat: subagents are traced only on completion. If you interrupt a turn mid-subagent, that subagent's child spans are not captured.
Sources: Trace Claude Code — LangSmith Docs | langsmith-claude-code-plugins — GitHub