Skip to content

Anthropic: extended thinking config not captured in span metadata #107

@AbhiPrasad

Description

Gap

When users enable extended thinking via the thinking parameter (e.g., thinking={"type": "enabled", "budget_tokens": 10000}), this configuration is not captured in span metadata. The thinking parameter is absent from METADATA_PARAMS in the Anthropic wrapper.

The thinking content blocks in the response ARE captured in span.output (since the full content array is logged), and token usage is correct (Anthropic counts thinking tokens within output_tokens). The gap is that the thinking configuration itself — whether it was enabled, the budget, and the type — is invisible in span metadata.

This matters because extended thinking is a major Anthropic feature (required for Claude Opus, configurable for Sonnet) and users need visibility into how they configured it across different traces.

What is missing

Add "thinking" to METADATA_PARAMS (line 30 of anthropic.py) so the thinking configuration is logged as span metadata.

Braintrust docs status

not_found — the Anthropic integration page at braintrust.dev/docs/integrations/ai-providers/anthropic does not mention extended thinking.

Upstream sources

Local files inspected

  • py/src/braintrust/wrappers/anthropic.py:
    • METADATA_PARAMS (line 30-40): includes model, max_tokens, temperature, top_k, top_p, stop_sequences, tool_choice, tools, stream — but NOT thinking
    • _start_span() extracts only params listed in METADATA_PARAMS into span metadata
  • py/src/braintrust/wrappers/test_anthropic.py — no test cases for extended thinking configuration

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions