feat(ai): capture gemini thought summaries as thinking blocks - #827
Open
fivestarspicy wants to merge 1 commit into
Open
feat(ai): capture gemini thought summaries as thinking blocks#827fivestarspicy wants to merge 1 commit into
fivestarspicy wants to merge 1 commit into
Conversation
Gemini parts marked thought=True were formatted as plain text blocks, so
reasoning was indistinguishable from the answer in LLM analytics. They now
become {"type": "thinking", "thinking": ...} blocks — the same shape the
Anthropic converter emits and the PostHog UI renders as reasoning — across
the response, input, and streaming-chunk paths.
Generated-By: PostHog Code
Task-Id: a7eb2477-e1b0-4c68-8933-cfb0b2f6b2b0
Open
1 task
Contributor
posthog-python Compliance ReportDate: 2026-08-03 19:50:15 UTC ✅ All Tests Passed!111/111 tests passed Capture_V1 Tests✅ 94/94 tests passed View Details
Feature_Flags Tests✅ 17/17 tests passed View Details
|
marandaneto
approved these changes
Aug 4, 2026
Radu-Raicea
approved these changes
Aug 4, 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.
💡 Motivation and Context
Gemini can return thought summaries when a request sets
thinking_config.include_thoughts=True, and the SDK already reportsthoughts_token_countas reasoning tokens — but the thought content was formatted as ordinary{"type": "text"}blocks, indistinguishable from the answer in LLM analytics. The Anthropic converter already emits{"type": "thinking", "thinking": ...}blocks, which the PostHog UI renders as reasoning; this brings the Gemini converter in line.Parts marked
thought=Truenow become thinking blocks in all three formatting paths: responses, inputs (multi-turn callers append prior model content, thoughts included, back into the conversation), and streaming chunks.Companion PostHog PR that makes a thinking block next to a Gemini-style
{"type": "function"}tool-call block render correctly: PostHog/posthog#76883💚 How did you test it?
posthog/test/ai/gemini/test_gemini_converter.pycovering the response, input, and streaming-chunk paths (each is a separate code path in the converter).ruff format --check,ruff check, andmypy(baseline-filtered) all clean.is Trueonpart.thoughtso loosely-specced mocks (whose.thoughtis a truthyMock) still land on the text branch — the existing mock-based wrapper tests stay green.📝 Checklist
If releasing new changes
sampo addto generate a changeset file🤖 Agent context
Autonomy: Human-driven (agent-assisted)
{"type": "thinking", "thinking": ...}is the block shape rendered as reasoning (the Anthropic recipe matches it per-block, provider-agnostically).include_thoughts.Created with PostHog Code