Skip to content

Support Gemini's stateful Interactions API (interactions:create) #136

@tombeckenham

Description

@tombeckenham

Summary

Add record/replay support for Gemini's Interactions API — the stateful conversation endpoint at:

POST https://generativelanguage.googleapis.com/v1beta/{parent=*}/interactions

This is the Gemini equivalent of OpenAI's Responses API: the server retains conversation transcripts and callers pass previous_interaction_id to chain turns without resending history.

Docs: https://ai.google.dev/gemini-api/docs/interactions

Why

TanStack AI is shipping a geminiTextInteractions() adapter (TanStack/ai#501) that routes through this endpoint. The adapter-level unit tests are comprehensive, but the E2E suite currently has a test.skip(...) placeholder because aimock cannot record/replay this endpoint yet:

https://github.com/TanStack/ai/blob/main/testing/e2e/tests/stateful-interactions.spec.ts

Once supported here, the spec can cover the full two-turn chain:

  1. First call — capture the server-assigned interactionId from the SSE response.
  2. Second call — send previous_interaction_id and assert the model references context from turn 1 while the outbound request body omits prior history.

What's needed

  • Recognize POST /v1beta/**/interactions as a Gemini endpoint for fixture matching.
  • Capture the SSE event stream (interaction.start, content.start, content.delta with text / function_call / thought_summary payloads, content.stop, interaction.status_update, interaction.complete, error).
  • Replay including the server-assigned interactionId so adapters can round-trip it on the next fixture.
  • Ideally respect previous_interaction_id in fixture matching so chained turns replay distinct recorded responses.

Notes

  • The endpoint is currently in Beta per Google; event/request shapes may shift.
  • Scope that would cover TanStack AI's needs: text output + function tools. Built-in tools (google_search, code_execution, etc.) and non-text output via Interactions are not yet exercised by our adapter.

Happy to provide recorded fixtures from TanStack AI's dev environment if that helps bootstrap the implementation.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions