Skip to main content
This guide shows you how to trace Pi coding agent sessions to LangSmith using the @langchain/langsmith-pi-extension extension. Once configured, each Pi session sends traces to LangSmith. Each trace includes user messages, assistant responses, tool calls, and individual LLM invocations, which gives you full observability into your Pi coding agent runs.
This integration does not support agent addressing. It traces to an agent environment by its tracer_session_name.

Prerequisites

Before setting up tracing, ensure you have:
  • Pi installed.
  • A LangSmith API key.
  • An agent in LangSmith. The extension does not support agent addressing, so it traces to one of the agent’s environments by name.

Installation

Install the extension via Pi:

Quick start

Tracing is disabled by default. Set the following environment variables to enable tracing and connect to your LangSmith account:
Run Pi as usual. When a session starts, the extension reports whether LangSmith tracing is enabled. You can also check the current tracing state at any time from within Pi:
Set LANGSMITH_PI_PROJECT to the agent environment’s tracer_session_name before sending traces.

Configuration

Configuration can come from environment variables or JSON config files. Values are merged in the following order, with later sources taking precedence:
  1. Defaults
  2. ~/.pi/langsmith.json (global config)
  3. <current-working-directory>/.pi/langsmith.json (project config)
  4. Environment variables

Environment variables

Example:

Config file

Create ~/.pi/langsmith.json for global settings or .pi/langsmith.json in a project directory for local overrides:
Config file fields:

Replicas

Use replicas to send traces to multiple LangSmith destinations simultaneously. This is useful for forwarding traces to both a personal workspace and a shared team workspace, or to a self-hosted LangSmith instance alongside the cloud.
Each replica entry can include an updates object to override metadata or tags on the replicated runs.