Skip to content

[BOT ISSUE] Google GenAI: Interactions API not instrumented #198

@braintrust-bot

Description

@braintrust-bot

Summary

The Google GenAI Interactions API (client.interactions.*) is not instrumented. This is a publicly documented Beta API (available since google-genai SDK v1.55.0) that provides a unified interface for agentic applications with server-managed conversation state, background execution, and tool orchestration.

The Interactions API is distinct from the Live API tracked in #125. The Live API is WebSocket-based real-time bidirectional streaming; the Interactions API is a request/response API for server-managed agentic conversations where the server handles conversation history, tool execution, and multi-turn state.

What is missing

The following client.interactions.* methods produce zero Braintrust tracing:

Method Description
client.interactions.create() Create and execute an interaction (the primary inference call)
client.interactions.get() Retrieve a completed interaction
client.interactions.cancel() Cancel an in-progress interaction
client.interactions.delete() Delete an interaction

At minimum, interactions.create() should be instrumented with:

  • Interaction-level span: Capturing model config, input content, output content, token usage, and duration
  • Tool use spans: The Interactions API supports function calling, Google Search grounding, code execution, and MCP tools — tool calls and results should appear as nested spans
  • Multi-turn linkage: The API uses previous_interaction_id for server-side conversation state management; this relationship should be captured in span metadata to enable trace-level visibility into multi-turn conversations

Key distinguishing features from generate_content

  • Server manages conversation state via previous_interaction_id (no client-side history resending)
  • Supports long-running/background execution (e.g., Deep Research agent)
  • Supports streaming via the same create() call
  • Has its own content types (ToolCallContent, GoogleMapsContent, etc.)
  • Returns interaction status (COMPLETE, INCOMPLETE, etc.)

Current instrumentation coverage

Google GenAI Method Instrumented?
models.generate_content() Yes
models.generate_content_stream() Yes
models.embed_content() Yes
models.generate_images() Yes
aio.live.connect() No (#125)
interactions.create() No
interactions.get() No

Braintrust docs status

not_found — the Gemini integration page documents generate_content, streaming, function calling, structured outputs, thinking tokens, context caching, and grounding, but does not mention the Interactions API.

Upstream sources

Local files inspected

  • py/src/braintrust/integrations/google_genai/patchers.py — defines 8 patchers (4 sync + 4 async) for generate_content, generate_content_stream, embed_content, generate_images; zero references to interactions
  • py/src/braintrust/integrations/google_genai/tracing.py — wrapper functions for the 4 patched method families; no interactions wrapper
  • py/src/braintrust/integrations/google_genai/integration.py — integration class registers the 8 patchers; no interactions patcher
  • py/src/braintrust/integrations/google_genai/test_google_genai.py — no interactions test cases
  • py/noxfile.pytest_google_genai(latest) session exists but does not test interactions

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions