Skip to content

feat(openai-agents) GenAI semconv compliance#3823

Open
max-deygin-traceloop wants to merge 7 commits intomax/tlp-1925-python-sdk-otel-semantic-conventionfrom
max/tlp-1928-openai-agents-insturmentation
Open

feat(openai-agents) GenAI semconv compliance#3823
max-deygin-traceloop wants to merge 7 commits intomax/tlp-1925-python-sdk-otel-semantic-conventionfrom
max/tlp-1928-openai-agents-insturmentation

Conversation

@max-deygin-traceloop
Copy link

Migrate openai-agents instrumentation to OTel GenAI semconv

Aligns the OpenAI Agents SDK instrumentation with the upstream OpenTelemetry GenAI
semantic conventions.

Changes:

  • Replace all SpanAttributes.LLM_* constants with upstream
    GenAIAttributes.GEN_AI_* equivalents
  • Migrate flat gen_ai.prompt.{i}.* / gen_ai.completion.{i}.* attributes to
    gen_ai.input.messages / gen_ai.output.messages JSON arrays
  • Migrate flat gen_ai.tool.definitions.{i}.* attributes to gen_ai.tool.definitions
    JSON array
  • Fix 5 duplicate gen_ai.operation.name dict keys in _hooks.py
  • Fix duplicate gen_ai.system key in _realtime_wrappers.py
  • Update all tests to use new attribute names and JSON array format

@coderabbitai
Copy link

coderabbitai bot commented Mar 18, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 495172ec-7ecc-486d-b85a-56c5b508103f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch max/tlp-1928-openai-agents-insturmentation
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@max-deygin-traceloop max-deygin-traceloop changed the title Max/tlp 1928 OpenAI agents insturmentation feat(openai-agents) GenAI semconv compliance Mar 18, 2026
@max-deygin-traceloop max-deygin-traceloop force-pushed the max/tlp-1925-python-sdk-otel-semantic-convention branch from 740ee81 to 6401889 Compare March 18, 2026 11:06
@max-deygin-traceloop max-deygin-traceloop force-pushed the max/tlp-1928-openai-agents-insturmentation branch 2 times, most recently from 60cb4f7 to 82e355e Compare March 18, 2026 14:12
@CLAassistant
Copy link

CLAassistant commented Mar 18, 2026

CLA assistant check
All committers have signed the CLA.

@max-deygin-traceloop max-deygin-traceloop force-pushed the max/tlp-1928-openai-agents-insturmentation branch 4 times, most recently from 749f737 to 40c18fb Compare March 18, 2026 14:54
SpanAttributes.LLM_REQUEST_TYPE: "response",
GenAIAttributes.GEN_AI_SYSTEM: "openai",
GenAIAttributes.GEN_AI_OPERATION_NAME: "response",
GenAIAttributes.GEN_AI_SYSTEM: "openai",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, after double checking it, we should put only GEN_AI_PROVIDER_NAME as system is deprecated

SpanAttributes.LLM_REQUEST_TYPE: "chat",
GenAIAttributes.GEN_AI_SYSTEM: "openai",
GenAIAttributes.GEN_AI_OPERATION_NAME: "chat",
GenAIAttributes.GEN_AI_SYSTEM: "openai",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

SpanAttributes.LLM_REQUEST_TYPE: "realtime",
GenAIAttributes.GEN_AI_SYSTEM: "openai",
GenAIAttributes.GEN_AI_OPERATION_NAME: "speech",
GenAIAttributes.GEN_AI_SYSTEM: "openai",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

SpanAttributes.LLM_REQUEST_TYPE: "realtime",
GenAIAttributes.GEN_AI_SYSTEM: "openai",
GenAIAttributes.GEN_AI_OPERATION_NAME: "transcription",
GenAIAttributes.GEN_AI_SYSTEM: "openai",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

SpanAttributes.LLM_REQUEST_TYPE: "realtime",
GenAIAttributes.GEN_AI_SYSTEM: "openai",
GenAIAttributes.GEN_AI_OPERATION_NAME: "speech_group",
GenAIAttributes.GEN_AI_SYSTEM: "openai",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

context=parent_context,
attributes={
SpanAttributes.LLM_REQUEST_TYPE: "realtime",
GenAIAttributes.GEN_AI_OPERATION_NAME: "realtime",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

attributes={
SpanAttributes.LLM_REQUEST_TYPE: "realtime",
SpanAttributes.LLM_SYSTEM: "openai",
GenAIAttributes.GEN_AI_OPERATION_NAME: "realtime",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

max-deygin-traceloop and others added 7 commits March 19, 2026 16:32
…LM_ → GEN_AI_

- Replace SpanAttributes.LLM_REQUEST_TYPE with GenAIAttributes.GEN_AI_OPERATION_NAME
- Replace SpanAttributes.LLM_REQUEST_FUNCTIONS with GenAIAttributes.GEN_AI_TOOL_DEFINITIONS
- Replace SpanAttributes.LLM_SYSTEM with GenAIAttributes.GEN_AI_SYSTEM
- Replace SpanAttributes.LLM_USAGE_TOTAL_TOKENS with SpanAttributes.GEN_AI_USAGE_TOTAL_TOKENS
- Add test_semconv_compliance.py and [tool.uv.sources] for local semconv_ai

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…l definitions to JSON array

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…en test constants, remove duplicate GEN_AI_SYSTEM key

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ssage format

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ve orphaned completion.tool.* attrs

- _realtime_wrappers.py: replace flat gen_ai.prompt.*/gen_ai.completion.* in
  create_llm_span() with GEN_AI_INPUT_MESSAGES/GEN_AI_OUTPUT_MESSAGES JSON arrays
- _hooks.py: remove gen_ai.completion.tool.{name,type,strict_json_schema} sub-attributes
  from FunctionSpanData handler (tool name already captured via GEN_AI_TOOL_NAME)
- tests: update test_realtime_session.py assertions to parse JSON array attributes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…, remove AgentSpanData misfeature

- _hooks.py: remove misplaced catch-all 'elif span_data:' that was shadowing
  SpeechSpanData, TranscriptionSpanData, SpeechGroupSpanData, and AgentSpanData branches
- _hooks.py: remove AgentSpanData handler that incorrectly propagated model settings
  to agent spans (test spec: agent spans must NOT carry gen_ai.request.* params)
- _hooks.py: replace hardcoded "openai.agent.model.frequency_penalty" with
  GenAIAttributes.GEN_AI_REQUEST_FREQUENCY_PENALTY constant
- tests: fix dead "llm.usage.*" prefix check, fix vestigial "gen_ai.prompt" scan,
  fix hardcoded frequency_penalty string, fix long line in test_realtime_session.py

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@max-deygin-traceloop max-deygin-traceloop force-pushed the max/tlp-1928-openai-agents-insturmentation branch from 40c18fb to db6adb2 Compare March 19, 2026 14:32
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.

4 participants