Skip to content

Bump openai to 2.52.0 and openai-agents to 0.19.1 - #288

Merged
anticomputer merged 1 commit into
mainfrom
anticomputer/openai-sdk-py314
Aug 3, 2026
Merged

anticomputer merged 1 commit into
mainfrom
anticomputer/openai-sdk-py314

Conversation

@anticomputer

@anticomputer anticomputer commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Problem

Under Python 3.14 every run that streams from the Responses API dies before the first task completes:

AttributeError: 'typing.Union' object has no attribute '__discriminator__'
  .../openai/_models.py:691 in _build_discriminated_union_meta
    cast(CachedDiscriminatorType, union).__discriminator__ = details

openai 1.107.0 memoises discriminated-union metadata by assigning an attribute onto the typing.Union object itself. Python 3.14 made typing.Union instances carry no __dict__, so the assignment raises. It fires from agents/models/openai_responses.py on the streaming path, meaning the agent is unusable on 3.14 with any api_type: responses model.

Upstream fixed this in openai 2.7.2 (openai/openai-python@15a7ec8, #2704) by moving the cache to a weakref.WeakKeyDictionary. The pinned openai-agents==0.2.11 requires openai<2, so both had to move together.

Change

pyproject.toml only:

package before after
openai 1.107.0 2.52.0
openai-agents 0.2.11 0.19.1
griffe 1.7.3
griffelib 2.1.0

openai-agents 0.19.1 depends on griffelib, which ships the same griffe import name that agents/function_schema.py uses. Since this file pins transitively, the stale griffe pin is replaced rather than left to dangle — leaving both installed lets whichever is uninstalled last clobber the shared griffe/ directory.

No source changes were needed; pip check reports no broken requirements and no other pin in the file drifted.

Validation

  • pytest: 556 passed, 2 skipped — unchanged from before the bump.

  • hatch fmt --linter --check: clean.

  • Live smoke run against CAPI on Python 3.14.5, one task per backend, all four returning normally where the first previously aborted with the AttributeError:

    slot model backend api_type
    general_tasks gpt-5.4 openai_agents responses
    hunt_claude claude-opus-5 anthropic_sdk messages
    hunt_gemini gemini-3.6-flash openai_agents chat_completions
    adjudication grok-4.5 openai_agents responses

pyproject.toml: openai 1.107.0 -> 2.52.0, openai-agents 0.2.11 -> 0.19.1.
openai 2.7.2 replaced the discriminated-union attribute cache in
openai/_models.py with a WeakKeyDictionary, which is what Python 3.14
requires now that typing.Union instances carry no __dict__.

Also swap griffe==1.7.3 for griffelib==2.1.0: openai-agents 0.19.1 depends
on griffelib, which supplies the same `griffe` import name.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: dadec5f9-3bf8-449c-84d6-db45be19bb6a
Copilot AI review requested due to automatic review settings July 31, 2026 18:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates the project’s pinned OpenAI SDK dependencies to versions compatible with Python 3.14 streaming on the Responses API, addressing the typing.Union discriminated-union metadata caching issue described in the PR.

Changes:

  • Bump openai from 1.107.0 to 2.52.0.
  • Bump openai-agents from 0.2.11 to 0.19.1.
  • Replace the griffe pin with griffelib to align with openai-agents’ newer dependency chain.
Show a summary per file
File Description
pyproject.toml Updates pinned dependency versions for openai/openai-agents and swaps griffegriffelib to match the upgraded agent SDK dependency set.

Review details

Tip

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

  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Lite

@anticomputer
anticomputer merged commit 31df912 into main Aug 3, 2026
10 checks passed
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