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:
The following examples show a complete retriever implementation with both requirements applied:
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.

