Skip to content

fix: retry connection pool prewarm after failure - #2378

Merged
davidzhao merged 1 commit into
mainfrom
port/connection-pool-prewarm-retry
Aug 30, 2026
Merged

fix: retry connection pool prewarm after failure#2378
davidzhao merged 1 commit into
mainfrom
port/connection-pool-prewarm-retry

Conversation

@rosetta-livekit-bot

@rosetta-livekit-bot rosetta-livekit-bot Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Port livekit/agents#6969 so a settled connection-pool prewarm no longer permanently suppresses later attempts. The target clears the matching prewarm controller when its asynchronous operation settles, allowing retry after failure while preserving in-flight deduplication and close-time cancellation.

Testing

  • pnpm test agents - 138 files passed, 2291 tests passed, 5 skipped
  • pnpm build - 40/40 tasks passed
  • pnpm lint - 40/40 tasks passed (existing warnings only)
  • pnpm format:check - passed
Source diff coverage

Authoritative source: livekit/agents#6969

  • livekit-agents/livekit/agents/utils/connection_pool.py: adapted to agents/src/connection_pool.ts. The TypeScript pool tracks an AbortController instead of a weak task reference, so the controller is cleared when the corresponding prewarm promise settles. An identity check prevents an older operation from clearing a newer controller after close/restart.
  • tests/test_connection_pool.py: adapted to agents/src/connection_pool.test.ts. The source retry-after-first-failure regression is ported with Vitest and asserts through the target public behavior because the TypeScript prewarm task is private and not returned.
  • Not applicable: none. Every source file has a target counterpart and was ported.

Ported from livekit/agents#6969

Original PR description

Summary

ConnectionPool.prewarm() records an in-flight task to suppress duplicate work. When that task completes or fails, the task reference was retained, so later prewarm calls permanently skipped the pool even though no prewarm operation was still running.

This change clears the completed task reference before deciding whether to return, allowing a later call to retry after failure or perform a fresh prewarm after completion. The patch is limited to the connection-pool lifecycle and adds a regression for retry-after-failure behavior.

Testing

  • uv run pytest tests/test_connection_pool.py --unit - 7 passed.
  • uv run ruff check livekit-agents/livekit/agents/utils/connection_pool.py tests/test_connection_pool.py - passed.
  • uv run ruff format --check livekit-agents/livekit/agents/utils/connection_pool.py tests/test_connection_pool.py - passed.
  • The core package strict mypy check passed before the final current-main rebase; the repository-wide make check format and lint stages pass on the current head. The repository-wide type stage remains blocked by the existing missing boto3 import in the experimental AWS realtime plugin, outside this patch.
  • git diff --check origin/main...HEAD - passed.

No external provider, LiveKit server, network credential, or integration account is required for this unit-level lifecycle regression.

The submitted commit is SSH-signed with the configured GitHub signing identity.

Compatibility

This is backward compatible. Successful prewarm behavior is unchanged; failed or completed prewarm tasks can now be retried instead of suppressing all future attempts.

@rosetta-livekit-bot
rosetta-livekit-bot Bot requested a review from a team as a code owner August 30, 2026 05:37
@changeset-bot

changeset-bot Bot commented Aug 30, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f3559c5

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

This PR includes changesets to release 39 packages
Name Type
@livekit/agents Patch
@livekit/agents-plugin-anam Patch
@livekit/agents-plugin-anthropic Patch
@livekit/agents-plugin-assemblyai Patch
@livekit/agents-plugin-azure Patch
@livekit/agents-plugin-baseten Patch
@livekit/agents-plugin-bey Patch
@livekit/agents-plugin-cartesia Patch
@livekit/agents-plugin-cerebras Patch
@livekit/agents-plugin-deepgram Patch
@livekit/agents-plugin-did Patch
@livekit/agents-plugin-elevenlabs Patch
@livekit/agents-plugin-fishaudio Patch
@livekit/agents-plugin-google Patch
@livekit/agents-plugin-hedra Patch
@livekit/agents-plugin-hume Patch
@livekit/agents-plugin-inworld Patch
@livekit/agents-plugin-krisp Patch
@livekit/agents-plugin-lemonslice Patch
@livekit/agents-plugin-liveavatar Patch
@livekit/agents-plugin-livekit Patch
@livekit/agents-plugin-minimax Patch
@livekit/agents-plugin-mistral Patch
@livekit/agents-plugin-mistralai Patch
@livekit/agents-plugin-neuphonic Patch
@livekit/agents-plugin-openai Patch
@livekit/agents-plugin-perplexity Patch
@livekit/agents-plugin-phonic Patch
@livekit/agents-plugin-protoface Patch
@livekit/agents-plugin-resemble Patch
@livekit/agents-plugin-rime Patch
@livekit/agents-plugin-runway Patch
@livekit/agents-plugin-sarvam Patch
@livekit/agents-plugin-silero Patch
@livekit/agents-plugin-soniox Patch
@livekit/agents-plugin-tavus Patch
@livekit/agents-plugins-test Patch
@livekit/agents-plugin-trugen Patch
@livekit/agents-plugin-xai 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

@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: No Issues Found

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

Devin Review

@davidzhao
davidzhao merged commit ba4a502 into main Aug 30, 2026
6 checks passed
@davidzhao
davidzhao deleted the port/connection-pool-prewarm-retry branch August 30, 2026 05:43
@github-actions github-actions Bot mentioned this pull request Aug 30, 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.

1 participant