Trace Every Cursor Agent Turn in LangSmith
This walkthrough details how to integrate LangSmith tracing with Cursor agents, ensuring that every agent turn is captured as a full, inspectable trace in LangSmith. The process involves installing the LangSmith plugin in Cursor, setting three specific environment variables (including `LANGCHAIN_TRACING_V2`), and running an end-to-end task to verify the hook's functionality.
Key takeaways
-
Full Trace Capture
By implementing this setup, every agent turn executed by Cursor is logged as a distinct trace in LangSmith, providing comprehensive visibility into the agent's execution flow.
-
Trace Structure Details
1:43
Each trace captures the model run details (model name, token usage), input/output, tool runs (e.g., file reads, shell commands), and nested tasks if sub-agents are involved.
-
Cross-Agent Comparison
LangSmith maintains a common trace structure that allows users to compare traces from multiple agents (Cursor, Claude Code, and Codex) within the same workspace.