Skip to content

fix(ai)!: AI integrations require a client with capture_ai - #1048

Open
eli-r-ph wants to merge 2 commits into
v1-capture-api-fixesfrom
v1-ai-require-capture-ai
Open

eli-r-ph wants to merge 2 commits into
v1-capture-api-fixesfrom
v1-ai-require-capture-ai

Conversation

@eli-r-ph

@eli-r-ph eli-r-ph commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

💡 Motivation and Context

Stacked on #1046. An AI integration given a client without capture_ai fell back to capture. That skipped the AI endpoint and its 8 MiB limit, and the failure showed up late or silently, often after a paid provider call. This PR reports it at setup instead, without stopping the app.

Changes

  • Every AI integration logs one error at construction when its client has no callable capture_ai, and then captures no AI events; provider calls still work.
  • This covers the OpenAI, Azure OpenAI, Anthropic, Bedrock, Vertex and Gemini wrappers, the LangChain CallbackHandler, and the OpenAI Agents and Claude Agent SDK processors.
  • Client, AsyncPosthog and the default global client work as before.
  • Integration modules no longer re-export setup; patch posthog.ai.utils.setup in tests instead.
  • Migration guide and changeset updated.

💚 How did you test it?

  • A parameterized test builds all 15 entry points with a client that lacks capture_ai; each logs one error and never calls capture.
  • An OpenAI call through such a client returns the provider response.
  • The 16 new or changed failure tests fail against feat!: exception level, keyword-only args, uuid and geoip #1046 and pass here.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Written with Cursor (Claude Opus 5.5) under the direction of the assignee, who chose failing at setup over failing at send time.

🤖 Generated with Claude Code

@eli-r-ph eli-r-ph self-assigned this Oct 10, 2026
@eli-r-ph
eli-r-ph marked this pull request as ready for review October 10, 2026 21:51
@eli-r-ph
eli-r-ph requested a review from a team as a code owner October 10, 2026 21:51
@eli-r-ph
eli-r-ph force-pushed the v1-ai-require-capture-ai branch from dfa7894 to 585ce8b Compare October 10, 2026 23:35
@eli-r-ph
eli-r-ph force-pushed the v1-capture-api-fixes branch from 6982671 to 0c99129 Compare October 10, 2026 23:35
@eli-r-ph
eli-r-ph force-pushed the v1-ai-require-capture-ai branch from 585ce8b to 9a89fd0 Compare October 11, 2026 20:17
@eli-r-ph
eli-r-ph force-pushed the v1-capture-api-fixes branch from 0c99129 to 161a339 Compare October 11, 2026 20:17
@eli-r-ph eli-r-ph changed the title fix(ai): fail at setup when an AI integration's client lacks capture_ai fix(ai)!: AI integrations require a client with capture_ai Oct 13, 2026
Comment thread posthog/ai/utils.py Outdated
@eli-r-ph
eli-r-ph requested a review from dustinbyrne October 14, 2026 02:51
@eli-r-ph
eli-r-ph force-pushed the v1-ai-require-capture-ai branch from 9a89fd0 to 5ea139e Compare October 14, 2026 03:11
@eli-r-ph
eli-r-ph force-pushed the v1-capture-api-fixes branch from 161a339 to 5c57a86 Compare October 14, 2026 03:11
eli-r-ph and others added 2 commits October 13, 2026 20:48
Raising TypeError at construction could stop the host application over an
analytics problem. The integration now logs one error at setup and captures no
AI events; provider calls work and return normally.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@eli-r-ph
eli-r-ph force-pushed the v1-capture-api-fixes branch from 5c57a86 to d57b40f Compare October 14, 2026 03:48
@eli-r-ph
eli-r-ph force-pushed the v1-ai-require-capture-ai branch from 5ea139e to 81db481 Compare October 14, 2026 03:48
@eli-r-ph
eli-r-ph requested a review from a team October 14, 2026 15:45

This branch has not been deployed

No deployments
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.

2 participants