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

   Linked issue: None
   
   ### Purpose of change
   
   When an Anthropic API call fails, the error reported to the user contains 
only a static string (`"Failed to call Anthropic messages API."`) with no 
diagnostic information. Any API failure — timeout, auth error, invalid model, 
network issue — is reported as the same opaque string, making diagnosis 
impossible without reading the full TaskManager stack trace.
   
   Root cause:
   
   - `AnthropicChatModelConnection.chat()` wraps all exceptions in 
`RuntimeException("Failed to call Anthropic messages API.", e)` — the cause `e` 
is attached but not surfaced.
   - `ChatModelInvoker.errorText()` extracts only `getMessage()`, discarding 
the cause entirely.
   
   ### Behavioral Semantics
   
   The change is backward compatible:
   
   - The original message substring `"Failed to call Anthropic messages API."` 
is preserved (existing `testBuildFailureIsWrapped` still passes).
   - The cause message is appended after `"Cause: "` in 
`AnthropicChatModelConnection.chat()`.
   - `ChatModelInvoker.errorText()` appends ` [caused by: <cause>]` when the 
exception has a non-null cause whose message is not already contained in the 
wrapper message.
   - No behavioral change for `InvocationFailure` or `RoutingFailure` — their 
messages are still returned as-is.
   
   ### Tests
   
   - New test `testChatExceptionIncludesCauseMessage` verifies the wrapped 
RuntimeException includes `"Cause:"` and the root cause message.
   - Existing `testBuildFailureIsWrapped` continues to pass (original message 
substring preserved).
   - All 105 `AnthropicChatModelConnectionTest` tests pass.
   - All 14 `ChatModelInvokerTest` tests pass.
   
   ### API
   
   No public API changes. The `errorText()` method in `ChatModelInvoker` is 
`public static` but only the error string format changes (appends cause info), 
not the method signature.
   
   ### Documentation
   
   - [ ] `doc-needed`
   - [x] `doc-not-needed`
   - [ ] `doc-included`
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   - [x] Yes
   - [ ] No
   
   Generated-by: Claude Code (Claude Sonnet 4)


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