evals(v4): OTEL provider + LangSmith gating (unwired) - #2758
Open
miguelg719 wants to merge 1 commit into
Open
Conversation
|
Contributor
There was a problem hiding this comment.
1 issue found across 3 files
Confidence score: 3/5
- In
packages/evals/framework/langsmith.ts,assertLangSmithReady()currently throws genericErrors and includes required environment-variable names, which can leak configuration details in logs and makes callers harder to handle reliably with typed error flows; switch to a dedicated typed configuration error and sanitize outward-facing messages while keeping detailed diagnostics internal.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/evals/framework/langsmith.ts">
<violation number="1" location="packages/evals/framework/langsmith.ts:24">
P2: Custom agent: **Exception and error message sanitization**
`assertLangSmithReady()` raises generic `Error` instances and exposes the required environment-variable names. Throw a dedicated typed configuration error with a sanitized message instead.</violation>
</file>
Architecture diagram
sequenceDiagram
participant App as Evals App
participant Gating as langsmith.ts (Transport Gating)
participant OTEL as otel.ts (Tracer Provider)
participant NodeTracer as NodeTracerProvider
participant Braintrust as Braintrust Processor
participant LangSmith as LangSmith Exporter
participant Harness as External Harness (claude_code/codex)
participant Stagehand as Stagehand 4.0 RPC
Note over App,Stagehand: OTEL Tracing Transport Setup
App->>Gating: resolveTraceTransport()
alt EVAL_TRACE_TRANSPORT=otel
Gating-->>App: "otel"
App->>OTEL: buildTracerProvider()
opt BRAINTRUST_API_KEY set
OTEL->>Braintrust: Configure BraintrustSpanProcessor
Note over Braintrust: project = stagehand (CI) or stagehand-dev
end
opt LANGSMITH_TRACING="true" AND API key set
OTEL->>LangSmith: Configure LangSmithOTLPTraceExporter
end
OTEL->>NodeTracer: provider.register() (GLOBAL)
Note over NodeTracer: Captures Stagehand 4.0 RPC spans
NodeTracer-->>Stagehand: Global tracer registration
alt No LangSmith API key
OTEL-->>App: THROW: Missing API key error
else LANGSMITH_TRACING != "true"
OTEL-->>App: THROW: Tracing not enabled error
end
else default (native)
Gating-->>App: "native"
Note over App: No OTEL setup, native path unchanged
end
Note over App,Harness: Runtime Spans
alt OTEL transport active
App->>OTEL: withHarnessAgentSpan({harness, model, task})
OTEL->>OTEL: create span agent.{harness} with 200kB JSON caps
OTEL->>Harness: execute agent run
alt Success
Harness-->>OTEL: result with _success
OTEL->>OTEL: set output.value + output.mime_type
OTEL-->>App: return result
else Error
Harness-->>OTEL: throws
OTEL->>OTEL: recordException + SpanStatusCode.ERROR
OTEL-->>App: re-throw
end
else native transport
App->>Harness: execute directly (no OTEL span)
end
Note over App,Stagehand: Shutdown
App->>OTEL: shutdownTracing()
OTEL->>NodeTracer: forceFlush() + shutdown()
alt flush/shutdown success
NodeTracer-->>OTEL: flushed
else timeout (10s)
OTEL->>OTEL: reject, swallow error (never masks eval result)
end
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
miguelg719
force-pushed
the
miguelgonzalez/evals-v4-otel-transport
branch
from
August 17, 2026 19:46
7a624a5 to
d57fb05
Compare
miguelg719
force-pushed
the
miguelgonzalez/evals-v4-otel-transport
branch
from
August 17, 2026 20:03
d57fb05 to
ac1cdd4
Compare
miguelg719
force-pushed
the
miguelgonzalez/evals-v4-otel-transport
branch
from
August 17, 2026 21:03
ac1cdd4 to
91981d7
Compare
miguelg719
force-pushed
the
miguelgonzalez/evals-v4-otel-transport
branch
from
August 17, 2026 22:05
91981d7 to
eb7fbf1
Compare
miguelg719
force-pushed
the
miguelgonzalez/evals-v4-otel-transport
branch
from
August 17, 2026 22:07
eb7fbf1 to
86b4611
Compare
miguelg719
force-pushed
the
miguelgonzalez/evals-v4-otel-transport
branch
from
August 17, 2026 22:34
86b4611 to
5f39300
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Stack 2/6. Adds the tracing transport surface; no call sites yet.
What
framework/langsmith.ts: transport gating (EVAL_TRACE_TRANSPORT= native (default) | otel).framework/otel.ts: NodeTracerProvider (Braintrust processor + LangSmith exporter) with globalprovider.register()so Stagehand 4.0 native RPC spans are captured;withHarnessAgentSpanhelper. Only builds/registers under otel — native path untouched..env.example: LangSmith +EVAL_TRACE_TRANSPORTvars.Testing
typecheck + unit + build green.
Base: #2757
Summary by cubic
Adds an OpenTelemetry tracing transport for evals, enabling export to Braintrust and LangSmith. Old behavior: native-only tracing. New behavior: when EVAL_TRACE_TRANSPORT="otel", a global
NodeTracerProvideris registered and spans export to configured sinks; defaults remain and no call sites yet.LANGSMITH_TRACING="true"andLANGSMITH_API_KEYorLANGCHAIN_API_KEY.NodeTracerProvider(@opentelemetry/sdk-trace-node) with BraintrustBraintrustSpanProcessor(@braintrust/otel) and optional LangSmith OTLP exporter (langsmith/experimental/otel/exporter); registers globally to capture Stagehand RPC spans; caps JSON span attributes at 200kB; addsshutdownTracing(10s timeout) andresetTracingStateForTests.withHarnessAgentSpanwraps external harness runs in a span; no-op unless OTEL is active.EVAL_TRACE_TRANSPORT="otel". For Braintrust, setBRAINTRUST_API_KEY(optionalBRAINTRUST_OTEL_PARENT/BRAINTRUST_OTEL_URL). For LangSmith, setLANGSMITH_TRACING="true"and provide an API key..env.exampledocuments these.Written for commit 5f39300. Summary will update on new commits.