davsclaus opened a new pull request, #28108:
URL: https://github.com/apache/camel/pull/28108

   [CAMEL-25784](https://issues.apache.org/jira/browse/CAMEL-25784), the part 
for the AI tools. **This PR builds on #28107** (the first commit here). Once 
#28107 is merged, I will rebase this PR so it only has its own commit.
   
   In a benchmark of Oct 18-19 2026, an app died at startup after a restart in 
4 of the first 6 runs of one example (contracts/rest-code-first, a code-first 
REST DSL with an API description, which failed on CAMEL-25768). The trace of 
one run:
   
   ```
   camel_control restart contracts-rest-code-first -> Restarted 
contracts-rest-code-first as pid 46486
   camel_get_log contracts-rest-code-first        -> No running Camel process 
matches 'contracts-rest-code-first'
   camel_run                                      -> status started, pid 46489
   camel_get_log 46489                            -> No running Camel process 
matches '46489'
   ... (two more starts, the same answers)
   ```
   
   The model restarted the app three times and never saw the error.
   
   ## The cause
   
   `camel_run` and `camel_control restart` answered "started" as soon as the 
status file of the new process appeared. The CLI connector writes that file 
while Camel starts, before the routes start. A run of that example shows it:
   
   ```
   status file appears at 1.74 s: context state Initializing (phase 2)
   process exits at 2.82 s with exit code 70: Cannot find 
RestApiProcessorFactory in Registry or classpath
   ```
   
   So both tools answered "started" for a process that died a second later, and 
the tools that came after found no process.
   
   ## What
   
   - **`camel_run` and `camel_control restart` wait until the CamelContext has 
started**, as the status file says (`context.state` is `Started`). A process 
that exits while it starts now gets the answer the tools already give for that: 
the failure with its cause and the output. A status without a state (an older 
Camel) counts as started, as before.
   - **`camel_get_log` of an integration that is not running answers with the 
log of its previous run** (#28107 keeps it, as `camel log --previous` shows 
it). It finds the run by the name or pid given, else by the pid selected before 
(such as the pid `camel_run` answered with). The message says how that run 
ended.
     The answer also has `previous` (name, pid, ended, exitCode, failure) and 
the records, as for a running integration. The answer for a run of that example 
on this branch (records cut):
     ```json
     {"message":"e2e-rest is not running. This is the log of its previous run 
(pid 40927), which ended at 2026-10-19 12:58:17 (2m28s ago) with exit code 70: 
Failed to start route: route1 because: java.lang.IllegalStateException: Cannot 
find RestApiProcessorFactory in Registry or classpath (such as the 
camel-openapi-java component)",
      "previous":{"name":"e2e-rest","pid":40927,"ended":"2026-10-19 
12:58:17","exitCode":70,"failure":"Failed to start route: route1 because: ..."},
      "file":"~/.camel/e2e-rest-previous.log",
      
"lines":[{"time":"12:58:17.301","level":"ERROR","logger":"MainSupport","message":"Error
 starting Camel: org.apache.camel.FailedToStartRouteException: Failed to start 
route: route1 because: ...","detailLines":75}, ...],
      "totalLines":168,"returnedLines":3}
     ```
   - **`previous=true`** asks `camel_get_log` for that log also when the 
integration runs again, such as after a restart. The camel-jbang-mcp server has 
the same argument.
   - **`camel_get_errors` of an integration that is not running** says how its 
previous run ended, and that `camel_get_log` shows its log:
     ```
     No running Camel process matches 'e2e-rest'; list_processes shows what 
runs. Its previous run (pid 40927) ended at 2026-10-19 12:58:17 (2m28s ago) 
with exit code 70: Failed to start route: route1 because: 
java.lang.IllegalStateException: Cannot find RestApiProcessorFactory in 
Registry or classpath (such as the camel-openapi-java component). camel_get_log 
shows its log.
     ```
   
   A name that matches no previous run gets the same error as before.
   
   ## Tests
   
   - New `PreviousRunToolsTest` (6): the log of the previous run by name, asked 
for with `previous`, and by the pid selected before; a name without a previous 
run; `camel_get_errors`; and when an integration has started (Starting, 
Started, no state, no status).
   - Two tests that looked at the real `~/.camel` (in camel-jbang-core and 
camel-jbang-mcp) now use a home directory of their own, as the tools now look 
for previous runs there.
   - All tests of camel-jbang-core pass (2335, 2 skipped, and 237), and of 
camel-jbang-mcp (503).
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   https://claude.ai/code/session_01STT6whBgK1AqsSsUKrnE8m
   


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