Skip to content

Instantly share code, notes, and snippets.

@decagondev
Created April 29, 2025 15:45
Show Gist options
  • Save decagondev/c43ea034cc41e426bf74c0ddcd343031 to your computer and use it in GitHub Desktop.
Save decagondev/c43ea034cc41e426bf74c0ddcd343031 to your computer and use it in GitHub Desktop.

Using LangSmith with LangGraph enables robust observability in multi-agent systems, especially when teams (like research teams using tools such as Tavily) are coordinated via a supervisor agent. Observability ensures transparency, debuggability, and traceability of workflows across the graph.


🧠 Why Use Observability in a LangGraph?

  • Debug execution flows across agents and tools.
  • Visualize agent decisions, tool calls, and responses.
  • Track latency, success/failure, and metadata.
  • Compare behavior across runs or task types.

LangSmith provides real-time and retrospective insight by logging:

  • Prompt inputs and outputs.
  • Tool invocations and results.
  • Decision branching within the graph.

πŸ” Sample Team Graph: Research with Tavily + Supervisor

In this example:

  • A user submits a query.
  • A Supervisor routes it to a Research Team, which uses Tavily to retrieve information.
  • Output is returned to the Supervisor for evaluation.
graph TD
  A[User Input] --> B[Supervisor Agent]
  B --> C{Task Type?}
  C -- Research --> D[Research Team]
  D --> E[Tool: Tavily Search]
  E --> F[Research Summary]
  F --> G[Supervisor Eval]
  G --> H[Final Output to User]
Loading

πŸ” LangSmith Integration Steps

1. Initialize a Tracer for LangSmith

from langsmith import traceable

@traceable(name="research_team")
def research_team(query):
    # Call Tavily, process result
    ...

2. Wrap Supervisor and Agents

@traceable(name="supervisor")
def supervisor_router(user_input):
    if "research" in user_input:
        return research_team(user_input)
    ...

3. Inspect Runs in LangSmith UI

  • View structured traces with nodes:
    • supervisor_router
    • research_team
    • Tavily tool invocation
  • Filter by tags, runtime, or errors.

πŸ“Š Benefits in a Team-Based LangGraph

  • Identify slow tools or agents.
  • Understand decision bottlenecks.
  • Ensure prompt consistency.
  • Export trace data for QA or reporting.

LangSmith turns your LangGraph from a black box into a traceable, auditable system β€” key for reliable, iterative development.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment