Skip to content

fix(voice): retry preemptive generation after a barge-in - #3134

Open
rosetta-livekit-bot[bot] wants to merge 1 commit into
mainfrom
restless-juices-fallout
Open

rosetta-livekit-bot[bot] wants to merge 1 commit into
mainfrom
restless-juices-fallout

Conversation

@rosetta-livekit-bot

@rosetta-livekit-bot rosetta-livekit-bot Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • retry the latest refused preemptive generation after blocking speech is interrupted and fully settled
  • preserve the transcript hook's async context and include interrupted replies and tool outputs in the retried request
  • cover barge-in, preflight, tool-context, lifecycle, and stale-generation scenarios

Ports livekit/agents#8892.

Testing

  • pnpm test agents (5,262 passed, 10 skipped)
  • pnpm build:agents
  • pnpm --filter @livekit/agents typecheck
  • pnpm --filter @livekit/agents lint
  • pnpm format:check

cue-cli framework-event validation could not be run because the binary is unavailable in the execution environment. The ported deterministic AgentSession regression suite validates the interruption lifecycle without external providers.

Source diff coverage

Source diff coverage

  • Adapted: livekit-agents/livekit/agents/voice/agent_activity.py -> agents/src/voice/agent_activity.ts. Ported refused-attempt tracking, callback cleanup, interrupted-task and current-transcript guards, stale-attempt replacement, turn/cancellation clearing, and hook-context preservation. Python contextvars.copy_context() maps to Node AsyncLocalStorage.snapshot(), and Python task completion maps to target Task.done.
  • Adapted: tests/test_agent_interruptions.py -> agents/src/voice/agent_activity_preemptive_pause_deadlock.test.ts. Ported every added scenario and parameterized case with the target's real AgentSession and SpeechHandle lifecycle plus a deterministic gated LLM, because the target has no Python FakeActions virtual-time harness. Coverage includes pause/no-pause barge-ins, interrupted tool results, preflight supersession, IGNORE_ON_ENTER context, interrupted and uninterrupted completion, cleared or extended transcripts, and stale-attempt replacement.
  • Not applicable: none.

Ported from livekit/agents#8892

Original PR description

A final transcript that barges in on agent speech skipped preemptive generation. With resume_false_interruption, the speech is paused but not yet interrupted when the hook runs, so the reply waited for the turn commit.

The refused attempt now retries once the interrupted speech is done, so its chat context includes the interrupted reply and tool results. Only the latest attempt retries, and only while its transcript is still current.

The issue report supplied the diagnosis and an offline reproduction.

Addresses AGT-4149

Initial prompt and agent context

Model: Claude Opus 5.5

Summary: investigate a reported issue where preemptive generation is skipped while agent speech is paused, implement a retry with tests, and revise it through several two-model code reviews.

@rosetta-livekit-bot
rosetta-livekit-bot Bot requested a review from a team as a code owner December 2, 2026 10:49
@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

This PR bumps

  • @livekit/agents: patch

Also bumped

  • @livekit/agents-plugin-anam: depends on @livekit/agents
  • @livekit/agents-plugin-anthropic: depends on @livekit/agents
  • @livekit/agents-plugin-assemblyai: depends on @livekit/agents
  • @livekit/agents-plugin-azure: depends on @livekit/agents
  • @livekit/agents-plugin-baseten: depends on @livekit/agents
  • @livekit/agents-plugin-bey: depends on @livekit/agents
  • @livekit/agents-plugin-cartesia: depends on @livekit/agents
  • @livekit/agents-plugin-deepgram: depends on @livekit/agents
  • @livekit/agents-plugin-did: depends on @livekit/agents
  • @livekit/agents-plugin-elevenlabs: depends on @livekit/agents
  • @livekit/agents-plugin-fishaudio: depends on @livekit/agents
  • @livekit/agents-plugin-google: depends on @livekit/agents
  • @livekit/agents-plugin-hume: depends on @livekit/agents
  • @livekit/agents-plugin-inworld: depends on @livekit/agents
  • @livekit/agents-plugin-krisp: depends on @livekit/agents
  • @livekit/agents-plugin-lemonslice: depends on @livekit/agents
  • @livekit/agents-plugin-liveavatar: depends on @livekit/agents
  • @livekit/agents-plugin-livekit: depends on @livekit/agents
  • @livekit/agents-plugin-meta: depends on @livekit/agents
  • @livekit/agents-plugin-minimax: depends on @livekit/agents
  • @livekit/agents-plugin-neuphonic: depends on @livekit/agents
  • @livekit/agents-plugin-nvidia: depends on @livekit/agents
  • @livekit/agents-plugin-openai: depends on @livekit/agents
  • @livekit/agents-plugin-phonic: depends on @livekit/agents
  • @livekit/agents-plugin-protoface: depends on @livekit/agents
  • @livekit/agents-plugin-resemble: depends on @livekit/agents
  • @livekit/agents-plugin-rime: depends on @livekit/agents
  • @livekit/agents-plugin-runway: depends on @livekit/agents
  • @livekit/agents-plugin-sarvam: depends on @livekit/agents
  • @livekit/agents-plugin-silero: depends on @livekit/agents
  • @livekit/agents-plugin-soniox: depends on @livekit/agents
  • @livekit/agents-plugin-speechify: depends on @livekit/agents
  • @livekit/agents-plugin-synthesia: depends on @livekit/agents
  • @livekit/agents-plugin-tavus: depends on @livekit/agents
  • @livekit/agents-plugin-trugen: depends on @livekit/agents
  • @livekit/agents-plugin-cerebras: depends on @livekit/agents, @livekit/agents-plugin-openai
  • @livekit/agents-plugin-mistralai: depends on @livekit/agents, @livekit/agents-plugin-silero
  • @livekit/agents-plugin-perplexity: depends on @livekit/agents, @livekit/agents-plugin-openai
  • @livekit/agents-plugin-xai: depends on @livekit/agents, @livekit/agents-plugin-openai
  • @livekit/agents-plugin-mistral: depends on @livekit/agents, @livekit/agents-plugin-mistralai

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔍 Devin Review: 2 flags

Not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)

Devin Review

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.

0 participants