mastra-ai/mastra · error · MastraClientErrorClass
A2A ${method} stream response did not include a body (status
Error message
A2A ${method} stream response did not include a body (status: ${response.status} ${response.statusText}) What it means
requireResponseBody guards A2A streaming calls (sendMessageStream, resubscribeTask): a streaming response must expose a ReadableStream body. When body is null, it throws a MastraClientError including status, statusText, sanitized headers, and (when available) response text to aid debugging.
Source
Thrown at client-sdks/client-js/src/resources/a2a.ts:116
.join(', ');
let responseText = '';
try {
responseText = await response.text();
} catch {
// Ignore body read failures and surface the rest of the response context.
}
const details = [
`A2A ${method} stream response did not include a body`,
`(status: ${response.status} ${response.statusText})`,
headerSummary ? `headers: ${headerSummary}` : '',
responseText ? `body: ${responseText}` : '',
]
.filter(Boolean)
.join(' ');
throw new MastraClientErrorClass(response.status, response.statusText, details);
}
/**
* Class for interacting with an agent via the A2A protocol
*/
export class A2A extends BaseResource {
constructor(
options: ClientOptions,
private agentId: string,
) {
super(options);
}
/**
* Get the agent card with metadata about the agent.
* @param options - Optional Agent Card verification settings
* @returns Promise containing the agent card information
*/View on GitHub (pinned to 75dd419e61)
Solutions
- Read the status/details embedded in the thrown MastraClientError (headers, body text) to identify the server-side cause.
- Confirm the A2A server supports streaming responses for the invoked method.
- Use a runtime with native streaming fetch (Node 18+, modern browsers).
- For persistent failures, fall back to the non-streaming sendMessage and poll for task updates.
Defensive patterns
Strategy: try-catch
Type guard
function hasBody(res: Response): res is Response & { body: ReadableStream<Uint8Array> } {
return res.body !== null;
} Try / catch
try {
const events = await a2a.sendMessageStream(msg);
} catch (e) {
if (e instanceof MastraClientError && e.message.includes('did not include a body')) {
// fall back to non-streaming sendMessage + task polling
}
throw e;
} Prevention
- Confirm the A2A server supports streaming for the method invoked.
- Use native streaming fetch runtimes.
- Implement a non-streaming fallback path for constrained environments.
When it happens
Trigger: Calling a2a.sendMessageStream(...) or resubscribeTask(...) where the HTTP response has no body: 204/304-style empty responses, server not supporting streaming, or a runtime/polyfill producing bodyless Response objects.
Common situations: A2A server returning a non-streaming error response with empty body; fetch polyfill in a constrained runtime; middleware consuming the stream before the client sees it.
Related errors
- Failed to stream background tasks: ${response.statusText}
- Response body is null
- Failed to stream agent builder action: ${response.statusText
- Response body is null
- Failed to observe agent builder action stream: ${response.st
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/a89007714c9836ad.
Report an issue: GitHub.