[
https://issues.apache.org/jira/browse/CAMEL-23776?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Luigi De Masi updated CAMEL-23776:
----------------------------------
Description:
CAMEL-23063 introduces A2A progress event emission from Camel routes through
the Simple language function:
{code}
${a2a:emit('Searching docs...')}
{code}
This allows route authors to emit progress updates, but common use cases
require several explicit route steps around the actual work being performed.
For example, a route may need to emit a progress event before a search, another
event after the search succeeds, and another event if the search fails.
This improvement proposes adding an {{a2aSubTask}} route/EIP step for scoped
A2A progress events.
The step should group nested route outputs and optionally emit A2A progress
events:
* {{emitBefore}}
* {{emitAfter}}
* {{emitOnError}}
All emit fields are optional and should support Simple expressions.
{{emitOnError}} must be able to access {{${exception.message}}}. The original
exception must still propagate after the error progress event is emitted.
Example:
{code:java}
steps:
- a2aSubTask:
emitBefore: Searching docs...
emitAfter: 'Docs found: ${body.size()}'
emitOnError: 'Error searching docs: ${exception.message}'
steps:
- to:
uri: 'elasticsearch:docs?operation=Search'
- a2aSubTask:
emitBefore: Drafting answer...
emitAfter: 'Answer drafted: ${body}'
emitOnError: 'Error drafting answer: ${exception.message}'
steps:
- bean:
ref: answerDraftingService
method: draft
- setBody:
simple: 'Final answer: ${body}'
{code}
The emitted messages should support Simple expressions and should be evaluated
against the current Exchange at the time each event is emitted.
h3. Expected behavior:
* {{emitBefore}} is evaluated and emitted before the nested steps are executed.
* {{emitAfter}} is evaluated and emitted after the nested steps complete
successfully.
* {{emitOnError}} is evaluated and emitted when the nested steps throw an
exception.
* {{emitOnError}} must not swallow, replace, or hide the original exception.
* All emit fields are optional.
* The step should support one or more nested Camel route steps.
* The nested steps should behave like normal route steps.
* Existing {{${a2a:emit(...)}}} support remains available and unchanged.
h3. The implementation should follow Camel’s standard model-based EIP approach,
similar to kamelet / circuit-breaker:
* define {{a2aSubTask}} in {{core/camel-core-model}}
* let generated DSL/catalog/tooling support expose it consistently to Java
DSL, XML DSL, YAML DSL, CLI, catalog, and other tooling
* keep the runtime implementation in {{camel-a2a}} using a component-provided
processor/factory
* do not implement this as an A2A-specific YAML DSL deserializer extension
h3. Acceptance criteria:
* {{a2aSubTask}} is represented in the core Camel model
* YAML support comes from generated model DSL support, not from a custom A2A
YAML resolver
* Java/model DSL usage is supported, not YAML-only
* runtime processor implementation lives in {{camel-a2a}}
* tests cover:
* success path
* failure path
* no emit fields configured
* only one emit configured
* multiple nested steps
* {{emitOnError}} with {{${exception.message}}}
* original exception propagation
* docs describe this as a Camel route/EIP step, not a YAML-only extension
was:
CAMEL-23063 introduces A2A progress event emission from Camel routes through
the Simple language function:
${a2a:emit('Searching docs...')}
This allows route authors to emit progress updates, but common use cases
require several explicit route steps around the actual work being performed.
For example, a route may need to emit a progress event before a search, another
event after the search succeeds, and another event if the search fails.
This improvement proposes adding an `a2aSubTask` YAML route step in camel-a2a.
The `a2aSubTask` step should group one or more nested Camel route steps and
emit A2A progress events around that grouped work.
Example:
{code:java}
steps:
- a2aSubTask:
emitBefore: Searching docs...
emitAfter: 'Docs found: ${body.size()}'
emitOnError: 'Error searching docs: ${exception.message}'
steps:
- to:
uri: 'elasticsearch:docs?operation=Search'
- a2aSubTask:
emitBefore: Drafting answer...
emitAfter: 'Answer drafted: ${body}'
emitOnError: 'Error drafting answer: ${exception.message}'
steps:
- bean:
ref: answerDraftingService
method: draft
- setBody:
simple: 'Final answer: ${body}'
{code}
The emitted messages should support Simple expressions and should be evaluated
against the current Exchange at the time each event is emitted.
Expected behavior:
* `emitBefore` is evaluated and emitted before the nested steps are executed.
* `emitAfter` is evaluated and emitted after the nested steps complete
successfully.
* `emitOnError` is evaluated and emitted when the nested steps throw an
exception.
* `emitOnError` must not swallow, replace, or hide the original exception.
* All emit fields are optional.
* The step should support one or more nested Camel route steps.
* The nested steps should behave like normal route steps.
* Existing `${a2a:emit(...)}` support remains available and unchanged.
Implementation notes:
* This issue should add the A2A-specific route model/reifier/processor support
needed by `a2aSubTask`.
* The YAML parser integration should use the generic YAML DSL extension
mechanism tracked separately.
* The YAML DSL core should not hard-code the `a2aSubTask` step.
Acceptance criteria:
* `camel-a2a` provides an `a2aSubTask` YAML route step.
* `a2aSubTask` supports nested `steps`.
* `emitBefore`, `emitAfter`, and `emitOnError` are optional.
* Emit message templates are evaluated as Simple expressions.
* `emitOnError` can access the exception through `${exception.message}`.
* Exceptions from nested steps continue to propagate normally.
* Tests cover successful execution, failure execution, no emit fields, only
one emit field, and multiple nested steps.
* Documentation includes the new YAML syntax and at least one full route
example.
> camel-a2a: Add a2aSubTask YAML route step for scoped progress events
> --------------------------------------------------------------------
>
> Key: CAMEL-23776
> URL: https://issues.apache.org/jira/browse/CAMEL-23776
> Project: Camel
> Issue Type: Improvement
> Reporter: Luigi De Masi
> Assignee: Luigi De Masi
> Priority: Major
>
> CAMEL-23063 introduces A2A progress event emission from Camel routes through
> the Simple language function:
> {code}
> ${a2a:emit('Searching docs...')}
> {code}
> This allows route authors to emit progress updates, but common use cases
> require several explicit route steps around the actual work being performed.
> For example, a route may need to emit a progress event before a search,
> another event after the search succeeds, and another event if the search
> fails.
> This improvement proposes adding an {{a2aSubTask}} route/EIP step for scoped
> A2A progress events.
> The step should group nested route outputs and optionally emit A2A progress
> events:
> * {{emitBefore}}
> * {{emitAfter}}
> * {{emitOnError}}
> All emit fields are optional and should support Simple expressions.
> {{emitOnError}} must be able to access {{${exception.message}}}. The original
> exception must still propagate after the error progress event is emitted.
> Example:
> {code:java}
> steps:
> - a2aSubTask:
> emitBefore: Searching docs...
> emitAfter: 'Docs found: ${body.size()}'
> emitOnError: 'Error searching docs: ${exception.message}'
> steps:
> - to:
> uri: 'elasticsearch:docs?operation=Search'
> - a2aSubTask:
> emitBefore: Drafting answer...
> emitAfter: 'Answer drafted: ${body}'
> emitOnError: 'Error drafting answer: ${exception.message}'
> steps:
> - bean:
> ref: answerDraftingService
> method: draft
> - setBody:
> simple: 'Final answer: ${body}'
> {code}
> The emitted messages should support Simple expressions and should be
> evaluated against the current Exchange at the time each event is emitted.
> h3. Expected behavior:
> * {{emitBefore}} is evaluated and emitted before the nested steps are
> executed.
> * {{emitAfter}} is evaluated and emitted after the nested steps complete
> successfully.
> * {{emitOnError}} is evaluated and emitted when the nested steps throw an
> exception.
> * {{emitOnError}} must not swallow, replace, or hide the original exception.
> * All emit fields are optional.
> * The step should support one or more nested Camel route steps.
> * The nested steps should behave like normal route steps.
> * Existing {{${a2a:emit(...)}}} support remains available and unchanged.
>
> h3. The implementation should follow Camel’s standard model-based EIP
> approach, similar to kamelet / circuit-breaker:
> * define {{a2aSubTask}} in {{core/camel-core-model}}
> * let generated DSL/catalog/tooling support expose it consistently to Java
> DSL, XML DSL, YAML DSL, CLI, catalog, and other tooling
> * keep the runtime implementation in {{camel-a2a}} using a
> component-provided processor/factory
> * do not implement this as an A2A-specific YAML DSL deserializer extension
> h3. Acceptance criteria:
> * {{a2aSubTask}} is represented in the core Camel model
> * YAML support comes from generated model DSL support, not from a custom A2A
> YAML resolver
> * Java/model DSL usage is supported, not YAML-only
> * runtime processor implementation lives in {{camel-a2a}}
> * tests cover:
> * success path
> * failure path
> * no emit fields configured
> * only one emit configured
> * multiple nested steps
> * {{emitOnError}} with {{${exception.message}}}
> * original exception propagation
> * docs describe this as a Camel route/EIP step, not a YAML-only extension
--
This message was sent by Atlassian Jira
(v8.20.10#820010)