oscerd commented on code in PR #27714: URL: https://github.com/apache/camel/pull/27714#discussion_r4246747321
########## 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: Already fixed — the root `AiEvent` class javadoc is `@since 4.24` as of the split commit 051b7b1739e4 (I rewrote the file there; 044b4b4c had only bumped the sub-interfaces). Confirmed on the current head. _Claude Code on behalf of oscerd_ ########## 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: Moot now — 051b7b1739e4 appends `Type.Ai` LAST in the enum, so no pre-existing ordinal (including `Custom`) shifts. No integer-serialisation note needed. _Claude Code on behalf of oscerd_ ########## 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 Review Comment: Fixed in 131b9fe60539 — the guide now describes `AiEvent` as a `CamelEvent` of `Type.Ai` (not an `ExchangeEvent`) and notes that exchange-related events implement the `AiEvent.ExchangeAiEvent` subtype. _Claude Code on behalf of oscerd_ ########## 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 Review Comment: Fixed in 131b9fe60539 — reworded to '`CamelEvent.ExchangeEvent`s (via `AiEvent.ExchangeAiEvent`)', which refers to the four shipped events (they implement the subtype), not all AI events. _Claude Code on behalf of oscerd_ ########## 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` Review Comment: Fixed in 131b9fe60539 — now reads 'the shipped AI events are now `ExchangeEvent`s (via `AiEvent.ExchangeAiEvent`)', not the root `AiEvent`. _Claude Code on behalf of oscerd_ ########## core/camel-api/src/main/java/org/apache/camel/spi/EventNotifier.java: ########## @@ -133,6 +133,24 @@ public interface EventNotifier { /** Set whether to ignore step events. */ void setIgnoreStepEvents(boolean ignoreStepEvents); + /** + * Whether to ignore AI events (see {@link org.apache.camel.ai.AiEvent}). AI events are their own category and are + * not affected by {@link #isIgnoreExchangeEvents()} even though an {@code AiEvent} is an exchange event. Review Comment: Fixed in 131b9fe60539 — the javadoc now says the flag is unaffected by `isIgnoreExchangeEvents()` 'even for the exchange-backed `ExchangeAiEvent` subtype', instead of calling `AiEvent` an exchange event. _Claude Code on behalf of oscerd_ -- 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]
