[java][python][Azure OpenAI] Align token limit handling with max_completion_tokens
I maintainer di solito rispondono entro 2 giorni
@samarthputhraya ci sta già lavorando.
Dal 29/11/2026.
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
Search before asking
- I searched the existing issues and did not find a duplicate.
Description
Follow-up to #1470: make Azure OpenAI Chat Completions token-limit handling consistent across Java, Python, and YAML, using max_completion_tokens as the typed setting.
Both setups currently expose max_tokens, but the requests differ:
- Java translates it to the SDK's
maxCompletionTokens, sendingmax_completion_tokens. - Python forwards it as
max_tokens.
Consequently, the Python path cannot use this setting with deployments whose models require max_completion_tokens. This is a request-field compatibility issue as well as a Java/Python mismatch.
Microsoft documents max_tokens as deprecated and requires max_completion_tokens for reasoning models: API reference, reasoning guide. However, the Azure FAQ explicitly notes that some older models, such as GPT-4 turbo-2024-04-09, do not support the new field. Preserve an explicit way to send the old field for deployments that need it.
Source: Java connection, Python setup and connection.
Expected changes
- Rename the typed setting to
max_completion_tokensconsistently in Java, Python, and YAML, without an old top-level compatibility alias. Send the new field under the same name in both languages. - Omit the token-limit field when it is unset and retain positive-value validation.
- For older deployments, allow users to leave the typed setting unset and explicitly send
additional_kwargs={"max_tokens": ...}. Do not translate that explicit old field to the new name. - Update the reserved-key validation in both Azure implementations: it currently reserves
max_tokens, so renaming only the setup field would leave this older-model path blocked. Preserve the existing collision policy for the new typed field. - Do not automatically generate both token-limit fields. Keep
additional_kwargsas passthrough; no extra validation is required to reject a configuration that explicitly supplies both token-limit names. - Update documentation and examples to distinguish the modern typed setting from the explicit older-deployment option. Explain that users should leave
max_completion_tokensunset when supplyingmax_tokensthroughadditional_kwargs. Check the supported Azure API versions; do not assume every OpenAI-compatible endpoint supports the same fields.
Verification
Cover Java and Python setup-to-request behavior, including YAML/descriptor configuration: omitted limit, explicit new limit, invalid values, and old-field-only passthrough through additional_kwargs. Assert the exact outgoing field names and values, including that the old-field-only case does not also generate max_completion_tokens. For Java, inspect the serialized HTTP body to catch duplicate fields. No special rejection test for explicitly supplying both token-limit names is required.
How to reproduce
Construct an Azure setup with max_tokens=256 (or the equivalent Java descriptor argument) and capture a chat request through its connection. Python sends max_tokens, while Java sends max_completion_tokens. For a reasoning deployment that rejects the old field, the Python request is incompatible with the documented API contract.
The current reserved-key validation also rejects additional_kwargs={"max_tokens": 256}, preventing it from serving as an explicit older-model option without a corresponding code change.
Version and environment
Identified during the review of #1470, from the source at c5976c41a286135b96232e024777142009e28c18. The current main-branch Python Azure file was also checked and is unchanged. This report is based on source inspection and Microsoft's API documentation; no live Azure deployment was tested.
This can be implemented separately and does not need to block #1470. Responses token-limit naming is tracked separately in #1477; its API field is max_output_tokens.
Are you willing to submit a PR?
- I'm willing to submit a PR!
- Lingua principale
- Java
- Stelle
- 497
- Fork
- 193
- Merge medio
- 2g 21h
- PR unite (30g)
- 68
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di apache/flink-agents
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
apache/flink-agents#1480 ·
I maintainer di solito rispondono entro 2 giorni
-
[Tech Debt] Python cross-language e2e tests hardcode 0.4-SNAPSHOT tests jar and silently skipAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
apache/flink-agents#1476 ·
I maintainer di solito rispondono entro 2 giorni
-
[Bug][runtime] Trace Log loggers fail on a string trace-log.pretty-print valueForse già presa @Zhuoxi2000 l’ha presa 3 giorni fa. ApertaaffectVersion/0.4.0 bug fixVersion/0.4.1 fixVersion/1.0.0 priority/major
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
apache/flink-agents#1463 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 4/5 1-2 giorni Idoneità per principianti 45/100
apache/flink-agents#1482 ·
I maintainer di solito rispondono entro 2 giorni
-
java priority/minor tech debt
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
apache/flink-agents#1477 ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di apache/flink-agents
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
Card-Forge/forge#13128 ·
I maintainer di solito rispondono entro 1 giorno
-
client documentation
Difficoltà 1/5 1-3 ore Idoneità per principianti 86/100
ClickHouse/clickhouse-java#3469 ·
I maintainer di solito rispondono entro 1 giorno
-
bug good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
Beam P2
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
I maintainer di solito rispondono entro 1 giorno