From 03c189e1c2c4e11ddadf0694394c62d22d0739c9 Mon Sep 17 00:00:00 2001 From: Emmanuel Hugonnet Date: Wed, 18 Feb 2026 17:53:24 +0100 Subject: [PATCH] fix: Add no-arg overload for getUserInput() in RequestContext to avoid passing null for default delimiter. Fixes issue #668 Signed-off-by: Emmanuel Hugonnet --- .../server/agentexecution/RequestContext.java | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) 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); } /**