alibaba/spring-ai-alibaba · error · IllegalStateException
Failed to parse any valid result from streaming response
Error message
Failed to parse any valid result from streaming response
What it means
parseStreamingResponse iterates SSE/stream chunks from an A2A server trying to extract a valid result; if no chunk could be parsed into a usable result by the end of the stream, it throws this IllegalStateException. It means the remote agent streamed nothing parseable (or only heartbeat/unknown events).
Source
Thrown at spring-ai-alibaba-agent-framework/src/main/java/com/alibaba/cloud/ai/graph/agent/a2a/A2aNodeActionWithConfig.java:537
try {
Map<String, Object> parsed = JSON.parseObject(jsonContent,
new TypeReference<Map<String, Object>>() {
});
Map<String, Object> result = (Map<String, Object>) parsed.get("result");
if (result != null) {
if (result.containsKey("artifact") || lastResult == null) {
lastResult = result;
}
}
}
catch (Exception e) {
continue;
}
}
}
if (lastResult == null) {
throw new IllegalStateException("Failed to parse any valid result from streaming response");
}
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("result", lastResult);
return resultMap;
}
private String extractResponseText(Map<String, Object> result) {
if (result == null) {
throw new IllegalStateException("Result is null, cannot extract response text");
}
if ("status-update".equals(result.get("kind"))) {
Map<String, Object> status = (Map<String, Object>) result.get("status");
if (status != null) {
String state = (String) status.get("state");
if ("completed".equals(state)) {
return "";
}View on GitHub (pinned to f82da0b50f)
Solutions
- Verify the remote A2A server is up and the AgentCard.url points to the JSON-RPC/stream endpoint, not a UI or docs page
- Check server-side logs for the request; ensure the agent actually emits message/stream events (status-update/artifact-update)
- Upgrade or align the A2A protocol version on both client and server so event shapes match what parseStreamingResponse expects
- Wrap the call and retry or fall back to the non-streaming message/send endpoint
Example fix
// before String url = "https://host/"; // UI root, not the A2A endpoint // after String url = agentCard.url(); // e.g. https://host/a2a/v1
Defensive patterns
Strategy: retry
Validate before calling
// pre-check: ensure the endpoint answers before streaming // e.g. fetch agent card: if (agentCard.url() == null || agentCard.url().isBlank()) fail fast;
Try / catch
try {
Map<String,Object> result = action.autoDetectAndParseResponse(...);
} catch (IllegalStateException e) {
// log stream contents/endpoint, retry once, then fall back to non-streaming message/send
} Prevention
- Point AgentCard.url at the actual A2A JSON-RPC/stream endpoint
- Confirm the remote agent emits status-update/artifact-update events
- Keep client and server A2A protocol versions aligned
When it happens
Trigger: Calling autoDetectAndParseResponse -> parseStreamingResponse against an A2A endpoint whose message/stream response yields no chunk matching the expected shapes (status-update, artifact-update, JSON-RPC result), or the stream closes immediately.
Common situations: Remote A2A server returns an error event or empty stream; server version speaks a different A2A protocol shape than the parser expects; network proxy truncates the SSE stream before any data event; wrong endpoint URL returning HTML error page.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Failed to build JSON-RPC streaming payload
- AppTypeNotSupport
- Invalid memory parameter
- Invalid iterations parameter
- Invalid parallel parameter
AI-assisted analysis of alibaba/spring-ai-alibaba@f82da0b50f (2026-09-09).
Data as JSON: /api/errors/ea528e687f9a0871.
Report an issue: GitHub.