-
Notifications
You must be signed in to change notification settings - Fork 167
chore(openai): use SpanAttributes.EMBEDDING_INVOCATION_PARAMETERS #2431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(openai): use SpanAttributes.EMBEDDING_INVOCATION_PARAMETERS #2431
Conversation
35592bb to
a83c407
Compare
...-instrumentation-openai-agents/src/openinference/instrumentation/openai_agents/_processor.py
Outdated
Show resolved
Hide resolved
...-instrumentation-openai-agents/src/openinference/instrumentation/openai_agents/_processor.py
Outdated
Show resolved
Hide resolved
a83c407 to
87bdaa8
Compare
This reverts commit a18078b.
Remove hardcoded constant and outdated TODO comment. Use the official SpanAttributes.EMBEDDING_INVOCATION_PARAMETERS constant that was released in semantic conventions v0.1.25. Bump openinference-semantic-conventions from >=0.1.23 to >=0.1.25.
…uteValue compatibility Handle edge cases where FunctionCallOutput and ResponseCustomToolCallOutputParam contain complex output types (lists, dicts) that don't match AttributeValue type. Serialize these to JSON strings while preserving None and string values.
87bdaa8 to
7d97d96
Compare
| yield f"{prefix}{MESSAGE_ROLE}", "tool" | ||
| yield f"{prefix}{MESSAGE_TOOL_CALL_ID}", obj["call_id"] | ||
| if (output := obj.get("output")) is not None: | ||
| output = obj["output"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Missing key existence check for output field
The function directly accesses obj["output"] without checking if the key exists, which could raise a KeyError if the field is optional. The old code used obj.get("output") for safe access, and the similar function _get_attributes_from_response_custom_tool_call_output_param checks if "output" in obj: before accessing. This inconsistency could cause runtime errors if FunctionCallOutput ever has a missing output key.
Remove hardcoded constant and outdated TODO comment. Use the official SpanAttributes.EMBEDDING_INVOCATION_PARAMETERS constant that was released in semantic conventions v0.1.25.
Bump openinference-semantic-conventions from >=0.1.23 to >=0.1.25.
Note
Serializes non-string tool outputs into
message.contentfor agents and switches OpenAI instrumentation to the officialEMBEDDING_INVOCATION_PARAMETERSattribute (bumping semantic conventions).custom_tool_call_outputandfunction_call_outputnow setmessage.content; non-string outputs are JSON-serialized viasafe_json_dumps.SpanAttributes.EMBEDDING_INVOCATION_PARAMETERS.openinference-semantic-conventionsto>=0.1.25.warn_unused_ignoresfortests.test_span_attribute_helpers.Written by Cursor Bugbot for commit 7d97d96. This will update automatically on new commits. Configure here.