Skip to content

Disable openai-v2 when agent-framework is used#142

Open
rads-1996 wants to merge 1 commit into
microsoft:mainfrom
rads-1996:fix-openai-v2-deps
Open

Disable openai-v2 when agent-framework is used#142
rads-1996 wants to merge 1 commit into
microsoft:mainfrom
rads-1996:fix-openai-v2-deps

Conversation

@rads-1996
Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings May 13, 2026 22:22
@rads-1996
Copy link
Copy Markdown
Member Author

Before -

image

After -

image

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR attempts to prevent duplicate/crashing OpenAI instrumentation by disabling openai auto-instrumentation when Agent Framework instrumentation is active.

Changes:

  • Adds _AGENT_FRAMEWORK_DISABLED_INSTRUMENTATIONS = ("openai",).
  • Updates instrumentation setup to auto-disable OpenAI when agent_framework is discovered.
  • Adds unit tests for Agent Framework/OpenAI instrumentation interactions.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/microsoft/opentelemetry/_constants.py Defines the Agent Framework-specific disabled instrumentation list.
src/microsoft/opentelemetry/_distro.py Applies the new auto-disable behavior during instrumentation discovery.
tests/test_distro.py Adds tests for OpenAI enable/disable behavior with Agent Framework present.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +712 to +718
if any(
ep.name == "agent_framework" and _is_instrumentation_enabled(otel_kwargs, ep.name)
for ep in discovered
):
inst_opts = otel_kwargs.setdefault(INSTRUMENTATION_OPTIONS_ARG, {})
for lib in _AGENT_FRAMEWORK_DISABLED_INSTRUMENTATIONS:
inst_opts.setdefault(lib, {}).setdefault("enabled", False)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This one sound serious

Comment on lines +716 to +718
inst_opts = otel_kwargs.setdefault(INSTRUMENTATION_OPTIONS_ARG, {})
for lib in _AGENT_FRAMEWORK_DISABLED_INSTRUMENTATIONS:
inst_opts.setdefault(lib, {}).setdefault("enabled", False)
@hectorhdzg
Copy link
Copy Markdown
Member

Is there a way to programmatically disable OpenAI Spans when using Microsoft Agent Framework?, if we decide to go with current approach, we should only change defaults, if customers explicitly config something on we should always honor that

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.

3 participants