eemario opened a new pull request, #1410:
URL: https://github.com/apache/flink-agents/pull/1410

   <!-- Please link the PR to the relevant issue(s). Hotfix doesn't need this. 
-->
   Linked issue: #xxx
   
   ### Purpose of change
   
   Allow Java OpenAI resource timeouts to use `Duration` or explicit duration 
strings instead of numeric seconds, aligning with the Java SDK.
   
   This covers `timeout` in `OpenAICompletionsConnection`, 
`AzureOpenAIChatModelConnection`, `VLLMChatModelConnection`, and 
`OpenAIResponsesModelConnection`, plus `request_timeout` in 
`OpenAIEmbeddingModelConnection`.
   
   #### Runtime flow
   
   Resource declarations → `ResourceDescriptor.getDurationArgument()` → 
connection-specific validation and millisecond rounding → SDK timeout settings.
   
   Top-level `Duration` arguments serialize as ISO-8601 strings. Connections 
accept these strings after plan deserialization, including declarations 
originating from Python or YAML.
   
   #### Key decisions
   
   Keep general parsing in internal `DurationUtils`, with SDK range and 
precision rules in the connections. Preserve the existing defaults and timeout 
behavior.
   
   ### Behavioral Semantics
   
   #### Interaction decisions
   
   | Input | Direct Java declaration | After plan JSON deserialization |
   |---|---|---|
   | `Duration` | Read directly | Read from its ISO-8601 representation |
   | Duration string | Parsed | Parsed |
   | Missing or null | Use the connection default | Use the connection default |
   
   #### Behavioral contracts
   
   - Accept `Duration`, ISO-8601 strings, and signed integer-with-unit strings 
such as `500 ms`.
   - Preserve nanoseconds during parsing; connections round positive values up 
to milliseconds.
   - Keep defaults of 60 seconds for Chat and 30 seconds for Embedding.
   - Zero disables timeouts. Valid values cannot exceed `Integer.MAX_VALUE` 
milliseconds.
   - Apply the resolved timeout to all four SDK timeout components.
   
   #### Failure behavior
   
   Unsupported types, malformed strings, and parser overflow raise 
`IllegalArgumentException` with the argument name. Connections reject negative 
and above-limit durations before SDK client creation. Bare numeric seconds are 
no longer accepted.
   
   ### Tests
   
   | Contract | Coverage |
   |---|---|
   | Supported formats, nanosecond precision, negative parsing, and overflow 
rejection | `DurationUtilsTest` |
   | Default/null handling, named errors, and JSON round trips | 
`ResourceDescriptorTest` |
   | SDK defaults, zero disabling, limits, and rounding | OpenAI connection and 
utility unit tests |
   | Python descriptor JSON round trips | `test_resource_declarations.py` |
   | Five connections through Python/YAML → plan JSON → Java SDK | 
`OpenAIResourceDurationCrossLanguageTest` |
   
   Passed: 166 Java unit tests, 14 Python tests, and 40 cross-language 
configuration cases.
   
   Cross-language tests construct real SDK clients and inspect timeout 
settings. Live provider requests and wall-clock timeout behavior were not 
verified.
   
   ### API
   
   Adds public `ResourceDescriptor.getDurationArgument(String, Duration)`.
   
   Java callers must replace numeric timeout values with `Duration` or explicit 
duration strings. Python/YAML declarations targeting Java resources must use 
duration strings. Native Python resource parameters retain numeric seconds.
   
   Defaults, zero disabling, SDK limits, and positive millisecond rounding 
remain unchanged.
   
   ### Documentation
   
   <!-- Do not remove this section. Check the proper box only. -->
   
   - [ ] `doc-needed` <!-- Your PR changes impact docs -->
   - [ ] `doc-not-needed` <!-- Your PR changes do not impact docs -->
   - [x] `doc-included` <!-- Your PR already contains the necessary 
documentation updates -->
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   <!-- Do not remove this section. Check the proper box only. -->
   
   - [x] Yes
   - [ ] No
   
   Generated-by: Codex CLI 0.167.0-alpha.4.1 (GPT-6)
   


-- 
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]

Reply via email to