[ 
https://issues.apache.org/jira/browse/CAMEL-25931?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18131073#comment-18131073
 ] 

Claus Ibsen commented on CAMEL-25931:
-------------------------------------

[~ldemasi] as you added camel-a2a (CAMEL-23063), could you take a look at this 
one? We left it out of the batch of body type bug fixes, as it needs a design 
choice. Two options:

*a)* The consumer keeps what it needs for its reply (its task id, its context 
id and the method that was called) in exchange properties, and builds the reply 
from those, so a producer in the route cannot change them. The producer ignores 
a {{CamelA2AOperation}} header that the consumer set, as that header describes 
the incoming call, so the {{operation}} option of the producer applies; a 
header the route sets itself still selects the operation. The {{CamelA2A*}} 
headers stay on the message for the route to read, and the documentation says 
which ones steer a producer and which ones are results. Open point: 
{{CamelA2ATaskState}} and {{CamelA2AResponseType}} are both results of a 
producer and inputs of the consumer's reply, so they need either their own 
names for the reply or the rule that a producer's result does not change the 
reply.

*b)* Documentation only for now: say to remove the {{CamelA2A*}} headers before 
calling another agent, and do the design later.

We would go with a), but you know the protocol and the intended use best: which 
do you prefer, or do you see a better way?

_Claude Code on behalf of davsclaus_

> camel-a2a - an agent that calls another agent mixes their headers: the 
> producer runs the operation of the consumer, and the reply takes the other 
> agent's task
> --------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-25931
>                 URL: https://issues.apache.org/jira/browse/CAMEL-25931
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-ai
>    Affects Versions: 4.21.0, 4.22.0, 4.23.0
>            Reporter: Claus Ibsen
>            Priority: Major
>             Fix For: 4.24.0
>
>
> An agent route that calls another agent, as an orchestrator does, shares the 
> {{CamelA2A*}} headers between its consumer and the producer, in both 
> directions.
> *1. The producer runs the operation of the consumer.* The consumer sets 
> {{CamelA2AOperation}} on the exchange of the route to the method of the call: 
> {{SendMessage}}, or {{SendStreamingMessage}} for a streaming call 
> ({{MessageSendOperation.java:139}} and {{A2AConsumer.java:1508}} on main). 
> The producer takes its operation from that header first, and uses its 
> {{operation}} option only when the header is absent 
> ({{A2AProducer.resolveOperation}}, {{A2AProducer.java:239-253}}):
> {code:java}
> String headerOp = exchange.getMessage().getHeader(A2AConstants.OPERATION, 
> String.class);
> if (headerOp != null) {
>     // Try method name first
>     A2AOperations operation = A2AOperations.fromMethodName(headerOp);
>     if (operation != null) {
>         return operation;
>     }
> {code}
> So, in the route of an agent:
> * {{to("a2a:...?operation=TASK_GET")}}, or any other operation, sends a 
> SendMessage;
> * a call with the default operation (MESSAGE_SEND) streams when the caller 
> streamed, and the body is then an {{SseEventIterator}} instead of the text of 
> the answer.
> *2. The reply takes the task of the other agent.* The consumer puts the id of 
> its own task in {{CamelA2ATaskId}} before the route 
> ({{A2AConsumer.java:1202}} and {{:1506}}). A SendMessage that gets a Task 
> back overwrites {{CamelA2ATaskId}}, {{CamelA2AContextId}}, 
> {{CamelA2ATaskState}} and {{CamelA2AResponseType}} with the values of the 
> other agent ({{MessageSendOperation.java:84-96}}). After the route, the 
> consumer builds its reply from these headers 
> ({{MessageSendOperation.buildResponse}}, {{:146-149}}), so the caller gets a 
> Task with the id, the context and the state of the other agent's task.
> Found by reading the code on 4.24.0-SNAPSHOT. It is so since the component 
> was added (CAMEL-23063, 4.21.0).
> *Proposed change*: keep what the consumer needs for its reply apart from the 
> headers that steer a producer, for example in exchange properties, so a 
> producer in the route neither reads the consumer's operation nor changes the 
> consumer's task. Until then, the documentation can say to remove the 
> {{CamelA2A*}} headers before calling another agent.
> _Claude Code on behalf of davsclaus_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to