Skip to content

Python: make OpenAI omit sentinel import compatible across SDK versions#13547

Open
OiPunk wants to merge 1 commit intomicrosoft:mainfrom
OiPunk:codex/semantic-kernel-openai-omit-compat
Open

Python: make OpenAI omit sentinel import compatible across SDK versions#13547
OiPunk wants to merge 1 commit intomicrosoft:mainfrom
OiPunk:codex/semantic-kernel-openai-omit-compat

Conversation

@OiPunk
Copy link

@OiPunk OiPunk commented Feb 14, 2026

Summary

Fixes import compatibility for OpenAI SDK variants where openai._types exports NOT_GIVEN/NotGiven but not omit/Omit.

This addresses the runtime import failure reported in #13525.

Changes

  • Added python/semantic_kernel/connectors/ai/open_ai/_types_compat.py:
    • Uses Omit/omit when available.
    • Falls back to NotGiven/NOT_GIVEN when omit is unavailable.
  • Updated OpenAI integrations to import from the new compatibility module:
    • python/semantic_kernel/connectors/ai/open_ai/services/open_ai_handler.py
    • python/semantic_kernel/connectors/ai/open_ai/services/open_ai_text_to_image_base.py
    • python/semantic_kernel/agents/open_ai/assistant_thread_actions.py
    • python/semantic_kernel/agents/open_ai/openai_assistant_agent.py
  • Added regression tests:
    • python/tests/unit/connectors/ai/open_ai/test_openai_types_compat.py
      • verifies normal path (omit available)
      • verifies fallback path (NOT_GIVEN only)

Validation

  • uv run ruff check semantic_kernel/connectors/ai/open_ai/_types_compat.py semantic_kernel/connectors/ai/open_ai/services/open_ai_handler.py semantic_kernel/connectors/ai/open_ai/services/open_ai_text_to_image_base.py semantic_kernel/agents/open_ai/assistant_thread_actions.py semantic_kernel/agents/open_ai/openai_assistant_agent.py tests/unit/connectors/ai/open_ai/test_openai_types_compat.py
  • env -u ALL_PROXY -u all_proxy -u HTTPS_PROXY -u https_proxy -u HTTP_PROXY -u http_proxy -u NO_PROXY -u no_proxy uv run --with pandas pytest -q tests/unit/connectors/ai/open_ai/test_openai_types_compat.py
  • env -u ALL_PROXY -u all_proxy -u HTTPS_PROXY -u https_proxy -u HTTP_PROXY -u http_proxy -u NO_PROXY -u no_proxy uv run --with pandas pytest -q tests/unit/connectors/ai/open_ai/services/test_openai_text_to_image.py -k test_init

@OiPunk OiPunk requested a review from a team as a code owner February 14, 2026 09:13
@moonbox3 moonbox3 added the python Pull requests for the Python Semantic Kernel label Feb 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Pull requests for the Python Semantic Kernel

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants