Skip to content

fix(deps): bump openai sdk to 2.30.0 for python 3.14 - #107918

Merged
trunk-io[bot] merged 1 commit into
masterfrom
posthog-self-driving/fixdeps-bump-openai-sdk-to-fix-python-f10c7b
Sep 28, 2026
Merged

trunk-io[bot] merged 1 commit into
masterfrom
posthog-self-driving/fixdeps-bump-openai-sdk-to-fix-python-f10c7b

Conversation

@posthog

@posthog posthog Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Problem

  • PostHog AI runs can crash on OpenAI-backed steps since the Python 3.14.7 bump (#94402).
  • The pinned openai==1.109.1 sets __discriminator__ on a typing.Union object when it decodes a discriminated union, for example some Responses API stream events.
  • Python 3.14 does not allow attributes on typing.Union, so the call raises AttributeError every time. The whole graph run stops, starting from MaxChatOpenAI in ee/hogai/llm.py.
  • Upstream fixed this in openai 2.x (openai/openai-python#2704).

Origin

  • Error tracking: issue
  • First signal: 2026-09-28
  • Inbox report: open
  • Likely cause: fc32d80
  • Task started by: auto-start, after the report was rated P1 and ready to fix

Changes

  • Root pin moves from openai==1.109.1 to openai==2.30.0. This is the version that services/llm-gateway already locks.
  • langchain-openai~=0.3.35 accepts openai 2.x, so the lock resolves with no other package change.
  • Only uv.lock changes otherwise. No application code changes.

Warning

This is a major SDK bump. Every backend caller of openai gets 2.x. The repo uses only stable client, error and chat-type imports, but CI is the real check for the rest of the call sites.

How did you test this code?

  • Called _build_discriminated_union_meta on ResponseStreamEvent on Python 3.14.7: 1.109.1 raises the reported AttributeError, 2.30.0 returns the discriminator details.
  • Ran hogli test ee/hogai/test/test_llm.py locally on 2.30.0. It passes.
  • Not tested: a live PostHog AI run against OpenAI.

Release status

  • No feature flag controls this change
  • This change is behind a feature flag and is not available to users
  • This change makes a previously flagged feature available to everyone

Automatic notifications

  • Publish to changelog?

Docs update

None.

🤖 Agent context

Autonomy: Fully autonomous

Agent: PostHog Desktop (Claude Code), claude-opus-5-5

  • No duplicate: an open-PR search for openai found no other SDK bump.
  • Chose the version that services/llm-gateway already uses, not the minimum fixed version (2.7.2), to keep one openai version across the repo.
  • Public artifact: the diff has only the pin and lock changes. No session material is in it.

Created with PostHog Desktop from this inbox report.

🤖 Generated with Claude Code

openai 1.109.1 sets __discriminator__ on a typing.Union object when it decodes a discriminated union. Python 3.14 rejects this with an AttributeError, so some Responses API stream events crash PostHog AI runs. openai 2.x does not set this attribute. langchain-openai 0.3.35 accepts openai 2.x, so it stays as is.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Generated-By: PostHog Desktop
Task-Id: 41e21d99-ef8f-401a-a931-8ba6bdfd9a65
@posthog posthog Bot added the self-driving label Sep 28, 2026
@posthog
posthog Bot marked this pull request as ready for review September 28, 2026 17:57
@trunk-io

trunk-io Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

😎 Merged successfully - details.

@posthog

posthog Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor Author

🦔 PostHog Review reviewed this pull request

Nothing worth raising this time. Enjoy the moment:

The dancing man in the red room from Twin Peaks

@stamphog stamphog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Not approved yet — waiting on the conditions below.

Re-add the stamphog label to request another review once you have addressed this.

This pull request was refused automatically by stamphog's deterministic policy gates. The deny-list gate failed on deps_toolchain, since this PR modifies pyproject.toml and uv.lock to bump the openai dependency, and dependency/toolchain pin changes are categorically excluded from automated approval. It was also flagged by the tier gate as T2-never, a fix-classified change that is never eligible for autonomous merge regardless of its small size. These are hard policy stops, not judgments on the change's correctness; a human reviewer will need to evaluate and merge this pull request manually.

Gate mechanics and policy version
Gate Result
prerequisites ✓ all clear
deny-list ✗ matches: deps_toolchain
size ✓ 2L, 1F substantive, 30L/2F incl. docs/generated/snapshots — within ceiling
tier ✗ classified as T2-never: T2-never (30L, 2F, single-area, fix)
stamphog 2.2.0 .stamphog/policy.yml @ unknown · reviewed head f7444f4

@stamphog stamphog Bot added the reviewhog ($$$) Reviews pull requests before humans do label Sep 28, 2026
@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

🤖 CI report

⚠️ Trunk lane — backend Python lane

This PR is assigned to the backend Python lane. It runs backend Python tests and may merge in parallel with PRs in other lanes.

✅ Playwright — all passed

All tests passed.

View test results →

✅ Hobby preview — passed

Hobby deployment smoke test passed successfully.


Run 36461770550

@coderabbitai

coderabbitai Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: PostHog/posthog/.coderabbit.yaml

Review profile: QUIET

Plan: Enterprise

Run ID: 4be1e72f-d7cf-44c1-88e4-ffff2f6c3a9b

📥 Commits

Reviewing files that changed from the base of the PR and between 14e6387 and f7444f4.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (1)
  • pyproject.toml

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 5 remain after this review.


📝 Walkthrough

Walkthrough

The pinned openai dependency version in pyproject.toml changes from 1.109.1 to 2.30.0.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to f7444

The gateway’s synchronous and asynchronous clients remain compatible with the upgraded SDK. No concrete merge-blocking regression was established; the change is ready for normal checks.

Architecture Summary

Architecture risk: 🔵 Low · up to f7444

The change affects 1 system.

Changed systems: pyproject.toml

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — pyproject.toml (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in pyproject.toml: The pinned openai dependency version changes from 1.109.1 to 2.30.0.
🚥 Pre-merge checks | ✅ 1
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The description includes the required Problem, Changes, testing, release status, notification, docs, and agent context sections. It clearly explains the Python 3.14.7 failure, the OpenAI SDK upgrade, …
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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

@posthog posthog Bot removed the reviewhog ($$$) Reviews pull requests before humans do label Sep 28, 2026
@trunk-io

trunk-io Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Static Badge   Static Badge   Static Badge

View Full Report ↗︎ ⋅ Docs

@rnegron
rnegron requested review from a team September 28, 2026 19:03

@rnegron rnegron left a comment

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.

lgtm, v2 breaking change seems to be around unused logic but will defer to AI teams for merging

@andrewm4894

Copy link
Copy Markdown
Member

/trunk merge

@trunk-io
trunk-io Bot merged commit fed94aa into master Sep 28, 2026
397 of 474 checks passed
@trunk-io
trunk-io Bot deleted the posthog-self-driving/fixdeps-bump-openai-sdk-to-fix-python-f10c7b branch September 28, 2026 21:11
@deployment-status-posthog

deployment-status-posthog Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-09-28 21:37 UTC Run
prod-us ✅ Deployed 2026-09-28 21:48 UTC Run
prod-eu ✅ Deployed 2026-09-28 21:48 UTC Run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants