Skip to content

[Feature]: Standard Gemini Live WebSocket (/ws/...BidiGenerateContent), ContextUpdate, and waitingForInput #358

Done

Description

@lawrancehoy-cyber

想要什么,用来做什么 / What you want and what for

想要什么,用来做什么 / What you want and what for

Add compatibility for official Gemini Live SDK clients (@google/genai, google-genai, LiveKit, Pipecat) plus missing Live session frames observed in current AI Studio web traffic:

Standard Gemini Live WebSocket path (BidiGenerateContentClientMessage JSON)

Official SDKs connect to /ws/google.ai.generativelanguage.v1beta.GenerativeService.BidiGenerateContent (currently handled only on /v1/live with custom payload or rejected on /v1beta/models/*:bidiGenerateContent with 400).
Supporting standard setup, clientContent, realtimeInput, and toolResponse JSON messages on the WebSocket endpoint allows unmodified official Gemini Live clients to connect directly.

Mid-session ContextUpdate (WebChannel outer field 9)

AI Studio now supports updating systemInstruction and tools mid-session without tearing down the WebSocket:
Outer message field 9: [tools, null, systemInstruction] (where systemInstruction is [[[null, text]]] and tools uses the standard EncodeTools array).
WAA proof binding string concatenates systemInstruction text and tool names/descriptions separated by spaces.
Also note EncodeBuildBidiSetup in internal/aistudio/build_bidi.go currently passes bidiVariantConversation unconditionally; routing by model/mode would keep Build/Applet Live aligned with EncodeBidiSetup.

Background thinking waitingForInput (serverContent field 8)

When thinkingLevel (LOW / MEDIUM / HIGH) is active in Live sessions, serverContent[8] (waitingForInput boolean) indicates the model is waiting for user input vs. finishing background reasoning. Exposing this flag in live server events helps clients manage turn state and barge-in.

版本 / Version

v0.3.16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    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