Skip to content

fix: type-guard llm message role and content attributes - #4194

Merged
mikeldking merged 3 commits into
mainfrom
claude/ecstatic-pasteur-ixjd1m
Oct 29, 2026
Merged

mikeldking merged 3 commits into
mainfrom
claude/ecstatic-pasteur-ixjd1m

Conversation

@mikeldking

Copy link
Copy Markdown
Contributor

Carries #4172 by @Harsh23Kashyap over the line. Fixes #3859.

Changes

  • The original commit from fix: type-guard llm message role and content attributes #4172 (b99fafb), unchanged and with authorship kept: _llm_messages_attributes now yields role only when it is a string, and routes list-valued content into the typed message.contents.N.message_content.* channel when there is no explicit contents.
  • A merge of the latest main.
  • A follow-up test commit that fixes the two CI failures in tests/test_attributes.py:
    • ruff format: one assert is wrapped to fit the line length.
    • mypy: the four tests that pass deliberately malformed messages (a list as content, an int as role) now carry # type: ignore[typeddict-item], the same pattern other test suites in the repo use.

Verification

tox run -e py313-ci-instrumentation passes: format, lint, mypy and 8596 tests.

If #4172 is updated with the same fix commit, this PR can be closed in its favour.


Generated by Claude Code

Harsh23Kashyap and others added 3 commits October 28, 2026 00:47
List-valued message content (OpenAI-style content blocks) was yielded
into the string span attribute llm.input_messages.N.message.content,
which is not a valid OTEL AttributeValue, and non-string role values
were emitted likewise. Yield role only when it is a string, and route
sequence content into the typed message.contents blocks channel when
no explicit contents field is present. String content handling is
unchanged.

Fixes #3859
@mikeldking
mikeldking marked this pull request as ready for review October 29, 2026 23:52
@mikeldking
mikeldking requested a review from a team as a code owner October 29, 2026 23:52
@mikeldking
mikeldking merged commit 98aa84b into main Oct 29, 2026
170 checks passed
@mikeldking
mikeldking deleted the claude/ecstatic-pasteur-ixjd1m branch October 29, 2026 23:52
@mikeldking mikeldking mentioned this pull request Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

get_llm_input_message_attributes stores list-valued content in a string span attribute

3 participants