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

   Linked issue: #1411
   
   ### Purpose of change
   
   Align Java Gemini and Ollama timeout configuration with their SDK contracts. 
Gemini `timeout` uses integer milliseconds; Ollama `requestTimeout` supports 
positive long seconds instead of requiring an Integer.
   
   #### Runtime flow
   
   Java declarations, JSON descriptors, or YAML initial arguments → Connection 
numeric validation → Gemini HttpOptions.timeout or OllamaChatEndpointCaller → 
HTTP request timeout.
   
   #### Key decisions
   
   Keep SDK-native units and ranges. Convert Number values exactly so 
Integer/Long differences after deserialization do not cause casts to fail, and 
fractions or overflow are not silently truncated. Each Connection retains its 
own default and zero-value policy.
   
   ### Behavioral Semantics
   
   #### Interaction decisions
   
   | Input | Gemini timeout | Ollama requestTimeout |
   |---|---|---|
   | Omitted or null | Leave SDK timeout unset | 60 seconds |
   | Zero | Disable request timeout | Reject |
   | Positive integral Number | Milliseconds, up to Integer.MAX_VALUE | 
Seconds, up to Long.MAX_VALUE |
   | Negative, fractional, non-finite, out of range, or nonnumeric | Reject | 
Reject |
   
   #### Behavioral contracts
   
   - Accepted numeric values reach the SDK without scaling, clamping, or 
truncation. Integral decimal values such as 1500.0 are accepted.
   - Java, JSON, and YAML declarations use the same Connection validation.
   - Gemini retains its SDK default when omitted; Ollama retains its 60-second 
default. Ollama does not expose a disabled-timeout value.
   
   #### Failure behavior
   
   Invalid timeout input fails during Connection construction with 
IllegalArgumentException naming the parameter, expected range, and supplied 
value. Existing SDK/service error handling is unchanged.
   
   ### Tests
   
   Coverage in GeminiTimeoutConfigurationTest and 
OllamaTimeoutConfigurationTest:
   
   | Contract | Coverage |
   |---|---|
   | Omitted defaults | absentTimeoutUsesDefault |
   | Null defaults | Null cases in directAndJsonDeclarationsReachSdk |
   | Exact SDK value, zero policy, and integer limits | 
directAndJsonDeclarationsReachSdk and rejectsInvalidNumericValues |
   | Equivalent Java/JSON declarations | directAndJsonDeclarationsReachSdk |
   | YAML numeric values reach the SDK | yamlNumericTypesReachSdk |
   | Invalid inputs fail with the parameter name | rejectsInvalidNumericValues |
   
   124 related Java tests passed (82 Gemini, 42 Ollama); Spotless and git diff 
--check passed. Tests inspect real SDK HTTP timeout configuration without 
sending requests.
   
   Not verified: live service calls, elapsed timeout enforcement, Vertex AI 
timeout execution, and the full Python-to-Java bridge. Native Python 
implementations are unchanged.
   
   <details>
   <summary>Verification command and implementation details</summary>
   
   ~~~sh
   mvn --batch-mode --no-transfer-progress test   -pl 
integrations/chat-models/gemini,integrations/chat-models/ollama -am   
'-Dtest=Gemini*Test,OllamaChatModel*Test,OllamaMultimodalTest,OllamaTimeoutConfigurationTest'
   -Dsurefire.failIfNoSpecifiedTests=false
   ~~~
   
   Numeric conversion uses BigDecimal.intValueExact()/longValueExact(). Tests 
inspect Gemini's underlying OkHttp call timeout and Ollama's constructed JDK 
HttpRequest timeout via reflection; SDK upgrades may require updating these 
helpers.
   </details>
   
   ### API
   
   Gemini timeout changes from seconds to milliseconds: a former value of 60 
must become 60000 to retain a 60-second timeout. Negative Gemini values now 
fail instead of being ignored, and the seconds-to-milliseconds clamping is 
removed. Zero is explicitly passed to the SDK to disable the timeout.
   
   Ollama retains seconds and its default, accepts values beyond the int range, 
and rejects nonpositive values at initialization rather than when constructing 
a request. Parameter names and public constructor signatures are unchanged. 
These contracts also apply when configuring the Java resources through YAML or 
cross-language descriptors.
   
   ### 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: 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