aws: LLM opens a new bedrock-runtime client every turn, so each reply waits on a fresh TCP+TLS handshake
I maintainer di solito rispondono entro 1 giorno
@amishaguptaberk ci sta già lavorando.
Dal 13/10/2026.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- aws, python
- Ambito
- backend-api-design, performance
Direzione di ricerca
Start in livekit-plugins/livekit-plugins-aws/livekit/plugins/aws/llm.py, especially LLMStream._run at line 324, and compare how the OpenAI and Google plugins retain and close clients. Work out client ownership and how prewarming can open a Bedrock connection; the issue leaves those design choices unresolved. Done means one client is reused across turns, closed in aclose(), and prewarming is supported.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Bug Description
Thanks for the LLM.prewarm() hook from #6484. The anthropic, openai, google and mistralai plugins implement it; the AWS plugin can't yet, because it has no client that lives past one turn.
LLMStream._run enters self._session.create_client("bedrock-runtime", ...) on every chat() call (llm.py L324). So each turn builds a new client and a new TCP + TLS connection, then closes both. Timing OpenAI GPT-6 on Bedrock:
| "Say pong.", us-east-1 | new client per turn (today) | one reused client |
|---|---|---|
aws.LLM time to first token, us.openai.gpt-6-sol, n=10 median |
1.10 s | 0.69 s |
aws.LLM time to first token, us.openai.gpt-6-luna, n=10 median |
1.13 s | 0.67 s |
aiobotocore converse_stream end to end, Sol, 3 runs (n=5, 5, 10) |
1.10 / 0.95 / 1.02 s | 0.67 / 0.70 / 0.71 s |
The "reused" aws.LLM rows monkeypatch create_client to hand back one already-open client. Split (n=10 medians): TCP connect 194 ms, TLS 1.3 handshake 199 ms, building the client 6 ms. So every turn pays two extra round trips: ~0.4 s from my machine (~190 ms from us-east-1), far less for an agent in the same region.
Expected Behavior
One bedrock-runtime client per aws.LLM instance, reused across turns and closed in aclose(), the way the openai and google plugins keep theirs. _prewarm_impl could then open the connection before the first reply.
Reproduction Steps
# aiobotocore directly, same Config the plugin uses; AWS credentials in the environment
uv run python - <<'PY'
import asyncio, statistics, time
from aiobotocore.session import get_session
from botocore.config import Config
REQ = dict(modelId="us.openai.gpt-6-sol",
messages=[{"role": "user", "content": [{"text": "Say pong."}]}],
inferenceConfig={"maxTokens": 64})
CFG = Config(user_agent_extra="x-client-framework:livekit-plugins-aws")
async def one(client):
async for _ in (await client.converse_stream(**REQ))["stream"]:
pass
async def main():
s = get_session(); s.set_config_variable("region", "us-east-1")
new, reuse = [], []
async with s.create_client("bedrock-runtime", config=CFG) as shared:
await one(shared)
for _ in range(5):
t0 = time.perf_counter()
async with s.create_client("bedrock-runtime", config=CFG) as c: # what _run does
await one(c)
new.append(time.perf_counter() - t0)
t0 = time.perf_counter(); await one(shared); reuse.append(time.perf_counter() - t0)
print(f"new client {statistics.median(new):.2f}s vs reused {statistics.median(reuse):.2f}s")
asyncio.run(main())
PY
new client 1.15s vs reused 0.72s
Operating System
macOS 26 (network-bound, not OS-specific)
Models Used
AWS Bedrock us.openai.gpt-6-sol via aws.LLM (any Bedrock model)
Package Versions
livekit-agents==1.8.2
livekit-plugins-aws==1.8.2 # main at b4df92e
aiobotocore==3.8.0
botocore==1.43.46
python==3.13
Session/Room/Call IDs
N/A
Proposed Solution
Create the client lazily on the first chat() (an AsyncExitStack on the LLM), reuse it in LLMStream._run, close it in aclose(), add _prewarm_impl. Two choices I'd leave to you: which event loop owns the client, and what a cheap request for _prewarm_impl would be (bedrock-runtime has no list-models call). Happy to open a PR once that's settled.
Additional Context
Related
- Polly TTS has the same per-request pattern (
tts.pyL162). I did not measure it. - 250-word answers, n=3 medians:
aws.LLMTTFT was 1.38 s (Sol) and 1.80 s (Luna). A reused boto3 client got 0.76 s and 1.32 s.
- Lingua principale
- Python
- Stelle
- 14.6k
- Fork
- 3.9k
- Merge medio
- 2g 9h
- PR unite (30g)
- 159
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di livekit/agents
-
BM25SearchStrategy (the default) never matches underscore-joined terms in tool descriptions or param descriptionsForse già presa @BlueX888 l’ha presa 2 giorni fa. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
livekit/agents#7727 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Assistant markup is stripped from chat history when expressive mode is offForse già presa @ShivamSharma43 l’ha presa 5 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
docs: openai.LLM vs openai.responses.LLM for HTTP OpenAI-compat hostsForse di nuovo libera @AbarnaaSree l’ha presa 44 giorni fa e non c’è nessuna pull request aperta. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
livekit/agents#7022 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 58/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di livekit/agents
Issue simili
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
openwisp/openwisp-utils#777 ·
-
Boolean statistics (Covered, Confident, JaccardDistant) aggregate to 1.0 without float weightsAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 63/100
google-research/weatherbenchX#310 ·
I maintainer di solito rispondono entro 3 giorni
-
`unload()` returns the trained `modules_to_save` copy instead of the original moduleForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
huggingface/peft#3955 ·
I maintainer di solito rispondono entro 1 giorno
-
author-page correction
Difficoltà 2/5 1-3 ore Idoneità per principianti 60/100
acl-org/acl-anthology#10313 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
AOSSIE-Org/Gitcord-GithubDiscordBot#147 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno