{"record":{"id":"9ec0498d75d3535c","repo":"mastra-ai/mastra","slug":"agent-durable-method-not-available","errorCode":"AGENT_DURABLE_METHOD_NOT_AVAILABLE","errorMessage":"Agent.${method}() is only available on agents constructed with `durable: true`. Configure `new Agent({ durable: true })` or retrieve the durable agent from a registered Mastra instance.","messagePattern":"Agent\\.(.+?)\\(\\) is only available on agents constructed with `durable: true`\\. Configure `new Agent\\((.+?)\\)` or retrieve the durable agent from a registered Mastra instance\\.","errorType":"error_code","errorClass":"MastraError","httpStatus":null,"severity":"error","filePath":"packages/core/src/agent/agent.ts","lineNumber":9839,"sourceCode":"  // execution. Each delegator resolves the lazily-built standalone\n  // `DurableAgent` wrapper via `#getStandaloneDurable()` and forwards the call.\n  //\n  // On a non-durable agent they throw `AGENT_DURABLE_METHOD_NOT_AVAILABLE` so\n  // callers get a clear error instead of a confusing \"not a function\" from a\n  // typo-safe method that silently does nothing.\n  //\n  // When the agent is attached to a `Mastra`, Mastra auto-wraps at\n  // registration and the caller already holds a `DurableAgent`, so the base\n  // methods below are unreachable via the wrapper — `#getStandaloneDurable()`\n  // returns `undefined` and the throw path fires. To avoid that misleading\n  // error, callers should either use the wrapper Mastra hands back or omit the\n  // `Mastra` registration and rely on the standalone wrapper.\n  // ---------------------------------------------------------------------------\n\n  async #requireStandaloneDurable(method: string): Promise<StandaloneDurableWrapper> {\n    const durable = await this.#getStandaloneDurable();\n    if (!durable) {\n      throw new MastraError({\n        id: 'AGENT_DURABLE_METHOD_NOT_AVAILABLE',\n        domain: ErrorDomain.AGENT,\n        category: ErrorCategory.USER,\n        text: `Agent.${method}() is only available on agents constructed with \\`durable: true\\`. Configure \\`new Agent({ durable: true })\\` or retrieve the durable agent from a registered Mastra instance.`,\n        details: { agentId: this.id, method },\n      });\n    }\n    return durable;\n  }\n\n  /** Resume a suspended durable run. Only valid when `durable: true`. */\n  async resume(\n    runId: string,\n    resumeData: unknown,\n    options?: DurableAgentStreamOptions<TOutput>,\n  ): Promise<DurableAgentStreamResult<TOutput>> {\n    const durable = await this.#requireStandaloneDurable('resume');\n    return durable.resume(runId, resumeData, options) as Promise<DurableAgentStreamResult<TOutput>>;","sourceCodeStart":9821,"sourceCodeEnd":9857,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/agent/agent.ts#L9821-L9857","documentation":"#requireStandaloneDurable(method) resolves the agent's standalone durable wrapper (created when the Agent is constructed with durable: true). If the agent is not durable, calling durable-only methods such as recover()/workflowInput() throws this USER error. It is a configuration problem, not a runtime failure.","triggerScenarios":"Calling any durable-only method (e.g. agent.recover(runId), agent.workflowInput(...)) on an agent constructed without `durable: true` in new Agent({...}), or on an agent not retrieved from a registered Mastra instance that provides durability.","commonSituations":"Copy-pasting durable-agent sample code onto an existing plain Agent; forgetting the durable flag during migration to durable agents; calling recover() on an agent instantiated standalone rather than via mastra.getAgent(); version upgrade where durable APIs were adopted but constructor options were not updated.","solutions":["Construct the agent with durable: true: new Agent({ ..., durable: true }).","Alternatively, register the agent in a Mastra instance and retrieve it via mastra.getAgent('id') so the durable wrapper is available.","If durability is not intended, replace the durable-only call with the non-durable equivalent (e.g. resume via sendStreamResume)."],"exampleFix":"// before\nconst agent = new Agent({ name: 'helper', instructions, model });\nawait agent.recover(runId); // throws\n// after\nconst agent = new Agent({ name: 'helper', instructions, model, durable: true });\nawait agent.recover(runId);","handlingStrategy":"validation","validationCode":"if (!agentIsDurable(agent)) { // e.g. constructed without durable: true\n  throw new Error('recover() requires new Agent({ durable: true }) or a Mastra-registered durable agent.');\n}","typeGuard":"function isDurableAgent(a: unknown): a is { recover: (runId: string) => Promise<unknown> } {\n  return typeof a === 'object' && a !== null && 'recover' in a && typeof (a as any).recover === 'function';\n}","tryCatchPattern":null,"preventionTips":["Set durable: true in the Agent constructor for any code path that uses recover()/durable methods.","Retrieve agents via mastra.getAgent() so durability wiring from the instance is applied.","Feature-flag durable-only call sites so non-durable agents never reach them."],"tags":["agent","durable","configuration","api-misuse","user-input"],"backgroundTag":"durable-mode-not-enabled","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}