Skip to content

fix(tracing): record finish reasons and leave success status unset - #2056

Open
agustin18 wants to merge 1 commit into
anthropics:mainfrom
agustin18:fix/tracing-finish-reasons-status
Open

agustin18 wants to merge 1 commit into
anthropics:mainfrom
agustin18:fix/tracing-finish-reasons-status

Conversation

@agustin18

Copy link
Copy Markdown

Fixes #2055

Records gen_ai.response.finish_reasons beside anthropic.message.stop_reason when the response has a stop reason. Also stops setting StatusCode.OK on successful spans, following the OpenTelemetry guidance to leave span status unset unless there is an error.

This applies to API calls, streamed bodies, work spans, tool-runner spans, and tool-use spans. Tests now assert UNSET on success and the new finish-reasons attribute.

Verification

  • uv run pytest tests/test_open_telemetry.py tests/lib/tools/test_open_telemetry.py tests/lib/environments/test_poller_method.py tests/lib/environments/test_worker.py -q -n0: 1085 passed, 4 skipped
  • ./scripts/lint: ruff, dependency caps, pyright and import check passed

@agustin18
agustin18 requested a review from a team as a code owner November 3, 2026 16:28

This branch has not been deployed

No deployments
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.

Built-in tracing: no gen_ai.response.finish_reasons, and status OK on success

1 participant