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

   [CAMEL-27146](https://issues.apache.org/jira/browse/CAMEL-27146)
   
   ## Problem
   
   The write tools of the camel-jbang-mcp server (`camel_write_file`, 
`camel_edit_file`) refuse a script (groovy, jq, ...) that returns a text 
starting with `resource:` (CAMEL-24882). The check read every line under the 
language key, not only the script. So a `resource:` value under another key 
looked like a script that returns it.
   
   In the local-model benchmark of last night (r35), the model wrote the wrong 
key:
   
   ```yaml
   - setBody:
       expression:
         groovy:
           resource: "resource:file:shipment-mapping.groovy"
   ```
   
   The refusal had two messages. The first is right: "the groovy text goes in 
expression:, write groovy: {expression: 
"resource:file:shipment-mapping.groovy"}". The second is wrong: "the script 
returns the text 'resource:file:shipment-mapping.groovy', not the file ... Add 
resolveResource: true under groovy: and return the name without a scheme". 
There is no script here.
   
   The model followed the second message. It wrote `expression: 
"shipment-mapping.groovy"` with `resolveResource: true`, and Groovy ran the 
file name as code: `MissingPropertyException: No such property: shipment`. The 
model fixed the route later, but the step failed on the errors (3 of 7 runs of 
that step).
   
   In the benchmark runs r30 to r35, 31 of the 34 refusals with this message 
were for a wrong key under groovy (`resource` 28 times, `resourceUri` 3 times). 
Only 3 were for a script that returns the text.
   
   ## Change
   
   The check reads only the script:
   - the value of the language key (a block scalar goes on in the lines under 
it);
   - or, when the key has no value, its `expression:` option among the other 
options (also as a block scalar);
   - or the `expression:` entry of a flow mapping, `groovy: {expression: 
"..."}`. Before, the whole flow mapping was read, so the form that the schema 
message gives would get the false message too.
   
   A wrong key now gets only the schema message. A script that returns 
`'resource:file:x'` still gets the hint, also when other options are around 
`expression:`.
   
   ## Tests
   
   - `SourceValidatorResourceLiteralTest`: a `resource:` value under another 
key (`resource`, `resourceUri`) is not a script; the script under `expression:` 
is read among other options; a flow mapping is read by its `expression:` entry, 
with and without `resolveResource: true`; the whole validator gives the wrong 
key only the schema message. Three of the new tests fail without the change.
   - camel-jbang-core, the `commands.ai` tests: 1097 run, 0 failures, 1 skipped.
   
   _Claude Code on behalf of davsclaus_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   https://claude.ai/code/session_016Y4dDi5iQNgtHrDdz2NpwF
   


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