Skip to content

Conversation

@kirsten-emak
Copy link
Contributor

@kirsten-emak kirsten-emak commented Jan 1, 2026

Description

When a realtime model (e.g., Gemini with dynamic thinking enabled) sends a generation with no audio output and no tool calls (i.e. a thinking-only turn), the agent would remain stuck in an intermediate and unrecoverable state, unable to process new user input. This fix ensures the agent state returns to 'listening' when a generation completes without executing any tools and without being interrupted, allowing the VAD to resume normal operation.

Changes Made

  • Added state recovery logic in agent_activity.ts to return agent to "listening" state when a generation completes without executing any tools
  • Ensures proper state transitions even for thinking-only turns (where the model reasons internally without producing audio output)
  • Gracefully handles cases where speechHandle.interrupted is false to allow normal state recovery

Pre-Review Checklist

  • Build passes: All builds (lint, typecheck, tests) pass locally
  • AI-generated code reviewed: Removed unnecessary comments and ensured code quality
  • Changes explained: All changes are properly documented and justified above
  • Scope appropriate: All changes relate to the PR title, or explanations provided for why they're included
  • Video demo: A small video demo showing changes works as expected and did not break any existing functionality using Agent Playground (if applicable) - not applicable

Testing

  • Tested with Gemini 2.5 Flash live native audio 12-2025 with dynamic thinking, proactivity and affective dialog enabled
  • Verified VAD resumes properly after thinking-only generation
  • No regression in normal tool call handling
  • Agent properly returns to listening state in all scenarios
  • All tests pass
  • Make sure both restaurant_agent.ts and realtime_agent.ts work properly (for major changes) - the change is specifically related to fixing realtime agent behaviour

Additional Notes

N/A


Note to reviewers: Please ensure the pre-review checklist is completed before starting your review.

When a realtime model (e.g., Gemini with dynamic thinking enabled) sends a generation with no audio output and no tool calls (i.e. a thinking-only turn), the agent would remain stuck in an intermediate state, unable to process new user input.
This fix ensures the agent state returns to 'listening' when a generation completes without executing any tools and without being interrupted, allowing the VAD to resume normal operation.
@changeset-bot
Copy link

changeset-bot bot commented Jan 1, 2026

🦋 Changeset detected

Latest commit: fd4fa8a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 16 packages
Name Type
@livekit/agents Patch
@livekit/agents-plugin-anam Patch
@livekit/agents-plugin-baseten Patch
@livekit/agents-plugin-bey Patch
@livekit/agents-plugin-cartesia Patch
@livekit/agents-plugin-deepgram Patch
@livekit/agents-plugin-elevenlabs Patch
@livekit/agents-plugin-google Patch
@livekit/agents-plugin-inworld Patch
@livekit/agents-plugin-livekit Patch
@livekit/agents-plugin-neuphonic Patch
@livekit/agents-plugin-openai Patch
@livekit/agents-plugin-resemble Patch
@livekit/agents-plugin-rime Patch
@livekit/agents-plugin-silero Patch
@livekit/agents-plugins-test Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@CLAassistant
Copy link

CLAassistant commented Jan 1, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@toubatbrian toubatbrian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

@toubatbrian toubatbrian merged commit 710688b into livekit:main Jan 5, 2026
5 of 6 checks passed
@github-actions github-actions bot mentioned this pull request Jan 5, 2026
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.

3 participants