Many LLM applications retrieve documents from vector databases, knowledge graphs, or other indexes as part of a retrieval-augmented generation (RAG) pipeline. LangSmith provides dedicated rendering for retriever steps, which makes it easier to inspect retrieved documents and diagnose retrieval issues.Documentation Index
Fetch the complete documentation index at: https://docs.langchain.com/llms.txt
Use this file to discover all available pages before exploring further.
These steps are optional. If you skip them, your retriever data will still be logged, but LangSmith will not render it with retriever-specific formatting.
Set run_type to retriever
Pass run_type="retriever" to the traceable decorator (Python) or traceable wrapper (TypeScript). This tells LangSmith to treat the step as a retrieval run and apply retriever-specific rendering in the LangSmith UI:
traceable, pass run_type="retriever" when creating the RunTree object.
Return documents in the expected format
Return a list of dictionaries (Python) or objects (TypeScript) from your retriever function. Each item in the list represents a retrieved document and must contain the following fields:| Field | Type | Description |
|---|---|---|
page_content | string | The text content of the retrieved document. |
type | string | Must always be "Document". |
metadata | object | Key-value pairs with metadata about the document, such as source URL, chunk ID, or score. This metadata is displayed alongside the document in the trace. |
Related
- Annotate code for tracing: Overview of all tracing methods, including
traceable,RunTree, and the REST API. - Log LLM calls: Similar custom logging requirements for LLM steps.
Connect these docs to Claude, VSCode, and more via MCP for real-time answers.

