Skip to content

prewarm LLM to skip connection establishment#6484

Open
davidzhao wants to merge 1 commit into
mainfrom
dz/prewarm
Open

prewarm LLM to skip connection establishment#6484
davidzhao wants to merge 1 commit into
mainfrom
dz/prewarm

Conversation

@davidzhao

Copy link
Copy Markdown
Member

warms up DNS + TLS cache/handshakes before the first LLM request is sent

warms up DNS + TLS cache/handshakes before the first LLM request is sent
@davidzhao
davidzhao requested a review from a team as a code owner July 18, 2026 22:41

@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 potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

# request doesn't pay connection setup costs
if isinstance(self._llm, LLM):
try:
asyncio.get_running_loop()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There is always an event loop

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Adding to this, I think we can skip checking it here since _llm.prewarm already does that internally.

session_close_transcript_timeout: float = 2.0,
# Runtime settings
conn_options: NotGivenOr[SessionConnectOptions] = NOT_GIVEN,
loop: asyncio.AbstractEventLoop | None = None,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

here


self._prewarm_task = asyncio.create_task(_prewarm())

async def _prewarm_impl(self) -> None:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Q: should we add support for FallbackAdapter?

# request doesn't pay connection setup costs
if isinstance(self._llm, LLM):
try:
asyncio.get_running_loop()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we clear the _prewarm_task here?

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.

3 participants