Repository navigation
Python: Add timeout parameter to OpenAI client classes - #9924
Draft
Isham Mohamed (IshamMohamed) wants to merge 4 commits into
Draft
Isham Mohamed (IshamMohamed) wants to merge 4 commits into
Isham Mohamed (IshamMohamed) wants to merge 4 commits into
Conversation
(OpenAIChatClient, OpenAIChatCompletionClient, and OpenAIEmbeddingClient) for consistent HTTP timeout control across all OpenAI integrations.
Isham Mohamed (IshamMohamed)
temporarily deployed
to
github-app-auth
November 1, 2026 00:59 — with
GitHub Actions
Inactive
Isham Mohamed (IshamMohamed)
temporarily deployed
to
github-app-auth
November 1, 2026 01:00 — with
GitHub Actions
Inactive
Isham Mohamed (IshamMohamed)
temporarily deployed
to
github-app-auth
November 1, 2026 01:00 — with
GitHub Actions
Inactive
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
A constructor indentation error prevents Chat Completions imports, while missing public timeout support and superclass forwarding leave the new timeout behavior incomplete.
4 open issues
What changed in this PR
This PR aims to address #9923 by exposing HTTP timeout control through Agent Framework’s public Python OpenAI clients, without requiring a custom SDK client.
Changes:
- Adds timeout parameters to Responses and embedding client constructors, and the raw Chat Completions constructor.
- Forwards embedding and raw Chat Completions timeouts through shared settings.
- Documents timeout defaults and behavior when an SDK client is supplied.
| File | Description |
|---|---|
python/packages/openai/agent_framework_openai/_embedding_client.py |
Adds timeout parameters, documentation, and forwarding for raw and public embedding clients. |
python/packages/openai/agent_framework_openai/_chat_completion_client.py |
Adds timeout support to the raw Chat Completions constructor. |
python/packages/openai/agent_framework_openai/_chat_client.py |
Adds timeout parameters and documentation to the public Responses client. |
Review effort: Balanced
Isham Mohamed (IshamMohamed)
temporarily deployed
to
github-app-auth
November 1, 2026 01:11 — with
GitHub Actions
Inactive
…ation to restore imports' Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Isham Mohamed (IshamMohamed)
temporarily deployed
to
github-app-auth
November 1, 2026 01:13 — with
GitHub Actions
Inactive
Isham Mohamed (IshamMohamed)
temporarily deployed
to
github-app-auth
November 1, 2026 01:36 — with
GitHub Actions
Inactive
This branch was previously 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.


(OpenAIChatClient, OpenAIChatCompletionClient, and OpenAIEmbeddingClient) for consistent HTTP timeout control across all OpenAI integrations.
Motivation & Context
Why is this change required?
This change is required because the high-level OpenAI client classes (
OpenAIChatClient,OpenAIChatCompletionClient,OpenAIEmbeddingClient) did not expose atimeoutparameter, while the underlying raw clients (RawOpenAIChatClient,RawOpenAIChatCompletionClient,RawOpenAIEmbeddingClient) already supported it. This prevented developers from controlling HTTP timeouts when using the framework's public client APIs.What problem does it solve?
It solves the problem of developers being unable to override the default OpenAI SDK timeout (connect: 5s, read/write/pool: 600s) through the framework's high-level clients. Previously, developers had to manually configure
async_clientinstances to control timeouts, which was inconsistent with the raw client API.What scenario does it contribute to?
It contributes to the scenario where applications need different timeout behaviors for OpenAI API requests (chat, chat completions, embeddings) without having to manually configure
async_clientinstances. For example, a long-running embedding request might need a 120s timeout while chat requests use 30s.If it fixes an open issue, please link to the issue below.
Fixes Python: [Feature]: Make timeout configurable on framework OpenAI clients (chat, chat completion, embedding) #9923
Scope of work is only limited to
timeouton the OpenAI client classes because it depends onRawOpenAI*Clientclasses and they havetimeoutexposed. A seperate PR may be requirered to implementmax_retries(similar to Python: [Feature]: Add max_retries (or OpenAI client kwargs) to FoundryChatClient #9719) because that work requiresRawOpenAI*Clienttoo to havemax_retriesexposed.Description & Review Guide
The overall approach follows the existing pattern already established in the raw OpenAI client classes (
RawOpenAIChatClient,RawOpenAIChatCompletionClient,RawOpenAIEmbeddingClient), which already supported atimeoutparameter. The implementation uses theload_openai_service_settings()infrastructure to handle both OpenAI and Azure routing consistently.The underlying design ensures a single
timeoutvalue applies to all request phases (connect, read, write, pool). Whenasync_clientis provided, the timeout parameter is ignored, allowing users to configure timeout directly on their pre-configured client. Default behavior is preserved (None= OpenAI SDK defaults: connect 5s, read/write/pool 600s).Added
timeout: float | None = Noneto all three__init__overloads ofOpenAIChatClient,OpenAIChatCompletionClient, andOpenAIEmbeddingClient. Updated docstrings to document the timeout parameter. Forwarded timeout throughload_openai_service_settings()for proper handling.Developers can now pass
timeoutto all three client classes. Default behavior is preserved (None = SDK default). Timeout is ignored whenasync_clientis provided. (PS: not added toNvidiaEmbeddingClientorFoundryLocalClientas they manage their own clients). The focust is only on directly OpenAI related clients on the agent-framework.timeoutis added to all three overloads for each client classtimeout=timeoutis passed toload_openai_service_settings()Nonepreserves SDK defaults)Related Issue
Fixes #9923
AI Assistance
AI assistance details:
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.