davsclaus commented on code in PR #29514:
URL: https://github.com/apache/camel/pull/29514#discussion_r4519017890


##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ChaosExplore.java:
##########
@@ -133,34 +144,58 @@ public Integer doCall() throws Exception {
             printer().printErr(started.error());
             return started.exitCode();
         }
-        printer().println("Let there be chaos: " + process.name() + " (pid " + 
process.pid() + "), "
+        String integration = displayName(process);
+        printer().println("Let there be chaos: " + integration + " (pid " + 
process.pid() + "), "
                           + 
TimeUtils.printDuration(started.reply().getLongOrDefault("budget", 0))
                           + (focus != null && !focus.isBlank() ? ", focus: " + 
focus : ""));
         int answer;
+        Ask ask = ask(process, integration);
         try {
-            answer = ask(process).doCall();
+            answer = ask.doCall();
         } catch (Exception e) {
             // the LLM fails with an exit code; anything else must not cost 
the report of what was explored so far
-            printer().printErr("camel ask failed: " + e.getMessage());
+            // an exception without a message is known by its type
+            printer().printErr("camel ask failed: " + (e.getMessage() != null 
? e.getMessage() : e.getClass().getSimpleName()));
             answer = CliExitCode.FAILURE;
         } finally {
             // the AI may have finished it already; else its rules go now
             ActionClient.execute(process, "chaos", root -> root.put("command", 
"explore-finish"), 10000);
         }
-        JsonObject exploration = 
ChaosExperimentRun.exploration(RuntimeHelper.readStatus(process.pid()));
+        JsonObject status = RuntimeHelper.readStatus(process.pid());
+        JsonObject exploration = ChaosExperimentRun.exploration(status);
         List<String> lines = journal(exploration);
         printer().println();
         lines.forEach(printer()::println);
+        if (save && exploration != null) {
+            Saved saved = save(Path.of("test", "chaos"), LocalDateTime.now(),
+                    new Run(integration, budget, focus, ask.usedModel, 
seed(status)), exploration, ask.lastAnswer,
+                    lines);
+            printer().println();
+            printer().println("Report: " + saved.report());
+            saved.scenarios().forEach(s -> printer().println("Scenario: " + s 
+ " (replay: camel run * --chaos=" + s + ")"));
+        }

Review Comment:
   Done in ce9e9a05333a: a failed save prints "Could not save the report in 
test/chaos: ..." after the journal, instead of a stack trace.
   
   _Claude Code on behalf of davsclaus_



##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ai/ToolRegistry.java:
##########
@@ -1005,6 +1006,13 @@ private static void registerChaosTools() {
                                     feed, args.get("body"), 
args.get("headers"), repeat,
                                     args.get("interval"))
                             : null;
+                    if (traffic != null) {
+                        // an experiment without messages says nothing: the AI 
gets the routes to feed instead
+                        String why = 
ChaosExperimentRun.checkFeed(ctx.readFullStatus(), feed);
+                        if (why != null) {
+                            throw new ToolExecutionException(why);
+                        }
+                    }

Review Comment:
   Removed the pre-check in ce9e9a05333a: the run checks the feed itself, and 
the tool turns its refusal into a tool error with the same reason. The CLI 
command keeps its pre-check, which gives the usage exit code.
   
   _Claude Code on behalf of davsclaus_



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