etzel-mes commented on PR #30317:
URL: https://github.com/apache/camel/pull/30317#issuecomment-6972131805

   Thanks for the review. All three are addressed in 0155f2ec472.
   
   **In-flight tool calls on route stop**
   
   The roles check is now a plain `AsyncProcessorSupport` with no lifecycle on 
the processor it wraps, as you suggested; `AiToolConsumer` starts and stops 
only the processor `authorizationPolicy.wrap(...)` returns. So `allowedRoles` 
alone starts and stops nothing more than a route without it. Two tests pin that.
   
   I wrote the test you asked for (a call held inside the route with a latch, 
route stopped, then `AiToolResult.Success` expected) and it still failed after 
that change. It also fails on unmodified main (3d3b5185f1b8) for a plain 
`ai-tool` route with no authorization option:
   
   ```
   ExecutionError[... cause=org.apache.camel.RouteStoppingException: The 
exchange cannot continue: its route is being stopped or reloaded]
     at 
RedeliveryErrorHandler$SimpleTask.runNotAllowed(RedeliveryErrorHandler.java:1026)
   ```
   
   `DefaultConsumer.doStop` stops the route processor itself 
(`ServiceHelper.stopService(exchangeFactory, processor)`), and 
`DefaultShutdownStrategy` does that before it waits for in-flight exchanges, 
since `AiToolConsumer` is neither `Suspendable` nor `ShutdownAware`. So the 
plain route is cut off too, in 4.22.x and 4.23.x as well.
   
   `AiToolConsumer implements Suspendable` fixes it: the consumer is suspended 
first (its existing `doSuspend` deregisters the tool), the call completes, then 
it stops. With that one line the test passes on main and the module's tests 
pass. It also makes the existing `doSuspend`/`doResume` reachable; today 
`suspendRoute` falls back to a stop.
   
   Since this changes every tool route and is a candidate for the maintenance 
branches, I left it out of this PR and will file it as its own issue with the 
test. `AiPromptConsumer` and `AiResourceConsumer` have the same shape. Say if 
you prefer it here instead.
   
   **Property name**
   
   Not deliberate. Renamed to `CamelAiToolSecurityPrincipalRoles` and 
`CamelAiToolSecurityPrincipalName`, after the module's other constants 
(`CamelAiToolCallId`). The Java constants keep their names, and 
`CamelMcpSecurityPrincipal` (released in 4.23.0) is untouched. 
camel-spring-boot sets the properties through the constants and needs no 
change; camel-quarkus PR 9509 does too, but its `usage.adoc` names the old 
strings. Say if you want a different name.
   
   **Messages**
   
   Reworded the four places and the `AiEvent.ToolCallDeniedEvent` Javadoc. The 
same "denied by authorization policy" log is in `LangChain4jAgentProducer` and 
the openai `McpToolCallExecutor`; I left those as they were not listed, and can 
change them here if you like.
   
   _Claude Code on behalf of etzel-mes_
   


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