gnodet-bot commented on code in PR #27714: URL: https://github.com/apache/camel/pull/27714#discussion_r4246525711
########## core/camel-api/src/main/java/org/apache/camel/ai/AiEvent.java: ########## @@ -0,0 +1,110 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.ai; + +import org.apache.camel.spi.CamelEvent; +import org.jspecify.annotations.Nullable; + +/** + * Common contract for events fired by Camel AI components (tool calls, agentic loops, ...). + * <p> + * An {@code AiEvent} is a {@link CamelEvent.ExchangeEvent} of {@link CamelEvent.Type#Ai}: it carries the exchange it + * relates to (so it can be correlated by route id or exchange id) and is typed {@code Ai} rather than {@code Custom}, + * so an {@link org.apache.camel.spi.EventNotifier} can recognise AI activity â and route it to metrics, tracing or a + * GenAI-observability backend â by type and by these sub-interfaces, without depending on any AI component or doing an + * {@code instanceof} against each component's own event class. + * <p> + * Concrete event classes live in the AI components (they implement these interfaces); the only thing shared across + * components is this contract. + * + * @since 4.23 Review Comment: đĄ **Root `AiEvent` interface `@since` still says 4.23 (not fixed)** The root `AiEvent` interface Javadoc says `@since 4.23` while all sub-interfaces say `@since 4.24`. The previous review flagged this; the author's response said it was fixed in `044b4b4c`, but this commit did not update the outer interface header. ```suggestion * @since 4.24 ``` ########## docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc: ########## @@ -0,0 +1,43 @@ += Apache Camel 4.x Upgrade Guide + +This document is for helping you upgrade your Apache Camel application +from Camel 4.x to 4.y. For example, if you are upgrading Camel 4.0 to 4.2, then you should follow the guides +from both 4.0 to 4.1 and 4.1 to 4.2. + +[NOTE] +==== +https://github.com/apache/camel-upgrade-recipes/[The Camel Upgrade Recipes project] provides automated assistance for some common migration tasks. +Note that manual migration is still required. +See the xref:camel-upgrade-recipes-tool.adoc[documentation] page for details. +==== + +== Upgrading Camel 4.23 to 4.24 + +=== camel-openai, camel-ai-tool - AI events now use CamelEvent.Type.Ai + +The events fired by the AI components now share a common contract, `org.apache.camel.ai.AiEvent` (a +`CamelEvent.ExchangeEvent` of the new `CamelEvent.Type.Ai`), instead of each being a component-specific +`CamelEvent.Type.Custom` event. This lets an `EventNotifier` recognise AI activity â and route it to metrics or +tracing â by type and by the `AiEvent` sub-interfaces, without depending on an AI component. + +The events shipped in 4.23.0 are affected: + +* `camel-ai-tool`: `AiToolAuthorizationDeniedEvent` now implements `AiEvent.ToolCallDeniedEvent`; +* `camel-openai`: `OpenAIAgenticLoopStartedEvent`, `OpenAIAgenticToolCallExecutedEvent` and + `OpenAIAgenticLoopCompletedEvent` now implement `AiEvent.AgentLoopStartedEvent`, `AiEvent.ToolCallExecutedEvent` + and `AiEvent.AgentLoopCompletedEvent`. + +Their `getType()` now returns `CamelEvent.Type.Ai` rather than `CamelEvent.Type.Custom`, and they are now +`CamelEvent.ExchangeEvent` instances. An `EventNotifier` that recognised these events by +`event.getType() == CamelEvent.Type.Custom` must match on `CamelEvent.Type.Ai` instead, or â preferably â +on `event instanceof org.apache.camel.ai.AiEvent` (or one of its sub-interfaces), which no longer requires a +dependency on the AI component. The concrete event classes and all their accessors are unchanged, so code that +references them directly is not affected. + +Because an `AiEvent` is now a `CamelEvent.ExchangeEvent`, a notifier that filters on `instanceof ExchangeEvent` +now also receives AI events. AI events are their own category: a new `ignoreAiEvents` flag +(`EventNotifier.setIgnoreAiEvents(boolean)`, default `false`) opts a notifier out, and `ignoreExchangeEvents` does +**not** drop AI events (so an AI-observability notifier can keep `ignoreExchangeEvents=true` for performance). Camel's +own exchange-oriented notifiers (the debugger, the dev-console event ring, the micrometer exchange notifier) set +`ignoreAiEvents=true` so AI events do not reach them; a custom exchange-focused notifier that should not see AI events +should do the same. Review Comment: âšī¸ **`Custom.ordinal()` shift not documented (not fixed from prior review)** Inserting `Type.Ai` before `Type.Custom` changes `Custom.ordinal()` from its previous value. The upgrade guide covers string-based migration but says nothing about the ordinal change. Users serialising the enum as an integer (Avro schemas, database columns, configuration files) will silently decode the wrong type after upgrading. ```suggestion should do the same. Note also that inserting `Type.Ai` before `Type.Custom` in the enum shifts `Type.Custom.ordinal()` from its previous value. Users who serialise `CamelEvent.Type` as an integer (Avro schemas, database columns, config files) must migrate those values. ``` -- 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]
