Skip to content

feat(evals v4): OTEL agent spans for claude_code/codex harnesses - #2761

Open
miguelg719 wants to merge 1 commit into
miguelgonzalez/evals-v4-otel-braintrustfrom
miguelgonzalez/evals-v4-otel-harness-spans
Open

feat(evals v4): OTEL agent spans for claude_code/codex harnesses#2761
miguelg719 wants to merge 1 commit into
miguelgonzalez/evals-v4-otel-braintrustfrom
miguelgonzalez/evals-v4-otel-harness-spans

Conversation

@miguelg719

@miguelg719 miguelg719 commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator

Why

Stack 5/6. External harnesses drive their own SDKs (claude-agent-sdk/codex-sdk) which emit no OTEL.

What

  • Wrap runClaudeCodeAgent/runCodexAgent in withHarnessAgentSpan so their runs nest an agent node under the eval task-root span — parity with the stagehand harness (whose native RPC spans flow in via the global provider).
  • No-op when EVAL_TRACE_TRANSPORT is unset.

Testing

Validated live: a claude_code run on Browserbase produced an 85-span LangSmith trace (task-root → agent.claude_code → native page/act/observe spans).

Base: #2760


Summary by cubic

Adds OpenTelemetry agent spans for the claude_code and codex harnesses so eval traces show a nested agent span under the task root. Previously these harnesses emitted no OTEL; now each run sets harness, model, task, and instruction span attributes without changing execution.

  • Wraps runClaudeCodeAgent/runCodexAgent with withHarnessAgentSpan in packages/evals/framework/benchHarness.ts.
  • No-op unless EVAL_TRACE_TRANSPORT is set; behavior matches the stagehand harness; no migration required.

Written for commit db1f171. Summary will update on new commits.

Review in cubic

@changeset-bot

changeset-bot Bot commented Aug 17, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: db1f171

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 1 file

Architecture diagram
sequenceDiagram
    participant Eval as Eval Runner
    participant Cli as claudeCodeHarness/codexHarness
    participant Span as withHarnessAgentSpan
    participant OTEL as OTEL/LangSmith
    participant Agent as claude-code/codex SDK

    Note over Eval,Agent: Runtime flow for external harnesses

    Eval->>Cli: execute plan
    Cli->>Cli: Prepare tool adapter, plan, signal, verifier

    alt EVAL_TRACE_TRANSPORT is set
        Cli->>Span: Wrap agent execution
        Span->>Span: Create agent span (attributes: harness, model, task, instruction)
        Span->>OTEL: Start agent span
        Span->>Agent: Execute runClaudeCodeAgent/runCodexAgent
        Agent-->>Span: Agent result
        Span->>OTEL: End agent span (attach to eval task-root)
        Span-->>Cli: Return result
    else EVAL_TRACE_TRANSPORT is unset
        Cli->>Agent: Execute runClaudeCodeAgent/runCodexAgent (no-op span)
        Agent-->>Cli: Agent result
    end

    Cli->>Cli: Run toolAdapter cleanup and deregister carrier
    Cli-->>Eval: Return task result

    Note over OTEL,Agent: Native page/act/observe spans from stagehand flow in via global provider
Loading

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread packages/evals/framework/benchHarness.ts
@miguelg719
miguelg719 force-pushed the miguelgonzalez/evals-v4-otel-harness-spans branch from 5ea3bad to 5987e13 Compare August 17, 2026 19:46
@miguelg719
miguelg719 force-pushed the miguelgonzalez/evals-v4-otel-harness-spans branch from 5987e13 to adfeb68 Compare August 17, 2026 20:03
@miguelg719
miguelg719 force-pushed the miguelgonzalez/evals-v4-otel-harness-spans branch from adfeb68 to 33dc9b5 Compare August 17, 2026 21:03
@miguelg719
miguelg719 force-pushed the miguelgonzalez/evals-v4-otel-harness-spans branch from 33dc9b5 to a380ea2 Compare August 17, 2026 22:05
@miguelg719
miguelg719 force-pushed the miguelgonzalez/evals-v4-otel-harness-spans branch from a380ea2 to 6496668 Compare August 17, 2026 22:07
@miguelg719
miguelg719 force-pushed the miguelgonzalez/evals-v4-otel-harness-spans branch from 6496668 to db1f171 Compare August 17, 2026 22:34
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