gnodet-bot commented on code in PR #26607:
URL: https://github.com/apache/camel/pull/26607#discussion_r4051509473
##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ai/ToolRegistry.java:
##########
@@ -942,39 +942,71 @@ private static void registerCatalogTools() {
private static void registerExampleTools() {
register(tool("list_examples",
- "List available Camel CLI examples. Returns name, title,
description, difficulty level, and tags.")
+ "List the Camel CLI examples, grouped as the ladder of the
examples (quick-start, run, transform, "
+ + "route, fail-well, connect,
connect-service, contracts, ai, cloud, showcase). "
+ + "Returns the groups (level, title,
intro) and the examples in reading order with "
+ + "name, title, description, level,
order, tags, what they teach, the infra "
+ + "services they need, whether they are
bundled and their files. "
+ + "Call it without arguments for the
whole ladder, with level for one group.")
.param("filter", "string",
"Filter by name, description, or tag
(case-insensitive)", false)
.param("level", "string",
- "Filter by difficulty: beginner, intermediate, or
advanced", false)
+ "Only the examples of one group: quick-start, run,
transform, route, fail-well, connect, "
+ + "connect-service, contracts, ai,
cloud or showcase",
+ false)
+ .param("limit", "integer", "Maximum number of examples to
return (default: 50)", false)
.executor((ctx, args) -> {
String filter = args.get("filter");
String level = args.get("level");
+ int limit = 50;
+ String limitArg = args.get("limit");
+ if (limitArg != null && !limitArg.isBlank()) {
+ try {
+ limit = Integer.parseInt(limitArg.trim());
+ } catch (NumberFormatException e) {
+ throw new ToolExecutionException("limit must be a
number: " + limitArg);
+ }
+ }
Review Comment:
⚠️ **`limit=0` and negative values silently return zero examples —
inconsistent with the other two implementations.**
`ExampleTools` guards with `limit != null && limit > 0 ? limit : 50` and
`TuiToolRegistry` guards with `n.intValue() > 0 ? n.intValue() : 50`. Here,
`Integer.parseInt("0")` sets `limit = 0`, and then `results.size() >= 0` is
always `true` → every entry is skipped → empty response. An LLM passing
`limit=0` meaning "no preference" would get nothing back.
Add the same guard:
```suggestion
if (limitArg != null && !limitArg.isBlank()) {
try {
limit = Integer.parseInt(limitArg.trim());
if (limit <= 0) {
limit = 50;
}
} catch (NumberFormatException e) {
throw new ToolExecutionException("limit must be
a number: " + limitArg);
}
}
```
--
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]