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

   Part of item 9 of 
[CAMEL-26932](https://issues.apache.org/jira/browse/CAMEL-26932): a catalog 
lookup that finds nothing gave no near-spelling suggestion.
   
   ## Problem
   
   `camel_catalog_doc name=kafak` answered `{"error":"Artifact not found: 
kafak"}`, without suggestions. The suggestions of the catalog 
(`suggestComponentNames` and the others) match a term by name, alias, title and 
substring, which is right for a protocol or product name such as `mqtt` or 
`s3`, but a typo matches none of them.
   
   ## Change
   
   When the catalog suggests nothing, `CatalogDocs` suggests the name the term 
is a typo of: `ArtifactUtils.closest`, the Damerau-Levenshtein match that the 
dependency checks use already. It allows a few edits, and gives no answer when 
two names are equally close, as a wrong guess is worse than none. It is used 
for the lookup by name (components, data formats, languages and EIPs), and for 
`kind=component`.
   
   ```
   camel_catalog_doc name=kafak                          {"error":"Artifact not 
found: kafak","suggestions":["kafka"]}
   camel_catalog_doc name=platfrom-http kind=component   {"error":"Component 
not found: platfrom-http","suggestions":["platform-http"]}
   ```
   
   ## Not in this PR, for a decision
   
   The rest of item 9 is that a miss is answered as data (MCP `isError=false`), 
and the third identical call gets the repeat note "Go on with the options the 
earlier answer gave", which does not fit a miss. Making a miss a tool error 
(`ToolExecutionException`) would take it out of the repeat count of 
`RepeatedToolCalls`, and that count is what stopped a small model from asking 
11 or 12 more times for a sample that does not exist (r32, CAMEL-26875). So 
that part needs a choice first: an error that still counts, or a repeat note of 
its own for a miss.
   
   ## Tests
   
   - `CatalogDocsTest.aMisspelledNameSuggestsTheNameItIsATypoOf`: `kafak` 
suggests `kafka`, `platfrom-http` with `kind=component` suggests 
`platform-http`, and `nosuchthing` still has no suggestions.
   - camel-jbang-run: 303 pass. camel-jbang-core: 3003 + 259 pass.
   
   _Claude Code on behalf of davsclaus_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


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