Skip to content

fix(anthropic): capture sampling params from extra_body - #480

Draft
walleseve wants to merge 2 commits into
open-telemetry:mainfrom
walleseve:fix/anthropic-extra-body-sampling
Draft

fix(anthropic): capture sampling params from extra_body#480
walleseve wants to merge 2 commits into
open-telemetry:mainfrom
walleseve:fix/anthropic-extra-body-sampling

Conversation

@walleseve

@walleseve walleseve commented Aug 25, 2026

Copy link
Copy Markdown

Why

Anthropic SDK 1.x removed temperature, top_p, and top_k from its typed method signatures while retaining them through extra_body. The instrumentation ignored that mapping, so these request attributes disappeared from telemetry. Fixes #471.

What

Fall back to numeric sampling values from extra_body when their named arguments are absent. Add extractor unit tests and make the existing sync/async coverage assert sampling attributes on both supported SDK generations.

Why the approach

For backward compatibility reasons, when conflicting values are supplied in both locations, the code ensures that the original named values win:

Validation

  • Anthropic latest: 166 passed, 2 skipped
  • Anthropic oldest: 159 passed, 9 skipped
  • Anthropic conformance: 5 skipped (weaver binary unavailable locally; CI installs it)
  • tox -e typecheck
  • tox -e precommit

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • Followed the style guidelines of this project
  • Changelog updated if the change requires an entry
  • Unit tests added
  • Documentation updated

@linux-foundation-easycla

linux-foundation-easycla Bot commented Aug 25, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

@walleseve
walleseve force-pushed the fix/anthropic-extra-body-sampling branch from 98fa68e to 2579ad0 Compare August 25, 2026 20:15
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.

anthropic >= 1.0: capture sampling params passed via extra_body

1 participant