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

   https://issues.apache.org/jira/browse/CAMEL-25900
   
   The REST example of the benchmark (one order out of a JSON list by its id, 
404 when unknown) failed 12 of 12 times on two nights. The model saw the 
earlier hints but wrote paths that give the wrong answer:
   - `$[?(@.orderId == '${header.id}')][0]` gives an empty list. Jayway applies 
an index after a filter to each element it matched.
   - `$[?(…)] && size() > 0` is no JsonPath, and fails with 500.
   - `${body[0].orderId}` takes the first element, because the List hint 
offered `[0]` first.
   
   The recipe is a filter with `resultType: java.util.Map`: the element when 
one matches, null when none does. The tools now lead to it:
   
   - **Source check** (`JsonPathChecks`): it reports an index after a filter, 
and `&&` or `||` outside a filter, and names the recipe.
   - **`camel_eval_expression`**: for a jsonpath filter, the answer notes that 
a filter gives a list also for one match, and that a route gets the one element 
with `resultType: java.util.Map`.
   - **`camel_catalog_doc jsonpath`**: it answers the recipe in `usage`.
   - **camel-bean**: the hint for `${body.orderId}` on a List leads with the 
jsonpath recipe, and `[0]` comes after it.
   - **`camel_catalog_find CamelHttpStatusCode`** (and similar names): it names 
CamelHttpResponseCode (`Exchange.HTTP_RESPONSE_CODE`).
   
   I did not add a `resultType` parameter to `camel_eval_expression`. With two 
new parameters, the prompt of the AI clients grew by about 60 tokens, past its 
budget with all tool groups loaded. The note in the answer teaches the same 
recipe at no prompt cost.
   
   Tests: new tests in `JsonPathChecksTest` (3), `CatalogDocsTest` (2), 
`ExpressionEvaluatorLanguageTest` (1), and an updated `SimpleSyntaxHintsTest`. 
camel-jbang-core 2406 + 237, camel-jbang-mcp 503 and the camel-core simple hint 
tests (33) pass, and the prompt budget is unchanged.
   
   _Claude Code on behalf of davsclaus_
   
   🤖 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