Skip to content

fix(ai): preserve Gemini tool-call IDs in captures - #5087

Merged
marandaneto merged 2 commits into
PostHog:mainfrom
gouveags:fix/ai-gemini-tool-call-ids
Sep 24, 2026
Merged

marandaneto merged 2 commits into
PostHog:mainfrom
gouveags:fix/ai-gemini-tool-call-ids

Conversation

@gouveags

Copy link
Copy Markdown
Contributor

Problem

Gemini returns IDs for function calls, but @posthog/ai omits them from $ai_output_choices in both non-streaming and streaming generations. The live-provider cassettes in #5037 record call_649034 and call_388245; replaying them against the previous formatter reproduced the omission. This is the output-ID half of #5085.

Changes

  • Preserve Gemini's function-call ID in both output paths when present. Calls without an ID keep their existing shape.
  • Assert the IDs against the two recorded Gemini tool-call cassettes.
  • Add an @posthog/ai patch changeset.

The replay assertion failed for both tool-call cases before the fix and passes afterward (5/5). The package build, type check, 1,024 unit tests, 275 offline cassette tests, and package lint pass. No provider request or response behavior changes.

The automated draft #5086 also covers this issue. This PR isolates the output-ID change and its cassette proof; the follow-up-input fix is being reviewed separately.

Release info Sub-libraries affected

Libraries affected

  • @posthog/ai

Checklist

  • Tests for new code
  • Accounted for the impact of any changes across different platforms
  • Accounted for backwards compatibility of any changes (no breaking changes!)
  • Took care not to unnecessarily increase the bundle size
  • Added an @posthog/ai patch changeset

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

I directed the scope and reviewed the implementation with Codex. We used Vitest, the existing Gemini replay harness, and GitHub CLI. The first signed commit contains the failing test; the second contains the fix. No agent session link is shared because this private work session also includes unrelated workspace context. GitHub would not allow assigning my external account to this PR.

@gouveags
gouveags requested a review from a team as a code owner September 24, 2026 05:06
@gouveags

Copy link
Copy Markdown
Contributor Author

@greptileai review

@greptile-apps

greptile-apps Bot commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Retrigger

The PR appears safe to merge.

Reviews (1) · Last reviewed commit: "fix(ai): retain Gemini tool call IDs in ..."

@marandaneto marandaneto 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.

The code looks good; no qualifying findings. Verdict: correct.

@marandaneto
marandaneto requested a review from a team September 24, 2026 10:16
@marandaneto
marandaneto enabled auto-merge (squash) September 24, 2026 10:20
@marandaneto
marandaneto merged commit 2bce7b2 into PostHog:main Sep 24, 2026
63 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.

2 participants