Skip to content

Commit eb7a05e

Browse files
committed
fix: Add no-arg overload for getUserInput() in RequestContext to avoid
passing null for default delimiter. FIxes issue #668 Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com>
1 parent e8fd7f2 commit eb7a05e

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

‎server-common/src/main/java/io/a2a/server/agentexecution/RequestContext.java‎

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,24 @@ public List<Task> getRelatedTasks() {
224224
return params != null ? params.tenant() : null;
225225
}
226226

227+
/**
228+
* Extracts all text content from the message and joins with the newline delimiter.
229+
* <p>
230+
* This is a convenience method for getting text input from messages that may contain
231+
* multiple text parts. Non-text parts (images, etc.) are ignored.
232+
* <p>
233+
* <b>Examples:</b>
234+
* <pre>{@code
235+
* // Join with newlines (common for multi-paragraph input)
236+
* String text = context.getUserInput("\n");
237+
* }</pre>
238+
*
239+
* @return all text parts joined with newline, or empty string if no message
240+
*/
241+
public String getUserInput() {
242+
return getUserInput("\n");
243+
}
244+
227245
/**
228246
* Extracts all text content from the message and joins with the specified delimiter.
229247
* <p>
@@ -245,12 +263,13 @@ public List<Task> getRelatedTasks() {
245263
* @param delimiter the string to insert between text parts (null defaults to "\n")
246264
* @return all text parts joined with delimiter, or empty string if no message
247265
*/
248-
public String getUserInput(String delimiter) {
266+
public String getUserInput(@Nullable String delimiter) {
249267
if (params == null) {
250268
return "";
251269
}
270+
String delim = delimiter;
252271
if (delimiter == null) {
253-
delimiter = "\n";
272+
delim = "\n";
254273
}
255274
return getMessageText(params.message(), delimiter);
256275
}

0 commit comments

Comments
 (0)