Repository navigation
fix(watsonx): record list prompts with GenAIAttributes.GEN_AI_PROMPT - #4709
Open
Ygormorais wants to merge 2 commits into
Open
Ygormorais wants to merge 2 commits into
Ygormorais wants to merge 2 commits into
Conversation
SpanAttributes.GEN_AI_PROMPT does not exist in opentelemetry.semconv_ai, so list prompts raised AttributeError, which @dont_throw swallowed: list prompts were silently dropped from the span and input events were not emitted. Use GenAIAttributes.GEN_AI_PROMPT (already imported; the documented replacement for LLM_PROMPTS) for the list and string branches. The attribute key is unchanged (gen_ai.prompt). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019vQj79oorBrk3jGJ9eumPM
Unit tests without cassettes or network: string prompt, list prompt as kwarg and list prompt passed positionally. The two list tests fail before the fix with AttributeError swallowed by @dont_throw. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019vQj79oorBrk3jGJ9eumPM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat(instrumentation): ...orfix(instrumentation): ....What
_set_input_attributesin the watsonx instrumentation usesSpanAttributes.GEN_AI_PROMPTwhen the prompt is a list:f"{SpanAttributes.GEN_AI_PROMPT}.{index}.user"opentelemetry.semconv_ai.SpanAttributeshas noGEN_AI_PROMPTmember (not in the published 0.5.1, not in the in-repo version), so this raisesAttributeError._handle_inputis wrapped in@dont_throw, so the error is swallowed. The result:model.generate(prompt=["a", "b"])) are silently missing from the span_emit_input_eventsis never reached for these calls, because it runs after the failing lineThis PR uses
GenAIAttributes.GEN_AI_PROMPT(already imported in the module, and the documented replacement forSpanAttributes.LLM_PROMPTSinsemconv-ai's MIGRATION.md) for the list branch, and for the string branch too, which usedLLM_PROMPTS. The attribute key staysgen_ai.prompt, so the string-prompt output is unchanged.I checked the latest
mainand the 150 most recent PR heads: none changes this line.Reproduction (before the fix)
Tests
Added
tests/traces/test_input_attributes.py(no cassettes, no network): string prompt, list prompt passed as kwarg, list prompt passed positionally.ruff check .clean🤖 Generated with Claude Code
https://claude.ai/code/session_019vQj79oorBrk3jGJ9eumPM
Summary by CodeRabbit