Skip to content

feat: Move the sendMessage with a MessageSendParams to the AbstractClient#665

Open
jmesnil wants to merge 1 commit intoa2aproject:mainfrom
jmesnil:663_SendMessage_with_params
Open

feat: Move the sendMessage with a MessageSendParams to the AbstractClient#665
jmesnil wants to merge 1 commit intoa2aproject:mainfrom
jmesnil:663_SendMessage_with_params

Conversation

@jmesnil
Copy link
Collaborator

@jmesnil jmesnil commented Feb 17, 2026

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

@gemini-code-assist
Copy link
Contributor

Warning

Gemini encountered an error creating the summary. You can try again by commenting /gemini summary.

@jmesnil
Copy link
Collaborator Author

jmesnil commented Feb 17, 2026

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +317 to +320
} else {
// must be a message
clientEvent = new MessageEvent((Message) eventKind);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
} 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());
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@jmesnil jmesnil force-pushed the 663_SendMessage_with_params branch from 8b7e51e to 8c34bf5 Compare February 17, 2026 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Client API to send a message does not provide a tenant parameter.

1 participant