prewarm LLM to skip connection establishment#6484
Open
davidzhao wants to merge 1 commit into
Open
Conversation
warms up DNS + TLS cache/handshakes before the first LLM request is sent
theomonnom
approved these changes
Jul 19, 2026
theomonnom
reviewed
Jul 19, 2026
| # request doesn't pay connection setup costs | ||
| if isinstance(self._llm, LLM): | ||
| try: | ||
| asyncio.get_running_loop() |
Member
There was a problem hiding this comment.
There is always an event loop
Member
There was a problem hiding this comment.
Adding to this, I think we can skip checking it here since _llm.prewarm already does that internally.
theomonnom
reviewed
Jul 19, 2026
| session_close_transcript_timeout: float = 2.0, | ||
| # Runtime settings | ||
| conn_options: NotGivenOr[SessionConnectOptions] = NOT_GIVEN, | ||
| loop: asyncio.AbstractEventLoop | None = None, |
|
|
||
| self._prewarm_task = asyncio.create_task(_prewarm()) | ||
|
|
||
| async def _prewarm_impl(self) -> None: |
Member
There was a problem hiding this comment.
Q: should we add support for FallbackAdapter?
| # request doesn't pay connection setup costs | ||
| if isinstance(self._llm, LLM): | ||
| try: | ||
| asyncio.get_running_loop() |
Member
There was a problem hiding this comment.
Adding to this, I think we can skip checking it here since _llm.prewarm already does that internally.
| async def _prewarm() -> None: | ||
| try: | ||
| await self._prewarm_impl() | ||
| except Exception: |
Member
There was a problem hiding this comment.
Should we clear the _prewarm_task here?
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.
warms up DNS + TLS cache/handshakes before the first LLM request is sent