langchain-ai/langsmith-cursor-plugins.
Prerequisites
Before setting up tracing, ensure you have:- Cursor installed.
- Node.js 22.13 or later. The hooks use the built-in
node:sqlitemodule to recover attachments from Cursor’s local database. - A LangSmith API key.
Install and enable the plugin
Install the plugin directly from the GitHub repository in Cursor’s settings:- Open Cursor > Settings > Plugins.
- Paste
https://github.com/langchain-ai/langsmith-cursor-pluginsinto the plugin link field. - Confirm to add LangSmith Tracing for Cursor.
Alternative: install from a local clone
Install the hooks from a local clone oflangsmith-cursor-plugins. This writes ~/.cursor/hooks.json for all Cursor projects:
hooks.json. The committed bundle/ means these commands run without pnpm install or pnpm build — those are only needed when contributing changes to the TypeScript source.
Restart Cursor after installing so it reloads hooks.json.
Configure tracing
Tracing is disabled until bothenabled (or TRACE_TO_LANGSMITH=true) and an API key are set. Configure credentials with environment variables, a JSON config file, or both.
Environment variables
EveryLANGSMITH_CURSOR_* variable also accepts the shorter LANGSMITH_* form. When both are set, LANGSMITH_CURSOR_* takes precedence.
Add the variables to your shell configuration file (
~/.zshrc, ~/.bashrc, or ~/.bash_profile):
Config file
Use~/.cursor/langsmith.json for global defaults or ./.cursor/langsmith.json for project-level settings. Settings resolve in this order, with later sources overriding earlier ones: defaults, global config, project config, environment variables.
Keep config files that include API keys out of version control.
Secret redaction
The plugin redacts detected secrets from run inputs, outputs, errors, and metadata before uploading them to LangSmith. Redaction is on by default. Redaction runs on your machine before upload, so unredacted content never reaches LangSmith. Replica destinations receive the same redacted payload. Detection covers provider API key prefixes, JSON Web Tokens, and PEM private key blocks. It also covers contextual shapes such asAPI_KEY=<value>, an Authorization header, and a password embedded in a URL. Each match is replaced with [SECRET_DETECTED]. For the rule list, see Redact secrets from traces.
Redaction matches known credential shapes, so treat it as a safety net rather than a guarantee. A credential in an unrecognized format still reaches LangSmith, and attachments, run names, and tags do not pass through the anonymizer. A redacted trace also still holds the prompts, file contents, and tool results it was built from, so restrict who can read the tracing project.
Attachments bypass redaction entirely. The plugin recovers image and file attachments from Cursor’s local database and sends their bytes, which the anonymizer never inspects. Set LANGSMITH_CURSOR_ATTACHMENTS to "false" to stop sending them.
To turn redaction off, set LANGSMITH_CURSOR_REDACT to false, 0, no, or off, or set "redact": false in a config file.
To redact additional patterns, set LANGSMITH_CURSOR_REDACT_EXTRA to a JSON array of { "pattern": ..., "replace": ... } rules, or set redact_extra_rules in a config file. Each pattern is a regular expression string, applied globally and case-sensitively. replace is optional and falls back to [redacted]. Extra rules run after the built-in ones.
redact_extra_rules to [] clears rules inherited from a lower-priority source. One rule with an invalid regular expression discards every setting in that file, so keep the patterns simple and verify them before committing.
Because a project-level .cursor/langsmith.json can set redact to false, review that file before enabling tracing in a repository you do not control.
What gets traced
The plugin listens to Cursor hooks and assembles one trace per agent turn:- Turns: each turn becomes its own trace, grouped into a thread using
thread_id= Cursor’sconversation_id. The trace nests the model run and any tool or subagent runs underneath the turn. - Token usage: per-turn
usage_metadataon the model run. - Model and provider:
ls_model_nameandls_provider, normalized from Cursor’s model label to a canonical provider id (for example,claude-4.6-sonnetbecomesclaude-sonnet-4-6). Auto mode reportsdefaultwith providercursor. - Tool calls: tool runs for both successful calls and failures, with inputs and outputs.
- Attachments: image and file attachments recovered from Cursor’s local database and rendered inline on the user message. Set
attachmentstofalseto skip this step. - Subagents: each subagent appears as a nested chain run with its own tool calls underneath, linked to the parent turn.
The plugin does not compute cost locally. Because
ls_model_name is normalized to a canonical id and usage_metadata carries the token breakdown, LangSmith’s server-side model price table renders cost in the UI. Auto mode reports default, which LangSmith cannot price.Trace metadata
Every run carries the sharedcoding-agent-v1 metadata contract on run.extra.metadata, which lets traces from any coding agent (Claude Code, Codex, Cursor) be identified and grouped with the same stable keys.
Cursor’s hooks do not expose stable sources for
user_id, sandbox_type, or approval_policy, so those keys are omitted.
View traces in LangSmith
Open the configured LangSmith project (defaultcursor) and complete a Cursor turn. The plugin uploads one trace per turn with this structure:
thread_id in the Threads tab of the project.
Known limitations
- Subagent token usage: Cursor does not expose a per-subagent usage breakdown via hooks or its local database, so a subagent’s
Taskrun carries its tool calls but no token counts.
Troubleshooting
If traces do not appear in LangSmith:- Confirm
TRACE_TO_LANGSMITH=trueor"enabled": trueis set in a config file the Cursor process can see. - Confirm
LANGSMITH_CURSOR_API_KEYorLANGSMITH_API_KEYis set and valid. - Confirm Cursor was fully restarted after the hooks were installed.
- Tail the hook log for errors:
tail -f ~/.cursor/langsmith-hook.log. - Enable verbose logging with
LANGSMITH_CURSOR_DEBUG=trueand re-check the log. - If runs land in the wrong project, set
LANGSMITH_CURSOR_PROJECTor theprojectconfig key.
Connect these docs to your agent of choice via MCP for real-time answers.

