fightBoxing commented on code in PR #1405:
URL: https://github.com/apache/flink-agents/pull/1405#discussion_r4625700976
##########
integrations/chat-models/watsonx/src/main/java/org/apache/flink/agents/integrations/chatmodels/watsonx/WatsonxChatModelConnection.java:
##########
@@ -881,4 +887,19 @@ private synchronized void invalidateCachedIamToken(String
rejectedToken) {
iamTokenExpirationEpochSec = 0;
}
}
+
+ /** HTTP status kept on the exception so the chat retry loop can tell 4xx
from 5xx. */
+ private static final class HttpStatusException extends RuntimeException {
Review Comment:
`HttpStatusException` is now public, and status lookup takes a public no-arg
`int`/`Integer` getter from a public superclass or public interface.
`Class.getMethod` on the non-public subclass was the call that threw
`IllegalAccessException`, even when `statusCode()` itself is public.
`WatsonxHttpStatusAccessTest` sits in `...watsonx.outside` and reflectively
reads `statusCode()` from a local-server 400.
`ChatModelInvokerTest.testNonPublicStatusSubclassInAnotherPackageIsNotRetried`
uses a non-public subclass defined in `org.apache.flink.agents.plan` and
expects a single attempt.
##########
plan/src/main/java/org/apache/flink/agents/plan/actions/ChatModelInvoker.java:
##########
@@ -110,6 +132,57 @@ public static String errorText(Exception error) {
: error.getClass().getName() + ": " +
String.valueOf(error.getMessage());
}
+ /**
+ * A client error is not retried. 408, 409, 429, and 5xx are. Anything
without an HTTP status,
+ * including a timeout, keeps the previous retry behavior. Status is read
from the failure or a
+ * cause, so a {@code RuntimeException} wrapper does not hide it.
+ */
+ static boolean isRetryableProviderFailure(Throwable error) {
Review Comment:
Java calls into a Python chat model now go through
`python_java_utils.call_chat_model`. A failure that has an HTTP status returns
`(False, status, message)` before Pemja flattens the exception. Java raises
`PythonHttpStatusException`, a `PythonException` with `statusCode()`. A
statusless failure and an uncapturable exception are re-raised.
The other direction inspects a `pemja.PyJObject` for `statusCode()`,
`getStatusCode()`, or `code()`, and walks `getCause()`. A non-retryable status
wins over a later 5xx.
`ChatModelCrossLanguageRetryTest` drives real Pemja. A Python 400, plain or
wrapped, and a Java 400 reached from Python are attempted once. 429, 503, and a
statusless error still use the retry budget.
--
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]