Skip to content

feat: add langsmith setup to trace Claude Code and Codex to LangSmith#156

Draft
Paarth Ahuja (paarth-a) wants to merge 2 commits into
mainfrom
paarth/setup-trace-config
Draft

feat: add langsmith setup to trace Claude Code and Codex to LangSmith#156
Paarth Ahuja (paarth-a) wants to merge 2 commits into
mainfrom
paarth/setup-trace-config

Conversation

@paarth-a

Copy link
Copy Markdown
Member

Summary

Adds a langsmith setup command family that configures coding agents to send full-content traces to LangSmith, with a copy-paste quick start:

langsmith setup claude <api-key>   # ~/.claude/settings.json
langsmith setup codex <api-key>    # ~/.codex/{config.toml,langsmith.json}
langsmith setup all <api-key>      # both
  • API key is a positional argument (also resolvable from --api-key, $LANGSMITH_API_KEY, or an API-key profile; passing a conflicting --api-key alongside the argument errors). Written to the agent config at 0600.
  • API URL defaults to https://api.smith.langchain.com (now documented in --api-url and setup help). Self-hosted endpoints (--api-url / $LANGSMITH_ENDPOINT) are expressed for Claude Code as a CC_LANGSMITH_RUNS_ENDPOINTS replica.
  • Project is only written when --project (or $LANGSMITH_PROJECT / $LANGSMITH_AGENT_PROJECT) is set. When unset the key is deleted — including stale values on re-runs — so each plugin's own default (claude-code / codex) stays the single source of truth. Both plugins treat an empty string as an explicit value, hence delete-not-write.
  • Claude Code config uses the CC_LANGSMITH_* namespace exclusively; declares the marketplace + enables the plugin (installs on next launch, no shell-out). Codex enables plugin_hooks and the tracing plugin in config.toml; one manual codex plugin marketplace add is printed.
  • Config writes are idempotent JSON/TOML merges that preserve unrelated keys.

Test plan

  • go test ./internal/cmd -run TestSetup — 10 tests: settings/credential merge + permissions, positional-key defaults (no project key written), stale-project removal on re-run, key-conflict error, self-hosted replica JSON with/without projectName, missing-key error, idempotency, setup all smoke.
  • Verified end-to-end against throwaway config dirs: bare setup claude <key> writes only TRACE_TO_LANGSMITH + CC_LANGSMITH_API_KEY (plugin defaults apply), --project/--api-url variants write the expected keys.
  • Known pre-existing flake (unrelated, reproduces on main): TestTraceMessages_Pagination can deadlock via the captureStdout pipe helper; fix tracked separately.

Paarth Ahuja (paarth-a) and others added 2 commits June 4, 2026 16:55
Adds `langsmith setup {claude,codex,all}` to persistently configure the
LangSmith tracing plugins for coding agents. Writes the agent's local config
at 0600 (Claude Code settings.json marketplace/enabledPlugins/env; Codex
config.toml + langsmith.json) and best-effort installs the plugin marketplace,
so every future agent session traces to a LangSmith project. Requires an API
key (OAuth profiles are not supported by these plugins).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- accept the API key as a positional argument on setup claude/codex/all
  (langsmith setup claude <api-key> is the whole quick start); a conflicting
  --api-key errors out
- stop writing a project name unless --project or $LANGSMITH_PROJECT is set:
  the CC_LANGSMITH_PROJECT / codex project keys are deleted when unset so the
  plugins' own defaults (claude-code / codex) stay the single source of truth,
  including on re-runs that drop a previously configured project
- move Claude Code to the CC_LANGSMITH_* env contract only; self-hosted
  endpoints are expressed as a CC_LANGSMITH_RUNS_ENDPOINTS replica (omitting
  projectName when no project is configured)
- drop the --no-install marketplace prefetch shell-out; Claude Code installs
  the declared plugin on next launch
- document the default API URL (https://api.smith.langchain.com) in --api-url
  and setup help; refresh README and rewrite setup tests for the new behavior

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant