Airsc miễn phí cho tất cả. Nếu nó giúp bạn, hãy ủng hộ $2–$20.

Ủng hộ
PluginCẩn thậnKiểm thử & sửa lỗiCần cài đặt chút

langsmith-claude-code-plugins

langchain-ai · langchain-ai/langsmith-claude-code-plugins

Plugin Claude Code ghi lại trace các cuộc hội thoại, lệnh gọi tool, subagent và quá trình nén ngữ cảnh lên LangSmith.

LangSmith plugins for Claude Code

73 sao15Giấy phép: MITCập nhật 12 ngày trước0 lượt mở

Xem trước

▍

Bạn có thể làm gì với nó

  • Xem lại mọi lệnh gọi tool mà Claude Code thực hiện trong một phiên trên LangSmith
  • Gỡ lỗi vì sao một subagent hành xử bất ngờ
  • Giám sát hoạt động của agent trong cả nhóm

Kiểm tra an toàn

Cẩn thận

Dùng được, nhưng nên đọc ghi chú trước.

  • ●Trình cài đặt tải script từ xa và chạy thẳng bằng shell.README.md

Quét tự động các file trong repo. Luôn xem lại code trước khi chạy.

Trích từ README

LangSmith Tracing Plugin for Claude Code

A Claude Code plugin that traces conversations, tool calls, subagent executions, and context compaction to LangSmith.

Setting up the LangSmith Gateway? Start with the required LangSmith CLI installation and browser login, then install and enable the separate langsmith-gateway plugin. The tracing plugin documented below does not require the LangSmith CLI and is optional when using the gateway.

Prerequisites

  • Node.js v18+, needed only when the plugin carries no build for your machine

Installation

Claude Code installs and manages the plugin for you, and the plugin carries its own macOS builds so there is nothing to download separately.

As a Claude Code plugin

From within Claude Code, run:

/plugin marketplace add langchain-ai/langsmith-claude-code-plugins
/plugin install langsmith-tracing@langsmith-claude-code-plugins
/reload-plugins

The hooks run a macOS build carried inside the plugin whenever one matches your machine, so on a Mac there is nothing to download and nothing to keep up to date beyond the plugin itself. Anywhere else, such as Linux and Windows, the same integration runs on the Node on your PATH. Either way the plugin shows up in /plugin with its name, version and enabled state, which is how you check that tracing is active.

To update, refresh the marketplace from within Claude Code:

/plugin marketplace update langsmith-claude-code-plugins

then move the install onto the new version from your shell:

claude plugin update langsmith-tracing@langsmith-claude-code-plugins

and restart Claude Code.

The marketplace update on its own only refreshes the catalog clone. Your install stays pinned to the version directory it was installed from, so the hooks keep running the old bundle until claude plugin update moves it.

To skip both steps next time, run /plugin, open Marketplaces → langsmith-claude-code-plugins and choose Enable auto-update. Third-party marketplaces have it off by default; enabling it updates the marketplace and its installed plugins together.

As a Claude Cowork plugin

Claude Cowork runs Claude Code in a sandboxed VM, thus the plugin needs to be added separately.

  1. Allow network egress for LANGSMITH_CC_ENDPOINT (eg. https://api.smith.langchain.com) or for all domains
  2. Add langchain-ai/langsmith-claude-code-plugins marketplace in Customize > Personal Plugins (+) > Create Plugin > Add Marketplace
  3. Edit each of the Claude Code hooks by prepending LangSmith Claude Code environment variables to command of every hook. Watch video to see step-by-step.

https://github.com/user-attachments/assets/1d44b30f-e0a8-4173-b60b-97a2d1fb95c5

[!IMPORTANT] Make sure that 'Allow network egress' is either enabled for all domains or enabled for LANGSMITH_CC_ENDPOINT, otherwise Cowork might freeze.

From source (development)

pnpm install
pnpm build
claude --plugin-dir /path/to/langsmith-claude-code-plugins

Setting environment variables

Option 1: Claude Code settings file (recommended)

Add the following to a .claude/settings.local.json file in your project folder or ~/.claude/settings.json globally:

{
  "env": {
    "TRACE_TO_LANGSMITH": "true",
    "CC_LANGSMITH_API_KEY": "lsv2_pt_...",
    "CC_LANGSMITH_PROJECT": "my-project"
  }
}

Option 2: Export to shell

Add to your ~/.zshrc, ~/.bashrc, or ~/.bash_profile:

export TRACE_TO_LANGSMITH="true"
export CC_LANGSMITH_API_KEY="lsv2_pt_..."
export CC_LANGSMITH_PROJECT="my-project"

Getting your LangSmith API key

  1. Go to smith.langchain.com
  2. Sign in or create an account
  3. Navigate to Settings → API Keys
  4. Click Create API Key
  5. Copy the key (starts with lsv2_pt_...)

What gets traced

With full tracing (the default), each LLM run includes:

  • Inputs: accumulated conversation messages
  • Outputs: assistant response content
  • Metadata: ls_provider: "anthropic", ls_model_name, ls_invocation_params (model, plus effort/service_tier when the transcript records them), token usage

In full mode, all runs (LLM, tool, turn, subagent) automatically include identity metadata so you can attribute traces in LangSmith:

  • anthropic_user_id: read from the userID field in ~/.claude.json (the Claude Code installation's stable hashed user ID). Omitted if the file is missing or unreadable.
  • local_username: the local OS username from os.userInfo().

To override either field, supply your own value via CC_LANGSMITH_METADATA since user-supplied keys always win.

Tool runs include the tool name, inputs, and output content. Skill tool runs additionally set ls_skill_name to the invoked skill's name, read from the tool's skill input, so per-skill usage is queryable in run stats.

Interrupted turns (where the user cancels mid-response) are marked with status "interrupted" in LangSmith.

Opening the current session in LangSmith

Run /langsmith-tracing:trace to get a link to this conversation's trace. It does not start a model turn or change any settings. When you trace to several projects, you get one labelled link per project.

  • A new thread is empty until a traced prompt finishes uploading.
  • Changing projects does not move older traces.
  • These are not public share links; recipients need access to the project.
  • If the lookup fails, search LangSmith for the session ID it prints.

Muting a thread

Muting is off by default unless configured below. With tracing enabled, use these argument-free plugin commands:

  • /langsmith-tracing:mute: omit this thread's input/output content and unsafe metadata.
  • /langsmith-tracing:unmute: restore full tracing for subsequent turns.

Claude Code namespaces

Xem mã nguồn trên GitHub