Skip to content

Block preemptive generation during tool execution#1369

Open
Genmin wants to merge 1 commit intolivekit:mainfrom
Genmin:fix/preemptive-generation-tool-execution
Open

Block preemptive generation during tool execution#1369
Genmin wants to merge 1 commit intolivekit:mainfrom
Genmin:fix/preemptive-generation-tool-execution

Conversation

@Genmin
Copy link
Copy Markdown
Contributor

@Genmin Genmin commented May 1, 2026

Summary

Prevents preemptive generation from starting while a previous speech handle is still executing function tools in the background.

_currentSpeech is cleared after the assistant generation/playout phase, before tool execution finishes. During that window a user EOU could previously start a preemptive reply from stale chat context, before the tool result had been inserted. The existing _backgroundSpeeches set already tracks that exact interval, so the preemptive guard now treats it as active work.

Fixes #1365.

Validation

  • pnpm vitest run agents/src/voice/agent_activity.test.ts
  • pnpm exec prettier --check agents/src/voice/agent_activity.ts agents/src/voice/agent_activity.test.ts
  • pnpm exec eslint -f unix agents/src/voice/agent_activity.ts agents/src/voice/agent_activity.test.ts (existing warnings only)
  • pnpm --filter @livekit/agents build
  • git diff --check

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 1, 2026

⚠️ No Changeset found

Latest commit: 30da8a1

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Copy Markdown
Contributor

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

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in 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.

Preemptive generation does not check in-flight function tool execution

2 participants