JiriOndrusek opened a new issue, #9544:
URL: https://github.com/apache/camel-quarkus/issues/9544
A `@RegisterAiService` method returning `Multi<String>` and annotated with
`@CamelAiTools("weatherTag")` is offered all registered tools when it is called
on the event loop (for example from a `@NonBlocking` REST method). The tag
filter is bypassed.
Found with a scratch test on `main` (quarkus-langchain4j 2.0.0.Beta4,
langchain4j 1.23.0). Tools: `createOrder`, `failingTool`, `getNews`,
`getWeather`; only `getWeather` has the tag `weatherTag`:
- `@Blocking` endpoint: offered `getWeather`
- `@NonBlocking` endpoint: offered
`createOrder,failingTool,getNews,getWeather`
Cause: for a `Multi` return called on the event loop, quarkus-langchain4j
defers the work to a worker thread (`runSubscriptionOn`).
`CamelAiToolProvider.provideTools` then runs after `CamelAiToolsInterceptor`
has already cleared the `ThreadLocal` that carries the tag. Blocking `String`
and `TokenStream` returns compute the tools synchronously and are not affected.
Possible fix: do not use a `ThreadLocal`; look up the tag from
`request.invocationContext().interfaceName()` in the existing `TAG_MAP`.
Test: in `ai-tool-langchain4j`, a `Multi<String>` service with
`@CamelAiTools`, a streaming scripted chat model that answers with the offered
tool names, called from a `@NonBlocking` and a `@Blocking` REST method. Both
must return only the tagged tool.
--
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]