
Langsmith Trace
Wire LangSmith tracing into LangChain or LangGraph apps and query or export traces when debugging solo-builder AI features in production.
Overview
Langsmith-trace is an agent skill most often used in Operate (also Build integrations, Ship testing) that adds LangSmith tracing to applications and queries or exports traces for debugging and analysis via the langsmith
Install
npx skills add https://github.com/langchain-ai/langsmith-skills --skill langsmith-traceWhat is this skill?
- Covers both adding LangSmith tracing to apps and querying or exporting trace data for debugging
- Python and JavaScript implementations supported with LangChain or LangGraph automatic tracing via environment variables
- LangSmith CLI installed via one-line curl installer script for list and export workflows
- Requires LANGSMITH_API_KEY with optional LANGSMITH_PROJECT and LANGSMITH_WORKSPACE_ID for org-scoped keys
- Documents --api-key flag on CLI commands as the preferred auth path alongside env vars
- Two main topics: adding tracing and querying or exporting trace data
- Python and JavaScript implementations both supported
Adoption & trust: 2.3k installs on skills.sh; 130 GitHub stars; 2/3 security scanners passed (skills.sh audits).
What problem does it solve?
You cannot see what your LangChain or LangGraph agent actually did on a failed run without a consistent tracing setup and a repeatable way to query LangSmith.
Who is it for?
Solo builders running LangChain or LangGraph in Python or JavaScript who already use or plan to use LangSmith and want one skill for instrumentation plus trace queries.
Skip if: Teams that do not use LangChain, LangGraph, or LangSmith, or who only need generic APM without LLM span semantics.
When should I use this skill?
INVOKE THIS SKILL when working with LangSmith tracing OR querying traces.
What do I get? / Deliverables
Your app emits traces into the correct LangSmith project and you can list, inspect, and export runs with authenticated CLI commands when debugging.
- Tracing environment configuration for the target LangSmith project
- CLI-driven trace lists and exports for debugging sessions
- Documented project and workspace env alignment before queries
Recommended Skills
Journey fit
Spans multiple journey phases - primary shelf plus alternate fits below.
Trace inspection and export are core production observability tasks after you ship agent or API workloads. LangSmith project-scoped trace list and analysis maps directly to monitoring LLM runs, latency, and failures in one place.
Where it fits
Enable LANGSMITH_TRACING and default project env vars while wiring your first LangGraph graph locally.
List traces for a staging project after a regression test fails on tool-calling behavior.
Export recent production traces to compare latency spikes across prompt versions.
How it compares
Use this LangSmith-focused procedural skill instead of guessing OpenTelemetry wiring for LangChain runs without project-scoped CLI query patterns.
Common Questions / FAQ
Who is langsmith-trace for?
Indie and solo developers shipping agent, API, or SaaS features on LangChain or LangGraph who need LangSmith tracing and trace lookup in daily workflows.
When should I use langsmith-trace?
Invoke it when enabling LANGSMITH_TRACING during Build integrations, when validating runs before Ship, or when querying traces in Operate monitoring after user-reported failures.
Is langsmith-trace safe to install?
The skill expects a LangSmith API key and network access to LangSmith; review the Security Audits panel on this Prism page and rotate keys if the repo or skill source is untrusted.
SKILL.md
READMESKILL.md - Langsmith Trace
<oneliner> Two main topics: **adding tracing** to your application, and **querying traces** for debugging and analysis. Python and Javascript implementations are both supported. </oneliner> <setup> Environment Variables ```bash LANGSMITH_API_KEY=lsv2_pt_your_api_key_here # REQUIRED LANGSMITH_PROJECT=your-project-name # Optional: default project LANGSMITH_WORKSPACE_ID=your-workspace-id # Optional: for org-scoped keys ``` Authentication is REQUIRED: either set the `LANGSMITH_API_KEY` environment variable, or pass the `--api-key` flag to CLI commands (preferred): ```bash langsmith trace list --project my-project --api-key $LANGSMITH_API_KEY ``` **IMPORTANT:** Always check the environment variables or `.env` file for `LANGSMITH_PROJECT` before querying or interacting with LangSmith. This tells you which project contains the relevant traces and data. If the LangSmith project is not available, use your best judgement to identify the right one. CLI Tool ```bash curl -sSL https://raw.githubusercontent.com/langchain-ai/langsmith-cli/main/scripts/install.sh | sh ``` </setup> <trace_langchain_oss> For LangChain/LangGraph apps, tracing is automatic. Just set environment variables: ```bash export LANGSMITH_TRACING=true export LANGSMITH_API_KEY=<your-api-key> export OPENAI_API_KEY=<your-openai-api-key> # or your LLM provider's key ``` Optional variables: - `LANGSMITH_PROJECT` - specify project name (defaults to "default") - `LANGCHAIN_CALLBACKS_BACKGROUND=false` - use for serverless to ensure traces complete before function exit (Python) </trace_langchain_oss> <trace_other_frameworks> For non-LangChain apps, if the framework has native OpenTelemetry support, use LangSmith's OpenTelemetry integration. If the app is NOT using a framework, or using one without automatic OTel support, use the traceable decorator/wrapper and wrap your LLM client. <python> Use @traceable decorator and wrap_openai() for automatic tracing. ```python from langsmith import traceable from langsmith.wrappers import wrap_openai from openai import OpenAI client = wrap_openai(OpenAI()) @traceable def my_llm_pipeline(question: str) -> str: resp = client.chat.completions.create( model="gpt-4o-mini", messages=[{"role": "user", "content": question}], ) return resp.choices[0].message.content # Nested tracing example @traceable def rag_pipeline(question: str) -> str: docs = retrieve_docs(question) return generate_answer(question, docs) @traceable(name="retrieve_docs") def retrieve_docs(query: str) -> list[str]: return docs @traceable(name="generate_answer") def generate_answer(question: str, docs: list[str]) -> str: return client.chat.completions.create(...) ``` </python> <typescript> Use traceable() wrapper and wrapOpenAI() for automatic tracing. ```typescript import { traceable } from "langsmith/traceable"; import { wrapOpenAI } from "langsmith/wrappers"; import OpenAI from "openai"; const client = wrapOpenAI(new OpenAI()); const myLlmPipeline = traceable(async (question: string): Promise<string> => { const resp = await client.chat.completions.create({ model: "gpt-4o-mini", messages: [{ role: "user", content: question }], }); return resp.choices[0].message.content || ""; }, { name: "my_llm_pipeline" }); // Nested tracing example const retrieveDocs = traceable(async (query: string): Promise<string[]> => { return docs; }, { name: "retrieve_docs" }); const generateAnswer = traceable(async (question: string, docs: string[]): Promise<string> => { const resp = await client.chat.completions.create({ model: "gpt-4o-mini", messages: [{ role: "user", content: `${question}\nContext: ${docs.join("\n")}` }], }); return resp.choices[0].me