fix(aio): enable multimodal for PostHog Desktop - #74135
Merged
carlos-marchal-ph merged 2 commits intoJul 28, 2026
Merged
Conversation
Generated-By: PostHog Code Task-Id: 2b999b3c-3652-4b53-a9fa-ded25207d1e2
Generated-By: PostHog Code Task-Id: 2b999b3c-3652-4b53-a9fa-ded25207d1e2
Contributor
|
Reviews (1): Last reviewed commit: "fix(aio): route llm-gateway captures ont..." | Re-trigger Greptile |
richardsolomou
approved these changes
Jul 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
services/llm-gateway— the separate deploy unit (ownpyproject.toml/uv.lock) backinggateway.{region}.posthog.comforposthog_code,background_agents,posthog_ai,slack_app,conversations,wizard,review_hog,array,bedrock, andllm_gateway— never joined the AI capture lane rollout in #73448/#73950. It pinnedposthoganalytics>=3.0.0(resolved to7.4.2, six minors behind), and its single capture call site never set_use_ai_lane/_enable_multimodal_capture.Bumping the SDK and setting those two flags on the constructed client turned out not to be enough on its own. The public
Posthog.capture()method always routes to the plain analytics lane regardless of_use_ai_lane— the SDK only reaches the dedicated AI lane (the endpoint the S3 multimodal-blob-offload ingestion pipeline consumes from) through the internal_capture_ai()method, dispatched viaposthoganalytics.ai.utils._capture_ai_event(). Every other capture site fixed by #73448/#73950 goes through the SDK's own AI-wrapper classes (posthoganalytics.ai.openai.OpenAI, the LangChainCallbackHandler, etc.), which call that dispatcher internally.services/llm-gatewaybuilds its$ai_generationproperties by hand from LiteLLM's logging object and called the plainclient.capture(...), bypassing it entirely — so the flags were set but nothing ever read them.Net effect: multimodal content proxied through this gateway (e.g. a screenshot sent by a PostHog Code agent session) never reached the AI ingestion pipeline, so it never got the S3 blob offload that direct-SDK traffic already gets — it stayed as a raw, uncapped base64 blob inline in the captured event.
Changes
posthoganalyticsto>=7.30.1, with anexclude-newer-packageoverride so this service's 7-dayexclude-newerwindow doesn't reject a same-day release (mirrors the override on the rootpyproject.toml)._use_ai_lane=Trueand_enable_multimodal_capture=Trueon thePosthog(...)client inPostHogCallback._capture_to_destination(callbacks/posthog.py).client.capture(**capture_kwargs)for_capture_ai_event(client, **capture_kwargs)in the same method — the actual fix that gets these events routed onto the AI lane.test_on_success_captures_event's constructor assertion to match.How did you test this code?
uv run pytest(fullservices/llm-gatewaysuite): 1371 passed, 50 skipped, 30 xfailed, 22 xpassed.uv run ruff check ./uv run ruff format --check .: clean.llm-analytics-apps/scripts/test_multimodal_passthrough.py's pattern as a direct-SDK baseline:_enable_multimodal_capture=True): resultingai_eventsrow carries aphaiblob://pointer, no inline base64 — confirms the local offload pipeline is live._capture_ai_eventfix: raw base64 stayed inline (451,826 chars).phaiblob://pointer, 317 chars — matches the direct-SDK result.Automatic notifications
Docs update
No doc references this rollout switch.
🤖 Agent context
Autonomy: Human-driven (agent-assisted) — assign @carlos-marchal-ph as DRI.
Found while auditing, with Carlos, which AI capture paths landed on the new multimodal lane after #73950. Initial fix (SDK bump + the two flags) turned out to be necessary but insufficient — local end-to-end testing via PostHog Code showed generations from the same conversation still carrying raw, unoffloaded base64 images. Traced it to
Posthog.capture()never checking_use_ai_lane; only_capture_ai_event()/_capture_ai()do. Verified the gap and the fix empirically against a local PostHog instance usingllm-analytics-apps' multimodal test scripts as a direct-SDK comparison point.