Many LLM applications have a chatbot-like interface in which the user and the LLM application engage in a multi-turn conversation. In order to track these conversations, you can use threads in LangSmith.Documentation Index
Fetch the complete documentation index at: https://langchain-5e9cc07a-preview-naomid-1779801766-572e290.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Group traces into threads
To associate traces together into a thread, you need to pass in a specialmetadata key where the value is the unique identifier for that thread. The key name should be one of:
session_idthread_idconversation_id
uuid7 helper (Python v0.4.43+, JS v0.3.80+):
- Python:
from langsmith import uuid7 - JS/TS:
import { uuid7 } from 'langsmith'
Example
This example demonstrates how to log and retrieve conversation history using a structured message format to maintain long-running chats. The example sets aTHREAD_ID and passes it via metadata to the tracing wrapper, linking every run from that session into the same thread in LangSmith. Conversation history is persisted locally between turns—replace the file-based or in-memory store with a database or cache in production. The get_chat_history flag controls whether the pipeline continues an existing thread or starts a fresh one:
get_chat_history=True / get_chat_history: true / getChatHistory = true, you can continue the conversation from where it left off. This means that the LLM receives the entire message history and responds to it, instead of just responding to the latest message:
View threads
You can view threads in the UI by clicking on the Threads tab in any project details page. The table shows each thread’s first input, last output, start times, turn count, latency (P50/P99), token usage, cost, and feedback score. The right panel displays aggregate stats for the project, including thread and trace counts, total and median token usage, error rate, and P50/P99 latency.Use Polly in thread views to analyze conversation threads, understand user sentiment, identify pain points, and track whether issues were resolved.
- Messages view (Beta): the conversation layer. Scan each turn as a chat-style thread showing user and assistant messages, tool calls, and subagent activity.
- Turns view: the per-turn summary. View each turn as a card showing its inputs and outputs, with expand/collapse and customizable input/output fields.
- Details view: the debugging layer. Drill into a specific run to inspect inputs, outputs, metadata, timing, errors, and child runs. The surrounding thread context stays visible so you can see where the run fits in the broader conversation.
M (Messages), T (Turns), and D (Details). While the Messages view is in beta, the thread side panel defaults to the Details view. The right panel shows stats for the thread, including turn count, first and last start times, P50/P99 latency, and a cost breakdown by input and output tokens. For a full description of each view, see View traces.
View feedback
Feedback scores are visible in the Feedback column of the threads table on the project’s Threads tab. Within a thread, open the Messages view and click the LLM call link in a turn’s metadata row to go to the Details view for that run, where you can review feedback for the run. You can also see thread-level feedback there.Save thread-level filter
Thread filters look through all runs and surface a thread if at least 1 run matches the filter.
Related
- Observability concepts: background on threads and how they relate to runs and traces.
- Add metadata and tags to traces: how to pass
thread_idand other metadata keys. - Filter traces: filter by thread metadata in the tracing UI.
- Set up multi-turn online evaluators: evaluate threads rather than individual runs.
- Log user feedback using the SDK: attach feedback to runs within a thread.
Connect these docs to Claude, VSCode, and more via MCP for real-time answers.

