Skip to content

Python: OpenAI Chat Client - fix max tokens trasnslation and extra int test - #3037

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 1 commit into
microsoft:mainfrom
eavanvalkenburg:fix_oai
Jan 5, 2026
Merged

Eduard van Valkenburg (eavanvalkenburg) merged 1 commit into
microsoft:mainfrom
eavanvalkenburg:fix_oai

Conversation

@eavanvalkenburg

Copy link
Copy Markdown
Member

Motivation and Context

Fixes #3025
Correctly translates max_tokens to the new max_completion_tokens variable and adds a integration test that validates that.

Description

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

@markwallace-microsoft

Copy link
Copy Markdown
Contributor

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/core/agent_framework/openai
   _chat_client.py2474880%115–116, 120, 140, 150–151, 153, 164, 180, 190, 195, 201–203, 210, 239, 259, 278, 292, 297–311, 318–320, 395, 401, 405, 408, 410, 412, 418, 432–433, 439, 455
TOTAL16849262484% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
2563 149 💤 0 ❌ 0 🔥 1m 0s ⏱️

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.

Pull request overview

This pull request fixes issue #3025 by correcting the translation of the max_tokens parameter in the OpenAI chat client implementation. The key change updates the parameter mapping from max_output_tokens to max_completion_tokens to align with the OpenAI API specification.

Key Changes:

  • Corrected parameter translation from max_output_tokens to max_completion_tokens in the chat client
  • Added an integration test to validate chat completion with custom chat options including max_tokens

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
python/packages/core/agent_framework/openai/_chat_client.py Fixed the translation mapping for max_tokens parameter from max_output_tokens to max_completion_tokens
python/packages/core/tests/openai/test_openai_chat_client.py Added new integration test test_openai_chat_completion_response_params to validate chat completions with custom options (max_tokens, temperature, top_p)

Merged via the queue into microsoft:main with commit deea844 Jan 5, 2026
23 checks passed