gnodet-bot commented on code in PR #30336:
URL: https://github.com/apache/camel/pull/30336#discussion_r4612254570


##########
components/camel-ai/camel-ai-prompt/src/main/java/org/apache/camel/component/ai/prompt/AiPromptExecutor.java:
##########
@@ -48,6 +48,13 @@ public static AiPromptResult execute(AiPromptSpec spec, 
Map<String, String> argu
                     "No consumer available for prompt '" + promptName + "'",
                     new IllegalStateException("No consumer available"));
         }
+        // A suspended prompt (suspended route, graceful shutdown) refuses new 
requests, as request/reply consumers do
+        // while suspended; a caller may hold its spec from before the 
suspend. Requests in flight are past this point.
+        if (consumer.isSuspendingOrSuspended()) {
+            return new AiPromptResult.ExecutionError(
+                    "Prompt '" + promptName + "' is suspended",
+                    new IllegalStateException("Prompt is suspended"));
+        }
         Processor processor = consumer.getProcessor();

Review Comment:
   The `IllegalStateException` cause message does not include the prompt name, 
unlike `AiToolExecutor` and `AiResourceExecutor` which both use 
`String.format("... '%s' ...", name)` and then pass `cause.getMessage()` as the 
outer message.
   
   When this error appears in logs or a stack trace, `cause.getMessage()` will 
just say `"Prompt is suspended"` with no indication of which prompt. Align with 
the sibling executors:
   
   ```suggestion
           if (consumer.isSuspendingOrSuspended()) {
               IllegalStateException cause = new IllegalStateException(
                       String.format("Prompt '%s' is suspended", promptName));
               return new AiPromptResult.ExecutionError(cause.getMessage(), 
cause);
           }
   ```



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