diff --git a/server-common/src/main/java/io/a2a/server/agentexecution/RequestContext.java b/server-common/src/main/java/io/a2a/server/agentexecution/RequestContext.java index beee9bf7e..9c2aa578f 100644 --- a/server-common/src/main/java/io/a2a/server/agentexecution/RequestContext.java +++ b/server-common/src/main/java/io/a2a/server/agentexecution/RequestContext.java @@ -224,6 +224,24 @@ public List getRelatedTasks() { return params != null ? params.tenant() : null; } + /** + * Extracts all text content from the message and joins with the newline delimiter. + *

+ * This is a convenience method for getting text input from messages that may contain + * multiple text parts. Non-text parts (images, etc.) are ignored. + *

+ * Examples: + *

{@code
+     * // Join with newlines (common for multi-paragraph input)
+     * String text = context.getUserInput("\n");
+     * }
+ * + * @return all text parts joined with newline, or empty string if no message + */ + public String getUserInput() { + return getUserInput("\n"); + } + /** * Extracts all text content from the message and joins with the specified delimiter. *

@@ -245,14 +263,15 @@ public List getRelatedTasks() { * @param delimiter the string to insert between text parts (null defaults to "\n") * @return all text parts joined with delimiter, or empty string if no message */ - public String getUserInput(String delimiter) { + public String getUserInput(@Nullable String delimiter) { if (params == null) { return ""; } + String delim = delimiter; if (delimiter == null) { - delimiter = "\n"; + delim = "\n"; } - return getMessageText(params.message(), delimiter); + return getMessageText(params.message(), delim); } /**