Skip to content

[bot] Anthropic Managed Agents (beta.agents / beta.sessions) not instrumented in Java SDK #157

Description

@braintrust-bot

Summary

Anthropic's Managed Agents API (/v1/agents, /v1/environments, /v1/sessions, plus vaults/memory_stores) launched in public beta on 2026-04-08 and is officially supported by the Anthropic Java SDK (anthropic-sdk-java), which this repo's anthropic_2_2_0 module wraps. None of these endpoints are instrumented — only the standard Messages API (messages().create()) is traced.

Braintrust's own docs already document agents/sessions tracing for the sibling Python and TypeScript SDKs, but explicitly do not for Java, confirming this is a real, product-visible gap rather than an unsupported/deprecated surface.

What is missing

The Anthropic Java SDK exposes these beta service clients under client.beta.*, confirmed to exist in the current anthropic-sdk-java source tree (anthropic-java-core/src/main/kotlin/com/anthropic/services/blocking/beta/):

  • AgentService / AgentServiceImpl (formerly agents.create()/agents.retrieve()/agents.list() — persisted, versioned agent configs: model, system prompt, tools, mcp_servers, skills)
  • SessionService / SessionServiceImpl (sessions.create() — starts a session that streams agent-loop events back to the caller; requires an agent reference and environment_id)
  • Sibling EnvironmentService, VaultService/CredentialService, MemoryStoreService under the same beta namespace

None of these are referenced anywhere in dev.braintrust.instrumentation.anthropic. The current instrumentation (TracingHttpClient in anthropic_2_2_0, dispatched through InstrumentationSemConv.tagAnthropicRequest/tagAnthropicResponse) only recognizes the standard /v1/messages request/response shape. Managed Agents endpoints use a different beta header (anthropic-beta: managed-agents-2026-04-01) and a different event-stream protocol (session turn events, user.message/user.define_outcome initial events), so a session's actual work — agent loop iterations, tool execution inside the sandbox, state transitions — produces no spans at all when driven through this SDK.

Braintrust docs status

Checked https://www.braintrust.dev/docs/integrations/ai-providers/anthropic directly:

  • Python: documents tracing "the Anthropic SDK's messages, batches, and managed agents APIs," with an explicit span table row for anthropic.beta.agents.*, anthropic.beta.sessions.*supported
  • TypeScript: documents anthropic.beta.sessions.turn / anthropic.beta.sessions.thread.turn spans and a collectAnthropicSession helper to opt streamed session events into span collection → supported
  • Java: the Java section only describes "Braintrust emits spans for the Anthropic Messages API" with a single span table row ("Anthropic Messages API spans" / messages().create(), including streaming) — no mention of agents, sessions, environments, or beta namespaces → not_found

Upstream sources

Local files inspected

  • braintrust-sdk/instrumentation/anthropic_2_2_0/src/main/java/dev/braintrust/instrumentation/anthropic/v2_2_0/ — no reference to agents, sessions, environments, beta, or managed-agents anywhere in the module
  • braintrust-sdk/src/main/java/dev/braintrust/instrumentation/InstrumentationSemConv.javatagAnthropicRequest/tagAnthropicResponse only handle the standard /v1/messages request/response JSON shape; no handling for session-turn event streams or agent/environment resource payloads
  • Full-repo grep for beta.agents, beta.sessions, ManagedAgent, AgentService, SessionService — zero matches

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions