Skip to content

[bot] Anthropic Beta.Messages (IBetaMessageService) execution calls are not instrumented #70

Description

@braintrust-bot

Summary

InstrumentedAnthropicClient instruments the regular Messages service but delegates the Beta service directly to the underlying client without any wrapping. As a result, all calls through client.Beta.Messages.Create() and client.Beta.Messages.CreateStreaming() — the endpoint used for beta-gated features such as computer use — bypass telemetry entirely and produce no spans.

What is missing

In InstrumentedAnthropicClient (src/Braintrust.Sdk.Anthropic/InstrumentedAnthropicClient.cs):

// line 90 — instrumented ✅
public IMessageService Messages => _instrumentedMessages;

// line 94 — NOT instrumented ❌
public IBetaService Beta => _client.Beta;

The IBetaService interface exposes Beta.Messages as an IBetaMessageService with the same execution methods as the regular messages service:

  • Beta.Messages.Create(BetaMessageCreateParams)/v1/messages with anthropic-beta: ... headers
  • Beta.Messages.CreateStreaming(BetaMessageCreateParams) → streaming variant

These methods are used for beta-gated Anthropic features, the most prominent being computer use (anthropic-beta: computer-use-2024-10-22), which lets Claude interact with desktop GUIs. Any user calling client.Beta.Messages.Create() (or its streaming variant) via a Braintrust-instrumented client gets:

  • No activity/span created
  • No input content captured
  • No output content captured
  • No token usage metrics recorded
  • No time_to_first_token measured

For comparison, the regular Messages endpoint is fully wrapped via InstrumentedMessageService.

Braintrust docs status

The Braintrust Anthropic integration docs at https://www.braintrust.dev/docs/integrations/ai-providers/anthropic explicitly list the Beta Messages API as a supported instrumentation surface:

  • For TypeScript: "anthropic.beta.messages.toolRunner" spans documented
  • For Python: Beta messages calls are described as auto-patched
  • For .NET: Only the regular Messages API is mentioned — Beta Messages are absent

Status: supported in TypeScript and Python SDKs; not_found for the C# SDK specifically.

Upstream sources

Local files inspected

  • src/Braintrust.Sdk.Anthropic/InstrumentedAnthropicClient.cs — line 90: Messages is wrapped by InstrumentedMessageService; line 94: Beta is an uninstrumented pass-through to _client.Beta
  • src/Braintrust.Sdk.Anthropic/InstrumentedMessageService.cs — reference implementation showing the instrumentation pattern (Create and CreateStreaming overrides) that would need to be replicated for IBetaMessageService
  • src/Braintrust.Sdk.Anthropic/Braintrust.Sdk.Anthropic.csproj — confirms Anthropic v12.5.0 dependency, which includes IBetaService

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions