Gemini Live: agent stays "speaking" without audio output
I maintainer di solito rispondono entro 1 giorno
Una pull request collegata è già stata integrata.
- #7869 di @Luke-salinero — integrata
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 68/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- python
- Ambito
- ai-infra-agents
Direzione di ricerca
Il bug si trova in AgentActivity._realtime_generation_task_impl, dove la transizione di ritorno a listening si trova all'interno del ramo if audio_output is not None:. Confrontalo con il percorso LLM della pipeline, che reimposta lo stato senza output audio, e verifica dove viene chiamato _update_agent_state. Il lavoro è completato quando una risposta realtime solo testuale termina in listening (o in thinking se restano discorsi in background), con un test che copra una sessione senza output audio.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Bug Description
In a session without audio output, a realtime model's reply leaves the agent state at speaking. It never goes back to listening. Clients that take turns on lk.agent.state hang after the first realtime reply. Our text-mode interviews and our simulation harness are both affected.
In AgentActivity._realtime_generation_task_impl, the transition back to listening sits inside if audio_output is not None:. A text-only session has no audio output, so it never takes that branch. The pipeline (STT-LLM-TTS) path resets the state without an audio output, so the two paths behave differently.
Expected Behavior
After a realtime generation finishes, the agent state goes to listening, or to thinking while background speeches remain, whether or not the session has an audio output. This matches the pipeline LLM path.
Reproduction Steps
1. Set LIVEKIT_API_KEY and LIVEKIT_API_SECRET and run the script below. No room is needed.
2. Compare the pipeline LLM with the two realtime models.
import asyncio, sys
from livekit.agents import Agent, AgentSession, inference
async def run(model):
is_realtime = model in ("google/gemini-3.8-live", "openai/gpt-realtime-2.1")
llm = inference.RealtimeModel(model, modalities=["text"]) if is_realtime else inference.LLM(model)
session = AgentSession(llm=llm)
states = []
session.on("agent_state_changed", lambda ev: states.append(ev.new_state))
await session.start(agent=Agent(instructions="You are a friendly interviewer."))
await session.generate_reply(instructions="Ask the user one short question.")
await asyncio.sleep(2)
print(f"=== {model}: states {states} -> final {session.agent_state!r}")
await session.aclose()
for m in sys.argv[1:]:
asyncio.run(run(m))
# python repro.py google/gemma-4-31b-it google/gemini-3.8-live openai/gpt-realtime-2.1
Output:
=== google/gemma-4-31b-it: states ['listening', 'thinking', 'speaking', 'listening'] -> final 'listening'
=== google/gemini-3.8-live: states ['listening', 'speaking'] -> final 'speaking'
=== openai/gpt-realtime-2.1: states ['listening', 'speaking'] -> final 'speaking'
The reply text is delivered in every case. Only the state is stuck, and it happens with both realtime providers.
Operating System
macOS 15
Models Used
LiveKit Inference: google/gemini-3.8-live, openai/gpt-realtime-2.1 (realtime, modalities=["text"]); google/gemma-4-31b-it as the pipeline comparison
Package Versions
livekit-agents==1.8.8
# also present on main (597e6b49)
Session/Room/Call IDs
No response
Proposed Solution
# In AgentActivity._realtime_generation_task_impl, update the agent state whether or not
# there's an audio output, and keep only the audio-specific work under the check:
self._session._update_agent_state("thinking" if self._background_speeches else "listening")
if audio_output is not None:
self._on_end_of_agent_speech(ended_at=time.time())
if self.interruption_enabled:
self.interruption_by_audio_activity_enabled = True
current_span.set_attribute(trace_types.ATTR_SPEECH_INTERRUPTED, speech_handle.interrupted)
Additional Context
Text-only realtime sessions are useful when the realtime model's text output is spoken by a separate TTS, or when the same agent serves both voice and text interviews. The only workaround we've found is setting the state to listening through the private _update_agent_state when a realtime reply finishes without an audio output.
Screenshots and Recordings
No response
- Lingua principale
- Python
- Stelle
- 14.6k
- Fork
- 3.9k
- Merge medio
- 3g 3h
- PR unite (30g)
- 199
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di livekit/agents
-
Assistant markup is stripped from chat history when expressive mode is offForse già presa @ShivamSharma43 l’ha presa 17 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
docs: openai.LLM vs openai.responses.LLM for HTTP OpenAI-compat hostsForse di nuovo libera @AbarnaaSree l’ha presa 57 giorni fa e non c’è nessuna pull request aperta. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
livekit/agents#7022 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
I maintainer di solito rispondono entro 1 giorno
-
TranslationRoomIO: unset_track() before a track is linked stalls startup, so the translation is never publishedForse già presa @RaphaelFakhri l’ha presa 1 giorno fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 20/100
livekit/agents#8114 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Python AgentServer health check (GET /) returns 200 before the worker has registered with LiveKitForse già presa @ninglinLiu l’ha presa 2 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
livekit/agents#8092 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di livekit/agents
Issue simili
-
README.zh-CN/ja/es still hard-code 501 test counts after README.md went count-freeForse già presa @Aaqibhafeezkhan l’ha presa oggi. Apertabeginner documentation good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
BistaDinesh03/critique#164 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
bug IO
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
MrNeRF/LichtFeld-Studio#3824 ·
I maintainer di solito rispondono entro 1 giorno
-
bug confirmed issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
open-webui/open-webui#33200 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Lychee link check failedAperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
-
The changelog workflow excludes otelbot but not dependabot, so every Dependabot pull request fails the changelog checkForse già presa @ocelotl l’ha presa oggi. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
open-telemetry/opentelemetry-python#5825 ·
I maintainer di solito rispondono entro 2 giorni