alibaba/spring-ai-alibaba · error · IllegalStateException
No valid text content found in result:
Error message
No valid text content found in result:
What it means
After checking status-update, artifact, and message/message parts shapes, extractResponseText could not find any text content in the result map and throws this IllegalStateException including the full result for debugging. The result parsed fine structurally, but it contained no text part.
Source
Thrown at spring-ai-alibaba-agent-framework/src/main/java/com/alibaba/cloud/ai/graph/agent/a2a/A2aNodeActionWithConfig.java:667
}
}
}
if (result.containsKey("message")) {
Map<String, Object> message = (Map<String, Object>) result.get("message");
if (message != null && message.containsKey("parts")) {
List<Object> parts = (List<Object>) message.get("parts");
if (parts != null && !parts.isEmpty()) {
Map<String, Object> lastPart = (Map<String, Object>) parts.get(parts.size() - 1);
if (lastPart != null) {
String text = (String) lastPart.get("text");
if (text != null) {
return text;
}
}
}
}
}
throw new IllegalStateException("No valid text content found in result: " + result);
}
/**
* Build the JSON-RPC request payload to send to the A2A server.
* @param state Parent state
* @return JSON string payload (e.g., JSON-RPC params)
*/
private String buildSendMessageRequest(OverAllState state, RunnableConfig config) {
Object textValue = getEffectiveInstruction(state);
String text = String.valueOf(textValue);
String id = UUID.randomUUID().toString();
String messageId = UUID.randomUUID().toString().replace("-", "");
Map<String, Object> part = Map.of("kind", "text", "text", text);
Map<String, Object> message = new HashMap<>();
message.put("kind", "message");View on GitHub (pinned to f82da0b50f)
Solutions
- Inspect the printed result and make the remote agent emit a text part (TextPart) in its final message or artifact
- Handle non-text parts yourself by reading the result map (e.g. artifact data parts) instead of relying on extractResponseText
- Check the agent's task state — a failed/canceled task won't carry final text; handle state first
- Update the library version if the server uses a newer A2A event shape the extractor doesn't know
Example fix
// before
// server sends only data parts -> extractor throws
// after
// server: new TextPart("analysis complete") in final Artifact/Message Defensive patterns
Strategy: try-catch
Validate before calling
Object kind = result != null ? result.get("kind") : null;
boolean hasText = kind != null && ("status-update".equals(kind) || "artifact-update".equals(kind) || "message".equals(kind)); Try / catch
try {
String text = action.responseText(result);
} catch (IllegalStateException e) {
// e.getMessage() contains the full result dump; inspect and handle non-text parts
} Prevention
- Make remote agents include a TextPart in final messages/artifacts
- Handle failed/canceled task states before extracting text
- Test against the real remote agent's event payloads
When it happens
Trigger: The A2A result is a valid event kind (e.g. status-update with a non-working state, or artifact-update with only non-text parts like binary/file parts), or the message has no TextPart entries, so all extraction branches fall through to the throw.
Common situations: Remote agent returns file/data parts instead of text; status-update with state=failed carrying error metadata but no message text; A2A server returns a custom event kind not covered by the extractor.
Related errors
- Result is null, cannot extract response text
- Failed to parse any valid result from streaming response
- Failed to build JSON-RPC payload
- Failed to build JSON-RPC streaming payload
- Instruction is empty and shareState is false
AI-assisted analysis of alibaba/spring-ai-alibaba@f82da0b50f (2026-09-09).
Data as JSON: /api/errors/1494b69db2f4dcae.
Report an issue: GitHub.