Croway opened a new pull request, #26856: URL: https://github.com/apache/camel/pull/26856
JIRA: [CAMEL-25000](https://issues.apache.org/jira/browse/CAMEL-25000) ## Problem `ai-tool` and `ai-resource` routes register in `AiToolRegistry` / `AiResourceRegistry` only when their consumer starts. Camel starts route consumers one at a time, so a route declared earlier whose consumer produces immediately (e.g. `stream:in -> openai:chat-completion?tags=...`) calls the LLM before the later tool routes are registered: the request silently carries some tools, or none. `camel-mcp-server` can publish a partial `tools/list` / `resources/list` the same way. Reproduced with Camel JBang 4.22.1 (`echo "..." | camel run reproducer.camel.yaml`): the console route declared first sends only the first tool; with the tool routes swapped, none. Declaring the console route last, or `startupOrder: 9999`, sends both. ## Fix - `AiToolEndpoint` / `AiResourceEndpoint` register their consumer's spec in `doStart()`, which runs during route warm-up — Camel warms up all routes before starting any route consumer. Only routes that start automatically are registered early; the consumer keeps registering on start/resume and deregistering on stop/suspend as before (re-registering the same spec is a no-op). An early registration whose consumer never started is removed when the endpoint stops. - The auto-startup decision is extracted from `RouteService.isAutoStartup()` into a new public `CamelContextHelper.isAutoStartup(Route)` (context/route `autoStartup` + `autoStartupExcludePattern`), used by both, instead of duplicating it in the components. - `design/aiTool.adoc` lifecycle section updated. ## Tests - `AiToolStartupOrderTest`, `AiResourceStartupOrderTest`, `McpServerBridgeStartupOrderTest`: a probe route declared first records what is registered/published when its consumer starts. They failed before the fix (`[]`) and pass after; they also check that `autoStartup(false)` routes are not registered. - `CamelContextHelperAutoStartupTest` for the new helper. - Existing tests: camel-ai-tool (118), camel-ai-resource (28), camel-mcp-server-api (27), camel-core auto-startup / startup-order / route-controller tests all pass. - The JBang reproducer on the patched snapshot sends both tools in either route order. _Claude Code on behalf of Croway_ -- 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]
