mastra-ai/mastra · error · HTTPException

agent thread aborts are not supported by this Mastra core…

Error message

agent thread aborts are not supported by this Mastra core version

What it means

The abort-thread handler checks that the agent instance implements abortThreadStream. Older core versions lack thread-level abort, so the server returns HTTP 501 Not Implemented rather than throwing an opaque TypeError. It signals the deployment's core is too old for this endpoint.

Solutions

  1. Upgrade @mastra/core to a version with abortThreadStream support
  2. Rebuild/redeploy the server so it binds the updated core
  3. Check all @mastra/* versions are aligned after the upgrade (pnpm why @mastra-core / pnpm ls)

Example fix

// before
pnpm add @mastra/core@0.10.0
// after
pnpm add @mastra/core@latest && pnpm build && redeploy
Defensive patterns

Strategy: type-guard

Validate before calling

function agentSupportsAbort(agent: unknown): boolean {
  return typeof (agent as { abortThreadStream?: unknown })?.abortThreadStream === 'function';
}

Type guard

function supportsAbort(a: unknown): a is { abortThreadStream: Function } {
  return !!a && typeof (a as { abortThreadStream?: unknown }).abortThreadStream === 'function';
}

Try / catch

try {
  await abortThread(agentId, { resourceId, threadId });
} catch (e) {
  if (e?.status === 501) console.warn('Thread aborts unsupported on this core version; upgrade @mastra/core');
  else throw e;
}

Prevention

When it happens

Trigger: Calling the agent thread abort endpoint (DELETE/POST on the thread abort route) against an agent without an abortThreadStream function — i.e. pre-abort-support @mastra/core.

Common situations: Upgraded server/playground but not core; running against an old mastra deploy; custom agent implementations missing the method.

Related errors


AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30). Data as JSON: /api/errors/9dce65f853441275. Report an issue: GitHub.

Appendix: source

Thrown at packages/server/src/server/handlers/agents.ts:2158

});

export const ABORT_AGENT_THREAD_ROUTE = createRoute({
  method: 'POST',
  path: '/agents/:agentId/threads/abort',
  responseType: 'json' as const,
  pathParamSchema: agentIdPathParams,
  bodySchema: abortAgentThreadBodySchema,
  responseSchema: abortAgentThreadResponseSchema,
  summary: 'Abort active agent thread run',
  description: 'Aborts the currently active stream run for a memory thread without changing thread subscriptions',
  tags: ['Agents', 'Streaming'],
  requiresAuth: true,
  requiresPermission: 'agents:execute',
  handler: async ({ mastra, agentId, resourceId, threadId, requestContext: serverRequestContext }) => {
    try {
      const agent = await getAgentFromSystem({ mastra, agentId, requestContext: serverRequestContext });
      if (typeof (agent as { abortThreadStream?: unknown }).abortThreadStream !== 'function') {
        throw new HTTPException(501, {
          message: 'agent thread aborts are not supported by this Mastra core version',
        });
      }

      const effectiveResourceId = getEffectiveResourceId(serverRequestContext, resourceId);
      const effectiveThreadId = getEffectiveThreadId(serverRequestContext, threadId);

      if (!effectiveThreadId) {
        throw new HTTPException(400, { message: 'threadId is required' });
      }

      if (effectiveResourceId) {
        const memory = await agent.getMemory({ requestContext: serverRequestContext });
        if (memory) {
          const thread = await memory.getThreadById({ threadId: effectiveThreadId });
          await validateThreadOwnership(thread, effectiveResourceId);
        }
      }

View on GitHub (pinned to 75dd419e61)