HsbcJone opened a new pull request, #1493: URL: https://github.com/apache/flink-agents/pull/1493
Linked issue: #1477 Closes #1477 ### Purpose of change Java and YAML OpenAI Responses configurations set the output limit with `max_output_tokens`. The request sends that field and does not send `max_tokens`. An unset limit is omitted. A value that is not greater than 0 is rejected. The previous top-level name is not read. The Responses API names this limit `max_output_tokens` and counts visible output tokens and reasoning tokens together. The setup name now matches that field. Flink Agents 0.x does not keep a compatibility alias. #### Runtime flow `OpenAIResponsesModelSetup` reads `max_output_tokens` from the resource descriptor. A missing value stays unset and is left out of `getParameters()`. A present value is stored with `Number.intValue()` and, when greater than 0, placed in the parameter map under `max_output_tokens`. `OpenAIResponsesModelConnection` copies that map, removes `max_output_tokens`, and calls `maxOutputTokens` unless `additional_kwargs` already contains `max_output_tokens`. `additional_kwargs` are then written as extra body properties. The HTTP body is the OpenAI Java SDK serialization of that builder. #### Key decisions The old top-level name is not accepted as an alias. Once the setup key and the wire key are the same, the connection uses the same additional-keyword precedence already used for Responses `temperature` and `store`: the additional value is the only `max_output_tokens` field. Chat Completions `max_tokens`, temperature omission, and `store` are unchanged. ### Behavioral Semantics #### Interaction decisions | Top-level `max_output_tokens` | `additional_kwargs.max_output_tokens` | Request | | --- | --- | --- | | Unset | Absent | Both `max_output_tokens` and `max_tokens` omitted | | Greater than 0 | Absent | One integer `max_output_tokens`; no `max_tokens` | | Unset | Present | One field, the additional value | | Greater than 0 | Present | One field, the additional value | | Not greater than 0 | Any | Setup throws; no request | | Top-level `max_tokens` only | Absent | Neither field sent | #### Behavioral contracts - An explicit `max_output_tokens` greater than 0 reaches the Responses request as an integral `max_output_tokens` value, and the body has no `max_tokens` field. - An unset limit omits both `max_output_tokens` and `max_tokens`. - When `additional_kwargs` contains `max_output_tokens`, that value is the only `max_output_tokens` field, including when a valid top-level value is also set. - A top-level `max_tokens` argument does not set the limit and is not sent. #### Failure behavior A top-level value that is not greater than 0 raises `IllegalArgumentException` with the message `max_output_tokens must be greater than 0`, before a request is built. A non-number still fails through the existing unchecked `Number` cast. `additional_kwargs` values are not validated here; a provider error for an additional value propagates as the SDK exception. There is no fallback to `max_tokens`. ### Tests | Contract | Tests | | --- | --- | | Explicit limit reaches the request as `max_output_tokens` and not `max_tokens` | `OpenAISetupRequestParametersTest.explicitOutputLimitReachesRequestUnderMaxOutputTokens` | | Unset limit is omitted | `OpenAISetupRequestParametersTest.unsetOutputLimitIsOmitted` | | Additional value wins as a single field | `OpenAISetupRequestParametersTest.additionalOutputLimitReachesRequestAndOverridesExplicitValue` | | Non-positive limit is rejected | `OpenAISetupRequestParametersTest.invalidExplicitOutputLimitIsRejected` | | Old top-level name is not sent | `OpenAISetupRequestParametersTest.legacyMaxTokensNameIsNotSent` | The request tests build a `ResourceDescriptor`, construct the real setup and connection, and read the HTTP body captured from the SDK against a loopback 400. Duplicate JSON keys fail parsing. The OpenAI module suite, including unchanged Chat Completions tests, passed (`mvn test -pl integrations/chat-models/openai`: 192 run, 0 failures). Not verified: a live Responses call, a YAML agent job, fractional or overflowing numbers, a non-number argument, and a Python caller passing the Java setup. There is no Python Responses setup to rename. <details> <summary>Implementation invariants</summary> The setup still truncates with `intValue()` before the positive check. The connection still sends the stored number with `longValue()`. `additional_kwargs` entries other than `max_output_tokens` are still copied onto the body after the typed fields. Temperature and `store` precedence are untouched. </details> ### API This is a breaking configuration change for Java and YAML OpenAI Responses setups. Callers that set `max_tokens` no longer apply an output limit; the argument is ignored rather than rejected. Callers set `max_output_tokens` instead. No compatibility alias is provided, consistent with the 0.x preview policy. Chat Completions, Azure OpenAI, and vLLM still use `max_tokens`. Omission, the greater-than-zero check, and additional-keyword passthrough are otherwise unchanged. When both the top-level setting and `additional_kwargs` supply `max_output_tokens`, the additional value is the one sent. ### Documentation - [ ] `doc-needed` - [ ] `doc-not-needed` - [x] `doc-included` ### Was this patch authored or co-authored using generative AI tooling? - [x] Yes - [ ] No Generated-by: Cursor Cloud Agent (Grok 4.7) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
