feat: Move the sendMessage with a MessageSendParams to the AbstractClient#665
feat: Move the sendMessage with a MessageSendParams to the AbstractClient#665jmesnil wants to merge 1 commit intoa2aproject:mainfrom
Conversation
|
Warning Gemini encountered an error creating the summary. You can try again by commenting |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors the sendMessage method that takes MessageSendParams by moving it to the AbstractClient and making it public. This change provides more control over message sending parameters. The implementation has been moved from a private method in the Client class to an override of the new abstract method. The changes look good and achieve the stated goal. I have a couple of suggestions to improve code consistency and robustness.
| } else { | ||
| // must be a message | ||
| clientEvent = new MessageEvent((Message) eventKind); | ||
| } |
There was a problem hiding this comment.
The else block assumes that if eventKind is not a Task, it must be a Message. This is risky as it could lead to a ClassCastException if EventKind has other implementations in the future. It's safer to explicitly check for Message and handle unexpected types, similar to the pattern used in getClientEvent. This also allows you to use pattern matching for Message and avoid the cast.
| } else { | |
| // must be a message | |
| clientEvent = new MessageEvent((Message) eventKind); | |
| } | |
| } else if (eventKind instanceof Message message) { | |
| clientEvent = new MessageEvent(message); | |
| } else { | |
| throw new A2AClientInvalidStateError("Unexpected event kind from non-streaming sendMessage: " + eventKind.getClass().getName()); | |
| } |
There was a problem hiding this comment.
That's fine. The spec says that the only acceptable response for a SendMessage is a Message or a Task (https://github.com/a2aproject/A2A/blob/73d5f59a322eec5d15f6698d8bd34fb17019d438/specification/a2a.proto#L783-L789)
…ient and made it public. Thought it might not be widely used, it allows full control of the parameters sent by the request (including the tenant). This fixes a2aproject#663 Signed-off-by: Jeff Mesnil <jmesnil@ibm.com>
8b7e51e to
8c34bf5
Compare
and made it public.
Thought it might not be widely used, it allows full control of the parameters sent by the request (including the tenant).
This fixes #663