luigidemasi commented on code in PR #28501:
URL: https://github.com/apache/camel/pull/28501#discussion_r4376583322


##########
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:
   `REQUEST_MESSAGE` is deliberately an exchange property only. Annotating it 
here would make 
[EndpointSchemaGeneratorMojo](https://github.com/apache/camel/blob/ac91f4d511ac0eb1d6a4e130da01628cee9adaf9/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/EndpointSchemaGeneratorMojo.java#L377-L468)
 advertise a message header that the consumer never sets.
   
   
[bb9dacb26e38](https://github.com/apache/camel/commit/bb9dacb26e389b02f9b33f841e1237e7dfbf5fb4)
 adds that explanation beside the constant and in the consumer guide, while 
keeping the field unannotated.
   
   _OpenAI Codex on behalf of @luigidemasi._



##########
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:
   Kept reference identity intentionally: only the original consumer `Message` 
instance has its incoming IDs stripped. A new message supplied by the route 
retains its IDs, including a value-equal copy. Switching to `.equals()` would 
strip deliberately retained IDs from such a copy.
   
   
[bb9dacb26e38](https://github.com/apache/camel/commit/bb9dacb26e389b02f9b33f841e1237e7dfbf5fb4)
 makes this contract explicit in the guide and migration notes and adds eight 
regression cases across both send operations: equal copies, edited copies, 
cleared IDs and selected downstream IDs. The docs explain clearing inherited 
IDs with `.taskId(null).contextId(null)` when a copy starts a new downstream 
conversation. 
[ac91f4d511ac](https://github.com/apache/camel/commit/ac91f4d511ac0eb1d6a4e130da01628cee9adaf9)
 also documents at both checks that removing the consumer-owned 
`REQUEST_MESSAGE` property disables stripping.
   
   _OpenAI Codex on behalf of @luigidemasi._



-- 
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]

Reply via email to