gnodet-bot commented on code in PR #28501:
URL: https://github.com/apache/camel/pull/28501#discussion_r4375676440
##########
components/camel-ai/camel-a2a/src/main/java/org/apache/camel/component/a2a/A2AConstants.java:
##########
@@ -25,19 +25,35 @@ public final class A2AConstants {
@Metadata(label = "producer", description = "A2A operation to invoke",
javaType = "String")
public static final String OPERATION = "CamelA2AOperation";
- @Metadata(label = "common", description = "Task ID", javaType = "String")
+ @Metadata(label = "consumer", description = "Incoming operation, also
retained as an exchange property",
+ javaType = "String")
+ public static final String REQUEST_OPERATION = "CamelA2ARequestOperation";
+ @Metadata(label = "consumer", description = "Consumer task ID, also
retained as an exchange property", javaType = "String")
+ public static final String REQUEST_TASK_ID = "CamelA2ARequestTaskId";
+ @Metadata(label = "consumer", description = "Consumer context ID, also
retained as an exchange property",
+ javaType = "String")
+ public static final String REQUEST_CONTEXT_ID = "CamelA2ARequestContextId";
+ @Metadata(label = "consumer", description = "Task state to return from
SendMessage; defaults to TASK_STATE_COMPLETED",
+ javaType = "String")
+ public static final String REPLY_TASK_STATE = "CamelA2AReplyTaskState";
+ @Metadata(label = "consumer", description = "SendMessage reply type: task
(default) or message", javaType = "String")
+ public static final String REPLY_TYPE = "CamelA2AReplyType";
+ public static final String REQUEST_MESSAGE = "CamelA2ARequestMessage";
+ @Metadata(label = "producer", description = "Downstream task ID for
producer requests and responses", javaType = "String")
Review Comment:
⚠️ **Missing `@Metadata` annotation.** Every sibling constant in this block
(`REQUEST_OPERATION`, `REQUEST_TASK_ID`, `REQUEST_CONTEXT_ID`,
`REPLY_TASK_STATE`, `REPLY_TYPE`) has a `@Metadata` annotation with `label`,
`description`, and `javaType`. `REQUEST_MESSAGE` is the only new constant that
doesn't — the catalog/tooling will silently ignore it. Add something like:
```suggestion
@Metadata(label = "consumer", description = "Original consumer Message
stored as an exchange property; used to detect identity-forwarding in nested
agent calls", javaType = "org.apache.camel.component.a2a.model.Message")
public static final String REQUEST_MESSAGE = "CamelA2ARequestMessage";
```
##########
components/camel-ai/camel-a2a/src/main/java/org/apache/camel/component/a2a/operation/MessageSendOperation.java:
##########
@@ -49,7 +49,9 @@ public Object buildRequest(Exchange exchange) {
Object body = exchange.getMessage().getBody();
if (body instanceof Message msg) {
- message = msg;
+ // An unchanged consumer message carries the outer agent's
identity, not the peer's.
+ message = msg == exchange.getProperty(A2AConstants.REQUEST_MESSAGE)
+ ?
Message.builder(msg).taskId(null).contextId(null).build() : msg;
Review Comment:
⚠️ **Reference equality (`==`) on a `record` type.** `Message` is a record,
so any route that creates a copy via `Message.builder(msg).build()` will
produce a new instance that is `equals()`-equivalent but not `==`-identical —
the identity-stripping logic silently skips, and the consumer's task/context
IDs bleed into the downstream call.
Consider using `.equals()` (safe even if `msg` or the property is `null`
with a null-check), or test directly on the fields you actually care about:
```suggestion
message =
msg.equals(exchange.getProperty(A2AConstants.REQUEST_MESSAGE))
?
Message.builder(msg).taskId(null).contextId(null).build() : msg;
```
--
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]