Skip to content

fix(azure): keep Responses LLM connections alive between turns - #8801

Open
chuenchen309 wants to merge 1 commit into
livekit:mainfrom
chuenchen309:fix/azure-responses-keepalive
Open

chuenchen309 wants to merge 1 commit into
livekit:mainfrom
chuenchen309:fix/azure-responses-keepalive

Conversation

@chuenchen309

Copy link
Copy Markdown
Contributor

azure.responses.LLM builds its AsyncAzureOpenAI without an http_client, so it gets the OpenAI SDK's default pool, which closes idle connections after 5 seconds. That is the same gap #8793 closed for openai.LLM.with_azure(), TTS.with_azure() and STT.with_azure(): the pause between two turns of a voice agent is usually longer than 5 seconds, so almost every request opens a new TCP and TLS connection. The parent openai.responses.LLM constructor already passes a 120-second keep-alive pool, but the Azure subclass hands its own client to it.

The fix passes the same httpx.AsyncClient that #8793 uses (50 connections, keepalive_expiry=120, follow_redirects=True, the given timeout or the existing default). Request timeouts are unchanged.

Tests. I added an azure-responses case to test_with_azure_keeps_its_connection_between_turns. It fails on main (two connections) and passes with the fix; the SDK-default control case still expects two. tests/test_plugin_openai.py and tests/test_plugin_openai_responses.py pass (96 tests), and ruff check and ruff format --check pass on the changed files.

@chuenchen309
chuenchen309 requested a review from a team as a code owner November 26, 2026 19:10

@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

This branch has not been deployed

No deployments
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