You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Python: Embedding clients have no close()/context manager and leak their internally created SDK clients #9814
#9748 added deterministic lifecycle to chat clients (async with, close(), connector-owned resource release), but the embedding client family was left out:
BaseEmbeddingClient has no __aenter__/__aexit__/close(), so async with does not work for any embedding client, and there is no contract for releasing resources.
OpenAIEmbeddingClient creates an AsyncOpenAI/AsyncAzureOpenAI SDK client internally (owning an httpx connection pool) when async_client is not supplied, and offers no way to close it — only GC ever releases the pool.
BedrockEmbeddingClient creates a boto3 bedrock-runtime client internally with the same gap.
OllamaEmbeddingClient creates an AsyncClient (httpx transport) internally with the same gap.
GeminiEmbeddingClient already implements close() with _owns_client — the rest of the family is inconsistent with it and with the chat clients.
Repro
fromagent_framework_openaiimportOpenAIEmbeddingClientclient=OpenAIEmbeddingClient(api_key="...")
asyncwithclient: # TypeError: 'async with' received an object that does not implement __aenter__
...
# and the internally created AsyncOpenAI is never closed deterministically
Long-lived processes that build embedding clients per unit of work (e.g. per request/tenant) accumulate unclosed httpx pools until GC runs, which is exactly the class of leak #9748 fixed for chat clients.
Expected
Embedding clients follow the same contract #9748 established for chat clients: base-class context trio with a no-op default close(), and resource-owning implementations that close only the SDK client they created (caller-supplied clients stay open), idempotent on repeated close.
changed the title [-]Embedding clients have no close()/context manager and leak their internally created SDK clients[/-][+]Python: Embedding clients have no close()/context manager and leak their internally created SDK clients[/+]on Oct 29, 2026
Activity
[-]Embedding clients have no close()/context manager and leak their internally created SDK clients[/-][+]Python: Embedding clients have no close()/context manager and leak their internally created SDK clients[/+]