Repository navigation
fix(azure): keep Responses LLM connections alive between turns - #8801
Open
chuenchen309 wants to merge 1 commit into
Open
chuenchen309 wants to merge 1 commit into
chuenchen309 wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
🔍 Devin Review: 2 flags
Not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
azure.responses.LLMbuilds itsAsyncAzureOpenAIwithout anhttp_client, so it gets the OpenAI SDK's default pool, which closes idle connections after 5 seconds. That is the same gap #8793 closed foropenai.LLM.with_azure(),TTS.with_azure()andSTT.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 parentopenai.responses.LLMconstructor already passes a 120-second keep-alive pool, but the Azure subclass hands its own client to it.The fix passes the same
httpx.AsyncClientthat #8793 uses (50 connections,keepalive_expiry=120,follow_redirects=True, the giventimeoutor the existing default). Request timeouts are unchanged.Tests. I added an
azure-responsescase totest_with_azure_keeps_its_connection_between_turns. It fails onmain(two connections) and passes with the fix; the SDK-default control case still expects two.tests/test_plugin_openai.pyandtests/test_plugin_openai_responses.pypass (96 tests), andruff checkandruff format --checkpass on the changed files.