mastra-ai/mastra · error

Subconscious remind requires a resourceId.

Error message

Subconscious remind requires a resourceId.

What it means

`resolveScope` in packages/memory/src/processors/observational-memory/subconscious/remind.ts:35 derives the resource portion of the knowledge scope via `resolveKnowledgeResourceId(requestContext, context.resourceId)`. When neither the explicit `resourceId` nor any requestContext fallback yields a value, remind cannot build a scope and throws.

Source

Thrown at packages/memory/src/processors/observational-memory/subconscious/remind.ts:35

Never remind about knowledge that is already visible in the current observations or recent messages — a reminder is only valuable for knowledge the agent can no longer see. Echoing back what was just said or just captured is noise.
If nothing is relevant, respond with exactly ${NO_REMINDER} and nothing else.
If knowledge is relevant, return one concise reminder that explains why it matters and includes source node or record IDs. Do not invent knowledge and do not expose knowledge outside the tools' scoped results.`;

/** Own-thread records younger than this are treated as still-in-context and excluded from reminder candidates. */
const FRESH_OWN_RECORD_WINDOW_MS = 30 * 60 * 1000;

function resolveScope(context: {
  requestContext?: { get(key: string): unknown };
  resourceId?: string;
  threadId: string;
}) {
  const organizationId = context.requestContext?.get('organizationId');
  if (typeof organizationId !== 'string' || !organizationId.trim()) {
    throw new Error('Subconscious remind requires organizationId in the request context.');
  }
  const resourceId = resolveKnowledgeResourceId(context.requestContext, context.resourceId);
  if (!resourceId) {
    throw new Error('Subconscious remind requires a resourceId.');
  }

  return canonicalizeKnowledgeScope([`org:${organizationId}`, `resource:${resourceId}`, `thread:${context.threadId}`]);
}

const REMINDER_QUERY_STOP_WORDS = new Set([
  'about',
  'after',
  'before',
  'current',
  'from',
  'have',
  'observations',
  'that',
  'their',
  'there',
  'they',
  'this',

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Pass an explicit `resourceId` in the context/options for the memory operation.
  2. Or store a resource identifier in requestContext so `resolveKnowledgeResourceId` can pick it up.
  3. Confirm whether your version still propagates resourceId automatically; otherwise update all call sites.

Example fix

// before
await memory.remember({ threadId: 't1', requestContext });
// after
await memory.remember({ threadId: 't1', resourceId: 'user_42', requestContext });
Defensive patterns

Strategy: validation

Validate before calling

const resourceId = context.resourceId ?? requestContext?.get('resourceId');
if (!resourceId || (typeof resourceId === 'string' && !resourceId.trim())) {
  throw new Error('resourceId is required for subconscious remind');
}

Type guard

function hasResourceId(ctx) {
  const v = ctx?.resourceId ?? ctx?.requestContext?.get('resourceId');
  return typeof v === 'string' && v.trim().length > 0;
}

Try / catch

try {
  await memory.remember({ threadId, requestContext });
} catch (e) {
  if (e.message.includes('requires a resourceId')) {
    return memory.remember({ threadId, resourceId: derivedResourceId, requestContext });
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling remind with `context.resourceId` undefined/empty AND no resource identifier resolvable from requestContext (the requestContext lacks the key `resolveKnowledgeResourceId` checks).

Common situations: Omitting resourceId on generate/stream/memory calls in versions where it is no longer auto-inferred; constructing the remind context manually without resourceId; tests that stub threadId but forget resourceId.

Related errors


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