mastra-ai/mastra · error · MastraError

DURABLE_AGENT_LIST_ACTIVE_RUNS_NO_STORAGE

DURABLE_AGENT_LIST_ACTIVE_RUNS_NO_STORAGE

Error message

DurableAgent "${this.name}" listActiveRuns() requires storage to discover running runs. Register the agent on a Mastra instance with persistent storage (e.g. PostgreSQL, LibSQL). See https://mastra.ai/docs/storage

What it means

listActiveRuns() discovers running runs by querying the workflows storage store via this.#mastra?.getStorage()?.getStore('workflows'). If the agent has no Mastra instance or the instance has no persistent storage configured, the store is undefined and the agent cannot enumerate active runs, so it throws instead of silently returning an empty list.

Source

Thrown at packages/core/src/agent/durable/durable-agent.ts:2924

        category: ErrorCategory.USER,
        text: `DurableAgent "${this.name}" listActiveRuns() requires perPage to be a positive integer.`,
        details: { agentName: this.name, perPage },
      });
    }
    if (page !== undefined && (!Number.isInteger(page) || page < 0)) {
      throw new MastraError({
        id: 'DURABLE_AGENT_LIST_ACTIVE_RUNS_INVALID_PAGE',
        domain: ErrorDomain.AGENT,
        category: ErrorCategory.USER,
        text: `DurableAgent "${this.name}" listActiveRuns() requires page to be a non-negative integer.`,
        details: { agentName: this.name, page },
      });
    }

    const workflowsStore = await this.#mastra?.getStorage()?.getStore('workflows');

    if (!workflowsStore) {
      throw new MastraError({
        id: 'DURABLE_AGENT_LIST_ACTIVE_RUNS_NO_STORAGE',
        domain: ErrorDomain.AGENT,
        category: ErrorCategory.USER,
        text:
          `DurableAgent "${this.name}" listActiveRuns() requires storage to discover running runs. ` +
          `Register the agent on a Mastra instance with persistent storage (e.g. PostgreSQL, LibSQL). See https://mastra.ai/docs/storage`,
        details: { agentName: this.name },
      });
    }

    // resourceId is a storage column, so it is pushed down to narrow the query
    // (the in-process check below remains as backstop for adapters that skip
    // the filter and for rows persisted before the column was populated).
    // Filtering by agentId/threadId happens in application code because those
    // fields only exist inside each row's `snapshot` JSON — storage adapters
    // have no predicate for them. Fetch candidates in bounded batches so peak
    // memory is O(batch size) hydrated snapshots instead of every `running`
    // row's full snapshot at once (#21501). Only the small per-run summary is

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Register the agent on a Mastra instance with persistent storage: new Mastra({ agents: { myAgent }, storage: new PostgresStore(...) }).
  2. Verify the configured storage adapter exposes a workflows store (PostgreSQL, LibSQL, etc.).
  3. In tests, either provide an in-memory/file-backed storage adapter or skip listActiveRuns coverage.

Example fix

// before
export const mastra = new Mastra({ agents: { myAgent } });
// after
export const mastra = new Mastra({
  agents: { myAgent },
  storage: new PostgresStore({ connectionString: process.env.DATABASE_URL }),
});
Defensive patterns

Strategy: try-catch

Validate before calling

const hasStorage = !!mastra?.getStorage?.()?.getStore('workflows');
if (!hasStorage) {
  throw new Error('listActiveRuns requires persistent storage on the Mastra instance');
}
await agent.listActiveRuns({ page: 0 });

Try / catch

import { MastraError } from '@mastra/core/mastra/error';
try {
  const runs = await agent.listActiveRuns({ page: 0 });
} catch (e) {
  if (e instanceof MastraError && e.id === 'DURABLE_AGENT_LIST_ACTIVE_RUNS_NO_STORAGE') {
    logger.warn('No storage configured; active-run listing unavailable');
    return [];
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling listActiveRuns() on a DurableAgent that was constructed without a Mastra instance, or whose Mastra instance was created without a storage option (e.g. new Mastra({}) with no storage).

Common situations: Standalone/in-memory test agents without storage, dev setups that skipped configuring PostgreSQL/LibSQL, or agents instantiated directly rather than registered on a configured Mastra instance.

Related errors


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