oscerd commented on code in PR #27714: URL: https://github.com/apache/camel/pull/27714#discussion_r4246562784
########## 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 + */ +public interface AiEvent extends CamelEvent.ExchangeEvent { Review Comment: Done in 051b7b1739e4 — `AiEvent` now extends `CamelEvent` (not `ExchangeEvent`), and the four tool/loop sub-interfaces sit on a new `AiEvent.ExchangeAiEvent extends AiEvent, CamelEvent.ExchangeEvent`; `AbstractOpenAIExchangeEvent` moved onto it, accessors unchanged. An Exchange-free `AiEvent` dispatches fine through `EventHelper.notifyAiEvent` (new test `dispatchesAnAiEventThatHasNoExchange`). Thanks for the Semantic pointer — this keeps `SemanticObserver` / `audit.begin(null, ...)` able to publish without a synthetic exchange. _Claude Code on behalf of oscerd_ ########## 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 + */ +public interface AiEvent extends CamelEvent.ExchangeEvent { + + /** + * The AI provider the event originates from, e.g. {@code openai} or {@code ai-tool}. Intended as a low-cardinality + * label for metrics and spans. Review Comment: Applied — `getProvider()` now documents a stable integration/provider family (`openai`, `ai-tool`, `semantic`), explicitly not an expert instance, model revision, invocation id, or an inference indicator (051b7b1739e4). _Claude Code on behalf of oscerd_ ########## 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 Review Comment: Addressed two ways: (1) the root `AiEvent` no longer extends `ExchangeEvent` — only the new `ExchangeAiEvent` subtype does, which is what the four shipped events implement; (2) the notifiers that branch on `instanceof ExchangeEvent` — `EventConsole`, `DefaultDebugger`, `MicrometerExchangeEventNotifier` — now set `ignoreAiEvents(true)`, and AI events are fired via `EventHelper.notifyAiEvent` which skips them, so they no longer reach the console ring / debugger / per-event route lookup. `camel-event` gets a `case Ai`. The 4.24 upgrade guide documents the ExchangeEvent reach and the `ignoreAiEvents` opt-out. _Claude Code on behalf of oscerd_ ########## 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. Review Comment: Fixed — `@since 4.24` on `AiEvent` and all new types (044b4b4c29c6). _Claude Code on behalf of oscerd_ ########## core/camel-api/src/main/java/org/apache/camel/spi/CamelEvent.java: ########## @@ -81,6 +81,13 @@ enum Type { StepStarted, StepCompleted, StepFailed, + /** + * Events fired by Camel AI components (tool calls, agentic loops, ...); see + * {@link org.apache.camel.ai.AiEvent}. + * + * @since 4.24 + */ + Ai, Review Comment: `Type.Ai` is now appended last in the enum (051b7b1739e4), so every pre-existing ordinal (including `Custom`) is unchanged. No ordinal shift, so no note needed for integer-serialised enums. _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]
