feat(evals): add LangSmith gating helpers + config (no behavior change) - #2351
feat(evals): add LangSmith gating helpers + config (no behavior change)#2351miguelg719 wants to merge 3 commits into
Conversation
|
There was a problem hiding this comment.
All reported issues were addressed across 7 files
Confidence score: 5/5
- Safe to merge after the addressed issues were fixed.
Architecture diagram
sequenceDiagram
participant Env as Environment
participant Welcome as welcomeStatus.ts
participant Doctor as doctor.ts
participant LangSmith as framework/langsmith.ts
participant Braintrust as framework/braintrust.ts
Note over Env,Braintrust: NEW: LangSmith gating + config (no runtime behavior change)
Welcome->>Env: snapshotEnv(): read LANGSMITH_API_KEY
Env-->>Welcome: value
Welcome->>Welcome: NEW: providerEntry("LANGSMITH_API_KEY") -> EnvSnapshot.langsmith
Welcome->>Braintrust: (unchanged) snapshot BRAINTRUST_API_KEY
Doctor->>Env: buildReport(): read EVAL_TRACE_PRIMARY (default "braintrust")
Doctor->>Env: read LANGSMITH_API_KEY, BRAINTRUST_API_KEY
Env-->>Doctor: values
Doctor->>Doctor: computeVerdict(keys, config, discovery, tracePrimary)
alt CHANGED: No experiment backend (both missing)
Doctor->>Doctor: Warn: “No experiment backend configured”
else CHANGED: Primary backend missing
Doctor->>Doctor: Warn: “EVAL_TRACE_PRIMARY=… but required key missing”
else Both present
Doctor->>Doctor: OK / warn only on BB partial
end
Note over LangSmith: NEW: gating helpers (not yet imported in hot path)
LangSmith->>Env: hasLangSmithApiKey(): Boolean(LANGSMITH_API_KEY)
LangSmith->>Env: langSmithTracingEnabled: key && LANGSMITH_TRACING==="true"
LangSmith->>Env: resolveTraceTransport(): defaults to "native" unless "otel"
LangSmith->>LangSmith: loadLangSmith(): lazy dynamic import (memoized)
LangSmith->>LangSmith: assertLangSmithReady(): throws on missing key or tracing flag
Note over Welcome,Doctor: No hot-path change: new module (langsmith.ts) is not referenced by any caller yet
Note over Env: NEW: .env.example entries: LANGSMITH_API_KEY, LANGSMITH_TRACING, EVAL_TRACE_TRANSPORT, EVAL_TRACE_PRIMARY
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 5 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
8be875a to
53043c6
Compare
Unrelated to this stack — main's #2373 landed this file unformatted, so the repo-wide `turbo run lint` job fails on every PR rebased onto current main. Formatting it here (stack base) unblocks CI for the whole stack.
…langsmith-gating # Conflicts: # packages/cli/src/lib/cloud/reduce-logs.ts
|
Superseded by the Stagehand 4.0 retarget stack (#2757–#2762). Main moved to the 4.0 monorepo restructure (packages/core → packages/sdk-ts; evals package restructured), so this 3.x-era diff no longer applies. The OTEL/LangSmith tracing work — plus native-span capture via 4.0's global tracer and claude_code/codex agent spans — is reimplemented additively on 4.0 in the new stack. |
why
First step of an opt-in OTEL trace transport that fans eval traces out to Braintrust and LangSmith. This PR adds only the gating/config surface — zero behavior change.
what changed
framework/langsmith.ts(new):hasLangSmithApiKey,langSmithTracingEnabled(key +LANGSMITH_TRACING=true), lazyloadLangSmith,assertLangSmithReady,resolveTraceTransport()(defaultnative)langsmithdependency;LANGSMITH_API_KEYrows indoctor+ welcome status (incl.EVAL_TRACE_PRIMARYdefault fix);.env.exampleblock;CONTRACT.md(invariants for the stack)test plan
tests/tui/doctor.test.tsStack 1/5 → next: #2352
Summary by cubic
Adds LangSmith gating and config for an opt-in trace transport that can send eval traces to Braintrust and LangSmith. No runtime behavior changes; default transport is
native, and experiments still require Braintrust.framework/langsmith.tshelpers:hasLangSmithApiKey,langSmithTracingEnabled(readsprocess.envat call time),resolveTraceTransport(native|otel, defaultnative), lazyloadLangSmith,assertLangSmithReady.doctorand welcome status surfaceLANGSMITH_API_KEY;doctorwarns when no experiment backend is set, when the selectedEVAL_TRACE_PRIMARYkey is missing, whenEVAL_TRACE_PRIMARYis unrecognized, and whenEVAL_TRACE_PRIMARY=langsmithbutLANGSMITH_TRACINGis not "true"..env.exampleaddsLANGSMITH_API_KEY,LANGSMITH_TRACING,EVAL_TRACE_TRANSPORT,EVAL_TRACE_PRIMARY(defaultbraintrust).langsmithdependency.Written for commit 36d7164. Summary will update on new commits.