coding

Debug LangChain Agents with LangSmith CLI

Learn how to debug LangChain agents using the LangSmith CLI tool to trace execution, inspect intermediate steps, and identify errors in agent workflows

Developers debug LangChain agents directly from the terminal using LangSmith Fetch commands.

Installation:

Terminal Commands:

  • langsmith fetch <run_id>: Retrieves specific agent trace data
  • langsmith fetch --project <project_name>: Pulls all runs from a project
  • langsmith fetch --filter "status:error": Filters failed executions
  • langsmith fetch --output json: Exports traces as JSON

Workflow Integration:

  • Pipe output to jq for JSON parsing: langsmith fetch <run_id> | jq '.outputs'
  • Combine with grep to search errors: langsmith fetch --filter "status:error" | grep "Exception"

Resources:

This eliminates browser context-switching and enables scriptable debugging workflows for production agent issues.