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

   _Claude Code on behalf of davsclaus_
   
   [CAMEL-25075](https://issues.apache.org/jira/browse/CAMEL-25075)
   
   In the local-model benchmark a small model got stuck asking 
`camel_catalog_doc(sql)` 16 times in a row until its tool call budget was 
spent. The trace showed every earlier answer was still in context: the model 
was at a fixed point, since each identical answer leaves its input unchanged. 
This does parts 1 and 2 of the plan on the ticket: declare which tools are 
deterministic, and make a repeat look different.
   
   ### What changes
   
   - **The contract.** `ToolDescriptor.deterministic(true)` in the shared 
registry marks the tools whose answer depends only on their arguments: 
`camel_catalog_doc`, `camel_catalog_find`, `camel_catalog_sample` and 
`camel_error_diagnose`. Both servers list them with `"_meta": 
{"camel.apache.org/deterministic": true}`. `camel mcp` does this with 
`@MetaField`, `camel tui --mcp` in its own `tools/list`. MCP has no standard 
hint for this: `idempotentHint` is about side effects.
   - **The backstop.** `RepeatedToolCalls` (camel-jbang-core) counts calls per 
session. The first two identical calls of a deterministic tool are answered in 
full. From the third, the answer is a short note that the call was already 
answered and how many times it was asked. It deliberately gives no advice on 
what to try instead, so the benchmark measures the model and not a nudge.
     - **Sessions:** for `camel mcp`, one MCP connection (`McpConnection.id()`, 
injected into the four tools and kept out of the input schema). For `camel tui 
--mcp`, which has no session id, the time from one `initialize` to the next.
     - Calls with other arguments, empty optional arguments treated as left 
out, and the tools that read files, logs or the running integration are always 
answered in full. Re-reading a file after an edit and polling the log keep 
working.
   - **The TUI AI panel is unchanged.** It already stops identical calls of any 
tool within a turn (`MAX_IDENTICAL_TOOL_CALLS`). It also compacts older tool 
results between turns and asks the model to call again for the full data, which 
a session-wide count would break.
   - Docs: a *Repeated calls* section in `camel-jbang-mcp.adoc`.
   
   ### Tests
   
   - `RepeatedToolCallsTest` (core): two full answers, then the note; other 
arguments; blank arguments; file, log and validate tools are never cut; reset.
   - `AuthoringToolsTest` (mcp): the third identical `camel_catalog_doc` of a 
connection gets the note and another connection does not. The `@MetaField` 
marking and the connection parameter match the shared descriptor for every 
tool, and the argument parity check skips the injected connection.
   - `TuiMcpServerRepeatedCallsTest` (tui): over HTTP, `tools/list` carries the 
`_meta` and the third call gets the note. A new `initialize` answers in full 
again.
   - Checked with the packaged Quarkus server over stdio. The listing has the 
`_meta` on the four tools and no `connection` in their input schema. 
`camel_catalog_doc(sql)` answered 17,073 characters twice, then 265 characters. 
Quarkus only accepts the `_meta` prefix with its trailing slash, which the unit 
tests cannot see, so this check is what found it.
   - Module test suites: camel-jbang-core 1436, camel-jbang-plugin-tui 1713, 
camel-jbang-mcp 426, all pass.
   
   ### Not done here
   
   Part 3 of the plan: measuring connect-service-sql and route-aggregator 
before and after, 10 passes each, for the next benchmark run.
   
   🤖 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