Skip to content

Add billing/cost warnings for Gemini Live API and implement session auto-kill / length cap #161

Description

@AchlysChang

Description

The system currently relies on Gemini Live API for interactive audio streaming. While the configured model (gemini-3-flash-live / gemini-3.1-flash-lite) is cost-effective for typical use, the continuous WebSocket audio/video stream consumes substantial Tokens unexpectedly fast (Audio Output Tokens + Context accumulation).

In my testing, a short session consumed over NT$500+ (~$16 USD) in API credits, quickly depleting prepaid balances. Since users might assume Flash/Lite models incur negligible costs, running an interview without cost awareness or automatic safeguards can lead to unexpected financial charges.

Observed Behavior

  • Unexpected High API Billing: Audio input/output tokens accumulate rapidly. Long sessions keep history context in memory, escalating token usage linearly.
  • Lack of Cost/Usage Safety Thresholds: There is no warning about real-time audio token costs before starting, nor an explicit auto-cleanup for idle/run-away background connections.

Diagnostic Observations

  • Input Tokens: ~270k tokens during peak usage.
  • Output Tokens: ~27k tokens (mostly Audio Output, which carries significantly higher pricing).
  • Unclosed or long-running WebSocket audio sessions can exhaust a small credit balance within an hour of active streaming.

Real-world Terminal Logs / Evidence

evidence: at=16:29.948 phase=coding accepted=true room=interview-mx7wt7we
interim review skipped: Gemini request rejected (status=402)
...
Gemini refused to resume (Gemini closed before setupComplete: code=1011 reason=Your prepayment credits are depleted...); starting a fresh session instead
...
Gemini could not be reached; ending interview room=interview-mx7wt7we

Suggested Behavior & Improvement Proposals

(Note: Excluded error messaging handling as it overlaps with #159 and #177. Focusing on cost warnings and bounds.)

  1. Pre-session Cost Warning: Display a clear notice in the setup screen informing candidates/interviewers that Gemini Live API consumes audio tokens continuously and requires an active paid API key / sufficient quota.
  2. Session Duration Cap & Auto-Disconnect: Implement a hard limit on the Live API session duration to prevent runaway costs. (The specific duration bounds and fallback behavior should be designed based on the existing contract in docs/provider-cost-and-degradation.md).
  3. Text-Only Modality Toggle: Provide an option to disable Audio Output and rely on TEXT modality instead, which serves as a cost-saving or fallback mechanism. This toggle should also align with the degradation guidelines in docs/provider-cost-and-degradation.md.

Activity

  1. changed the title [-][Feature / Safety] Add billing/cost warnings for Gemini Live API and implement session auto-kill / length cap[/-] [+]Add billing/cost warnings for Gemini Live API and implement session auto-kill / length cap[/+] on Sep 28, 2026
  2. jserv commented on Sep 28, 2026

    @jserv
    Contributor

    Do not add [Feature / Safety] or similar labels to the subject, as maintainers can classify them on demand.

  3. jserv commented on Sep 29, 2026

    @jserv
    Contributor

    Item 4 here overlaps #159, which asks for the same thing: an actionable quota and billing message in the browser, and an end to the reconnect loop once the provider has reported a billing failure. #177 then proposes the concrete mechanism for showing it, carrying the reason on the existing interviewer_state message.

    Suggest narrowing this issue to what is unique to it and has no other thread: the pre-session cost warning, the maximum session duration with auto-disconnect, and the text-only modality toggle. The error messaging can then be settled once in #159 and #177 instead of three times.

    What an interview may spend and what bounds a misbehaving provider are owned by docs/provider-cost-and-degradation.md. A duration cap and a modality toggle are changes to that contract, so the proposal should start from what the document already says rather than from a number chosen here.

  4. AchlysChang commented on Oct 12, 2026

    @AchlysChang
    Author

    Thanks @jserv for the guidance.

    I will start by addressing the first part of this issue in a separate, small Pull Request: implementing the pre-session cost warning notification.

    I have reviewed docs/provider-cost-and-degradation.md to ensure the warning limits and logic align with the repository guidelines.

    I am currently working on a topic branch for this feature. Could you please assign this issue to me?

  5. jserv commented on Oct 12, 2026

    @jserv
    Contributor

    @AchlysChang A pull request for the pre-session cost warning alone is welcome. Base its wording on what docs/provider-cost-and-degradation.md already says rather than on a number chosen in the PR, and end it with Refs #161, since the duration cap and the text-only toggle stay open here. No assignment is needed.

  6. jserv commented on Oct 20, 2026

    @jserv
    Contributor

    @AchlysChang The pre-session cost warning was accepted on 2026-10-12, and no pull request has appeared since. Is it still coming? If there is no reply by 2026-10-27, the assignment is removed and the issue stays open for anyone else to take, with Refs #161.

  7. AchlysChang commented on Oct 22, 2026

    @AchlysChang
    Author

    Hi @jserv,

    Thanks for checking in! I'm actively working on this feature in my local branch and finalizing the implementation based on docs/provider-cost-and-degradation.md.

    I will submit the PR in the next few days. Please keep the assignment with me. Thank you for your patience!

  8. jserv commented on Oct 22, 2026

    @jserv
    Contributor

    I will submit the PR in the next few days. Please keep the assignment with me. Thank you for your patience!

    Do reply in time, as effective collaboration.

  9. jserv commented on Oct 23, 2026

    @jserv
    Contributor

    #436 implements the pre-session cost warning and ends with Refs #161, so its merge leaves this issue open for the session length cap with auto-disconnect and the text-only toggle.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions