Skip to content

fix(python): preserve max_output_tokens in ModelLimits - #2799

Open
HDMowri wants to merge 1 commit into
github:mainfrom
HDMowri:fix-python-model-limits-max-output-tokens
Open

HDMowri wants to merge 1 commit into
github:mainfrom
HDMowri:fix-python-model-limits-max-output-tokens

Conversation

@HDMowri

@HDMowri HDMowri commented Sep 30, 2026 •

Copy link
Copy Markdown

Summary

  • Preserve max_output_tokens on the public Python ModelLimits type.
  • Keep the field during model metadata deserialization and serialization.
  • Preserve compatibility with existing positional ModelLimits construction.

Context

The generated RPC ModelCapabilitiesLimits already carries
max_output_tokens, but CopilotClient.list_models() converts model metadata
through the public ModelLimits.from_dict(), which previously discarded the
field.

The TypeScript public ModelCapabilities type used by listModels() already
includes max_output_tokens. This follows the same schema/public-type parity
principle addressed in #2569, although that PR was motivated by the TypeScript
session-override path while this change fixes Python model-metadata
deserialization.

Compatibility

ModelLimits already supports positional construction as:

ModelLimits(max_prompt_tokens, max_context_window_tokens, vision)

The new field is keyword-only so existing positional arguments retain their
meaning. This follows the compatibility approach used by the SDK's generated
Python dataclasses when fields are added after an established positional API.

Fixes #2798

Testing

  • verifies max_output_tokens deserialization and serialization
  • verifies existing positional ModelLimits construction remains unchanged
  • pytest test_client.py — 154 passed
  • pytest test_legacy_parameters.py — 7 passed
  • ruff format --check copilot test_client.py
  • ruff check copilot test_client.py
  • ty check copilot

Preserve max_output_tokens when Python model metadata is deserialized and serialized without changing existing positional construction.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@HDMowri
HDMowri requested a review from a team as a code owner September 30, 2026 07:14

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python ModelLimits drops max_output_tokens from model metadata

2 participants