Skip to content

Python: Add timeout parameter to FoundryChatClient - #9699

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 1 commit into
microsoft:mainfrom
droideronline:feature/foundry-chat-client-timeout
Oct 26, 2026
Merged

Eduard van Valkenburg (eavanvalkenburg) merged 1 commit into
microsoft:mainfrom
droideronline:feature/foundry-chat-client-timeout

Conversation

@droideronline

Copy link
Copy Markdown
Contributor

Motivation & Context

FoundryAgent accepts a timeout, but FoundryChatClient and RawFoundryChatClient do not, so there is no supported way to set an HTTP timeout on them. Callers have to reassign client.client after construction.

Description & Review Guide

  • What are the major changes?
    • Add timeout: float | None = None to RawFoundryChatClient.__init__ and FoundryChatClient.__init__.
    • When set, apply it with openai_client.with_options(timeout=timeout) on the client returned by project_client.get_openai_client(), the same approach FoundryAgent uses.
    • Add unit tests for both the timeout and no-timeout paths.
  • What is the impact of these changes? None unless timeout is passed. The default keeps the OpenAI SDK behavior.
  • What do you want reviewers to focus on? Whether applying the timeout via with_options after get_openai_client() is the right place, consistent with FoundryAgent.

Related Issue

Fixes #9698

AI Assistance

  • No material AI assistance was used.
  • This is an AI-assisted contribution. I reviewed, understood, and verified all submitted content and accept responsibility for it.

AI assistance details: implementation, tests, and this PR description.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR links to an agreed issue with no competing open PR, or the Related Issue section documents a trivial-change or repository-automation exception.
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

Apply the timeout to the OpenAI client returned by the project client,
matching what FoundryAgent already does.
Copilot AI balanced review requested due to automatic review settings October 26, 2026 08:56

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@eavanvalkenburg

Copy link
Copy Markdown
Member

/review

@github-actions github-actions 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.

MAF Automated Review — Iteration 1

Result: No findings
Scope: full PR (1 commit(s)): 814361287216
Model: gpt-5.6-sol

Overview

The PR adds an optional keyword-only timeout to both Foundry chat-client constructors and applies it by cloning the OpenAI client with with_options, matching the existing FoundryAgent contract. The default path preserves the original client, and focused tests cover both configured and omitted timeout behavior. No publishable correctness, compatibility, architecture, or security issue was established.

Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
No publishable findings remained after source verification for this scope.

Merged via the queue into microsoft:main with commit b79c03c Oct 26, 2026
55 of 57 checks passed

This branch was previously deployed

1 inactive deployment
github-app-auth — 81436128 Deployed Oct 26, 2026 by droideronline via team_check #7451
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Feature]: Add timeout parameter to FoundryChatClient

3 participants