{"record":{"id":"9dce65f853441275","repo":"mastra-ai/mastra","slug":"agent-thread-aborts-are-not-supported-by-this-mast","errorCode":null,"errorMessage":"agent thread aborts are not supported by this Mastra core version","messagePattern":"agent thread aborts are not supported by this Mastra core version","errorType":"http","errorClass":"HTTPException","httpStatus":501,"severity":"error","filePath":"packages/server/src/server/handlers/agents.ts","lineNumber":2158,"sourceCode":"});\n\nexport const ABORT_AGENT_THREAD_ROUTE = createRoute({\n  method: 'POST',\n  path: '/agents/:agentId/threads/abort',\n  responseType: 'json' as const,\n  pathParamSchema: agentIdPathParams,\n  bodySchema: abortAgentThreadBodySchema,\n  responseSchema: abortAgentThreadResponseSchema,\n  summary: 'Abort active agent thread run',\n  description: 'Aborts the currently active stream run for a memory thread without changing thread subscriptions',\n  tags: ['Agents', 'Streaming'],\n  requiresAuth: true,\n  requiresPermission: 'agents:execute',\n  handler: async ({ mastra, agentId, resourceId, threadId, requestContext: serverRequestContext }) => {\n    try {\n      const agent = await getAgentFromSystem({ mastra, agentId, requestContext: serverRequestContext });\n      if (typeof (agent as { abortThreadStream?: unknown }).abortThreadStream !== 'function') {\n        throw new HTTPException(501, {\n          message: 'agent thread aborts are not supported by this Mastra core version',\n        });\n      }\n\n      const effectiveResourceId = getEffectiveResourceId(serverRequestContext, resourceId);\n      const effectiveThreadId = getEffectiveThreadId(serverRequestContext, threadId);\n\n      if (!effectiveThreadId) {\n        throw new HTTPException(400, { message: 'threadId is required' });\n      }\n\n      if (effectiveResourceId) {\n        const memory = await agent.getMemory({ requestContext: serverRequestContext });\n        if (memory) {\n          const thread = await memory.getThreadById({ threadId: effectiveThreadId });\n          await validateThreadOwnership(thread, effectiveResourceId);\n        }\n      }","sourceCodeStart":2140,"sourceCodeEnd":2176,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/server/src/server/handlers/agents.ts#L2140-L2176","documentation":"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.","triggerScenarios":"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.","commonSituations":"Upgraded server/playground but not core; running against an old mastra deploy; custom agent implementations missing the method.","solutions":["Upgrade @mastra/core to a version with abortThreadStream support","Rebuild/redeploy the server so it binds the updated core","Check all @mastra/* versions are aligned after the upgrade (pnpm why @mastra-core / pnpm ls)"],"exampleFix":"// before\npnpm add @mastra/core@0.10.0\n// after\npnpm add @mastra/core@latest && pnpm build && redeploy","handlingStrategy":"type-guard","validationCode":"function agentSupportsAbort(agent: unknown): boolean {\n  return typeof (agent as { abortThreadStream?: unknown })?.abortThreadStream === 'function';\n}","typeGuard":"function supportsAbort(a: unknown): a is { abortThreadStream: Function } {\n  return !!a && typeof (a as { abortThreadStream?: unknown }).abortThreadStream === 'function';\n}","tryCatchPattern":"try {\n  await abortThread(agentId, { resourceId, threadId });\n} catch (e) {\n  if (e?.status === 501) console.warn('Thread aborts unsupported on this core version; upgrade @mastra/core');\n  else throw e;\n}","preventionTips":["Gate abort UI behind a capability check on the agent object","Upgrade core before exposing abort endpoints in production","Restart/redeploy after core upgrades so the running server picks up new agent methods"],"tags":["http-501","version-compatibility","abort","server"],"backgroundTag":"feature-not-supported-version","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}