{"record":{"id":"8551dd1ac31c06fb","repo":"mastra-ai/mastra","slug":"subconscious-activity-recentupdates-must-be-an-int","errorCode":null,"errorMessage":"Subconscious activity.recentUpdates must be an integer between 1 and ${MAX_RECENT_UPDATES}.","messagePattern":"Subconscious activity\\.recentUpdates must be an integer between 1 and (.+?)\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/memory/src/processors/observational-memory/subconscious/index.ts","lineNumber":105,"sourceCode":"  readonly resolved: Readonly<ResolvedSubconsciousConfig>;\n\n  constructor(config: SubconsciousConfig = {}) {\n    const observation = config.observation ?? ['capture', 'remind'];\n    const reflection = config.reflection ?? ['curate', 'learn'];\n    assertUniqueNames(observation, 'observation');\n    assertUniqueNames(reflection, 'reflection');\n\n    const maxSteps = config.maxSteps === undefined ? undefined : boundedSteps(config, DEFAULT_MAX_STEPS);\n    for (const entry of observation) this.#validateObservationEntry(entry);\n    for (const entry of reflection) this.#validateReflectionEntry(entry);\n\n    const recentUpdates =\n      config.activity === false ? false : (config.activity?.recentUpdates ?? DEFAULT_RECENT_UPDATES);\n    if (\n      recentUpdates !== false &&\n      (!Number.isInteger(recentUpdates) || recentUpdates < 1 || recentUpdates > MAX_RECENT_UPDATES)\n    ) {\n      throw new Error(`Subconscious activity.recentUpdates must be an integer between 1 and ${MAX_RECENT_UPDATES}.`);\n    }\n\n    const pins =\n      config.pins === undefined || config.pins === false\n        ? false\n        : {\n            maxPins: (config.pins === true ? undefined : config.pins.maxPins) ?? DEFAULT_MAX_PINS,\n            maxCharacters:\n              (config.pins === true ? undefined : config.pins.maxCharacters) ?? DEFAULT_PINNED_MAX_CHARACTERS,\n            capturePinning: (config.pins === true ? undefined : config.pins.capturePinning) ?? false,\n          };\n    if (pins !== false) {\n      if (!Number.isInteger(pins.maxPins) || pins.maxPins < 1) {\n        throw new Error('Subconscious pins.maxPins must be a positive integer.');\n      }\n      if (\n        !Number.isInteger(pins.maxCharacters) ||\n        pins.maxCharacters < 1 ||","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/memory/src/processors/observational-memory/subconscious/index.ts#L87-L123","documentation":"The Subconscious constructor validates config.activity.recentUpdates: when activity is enabled (not false), recentUpdates must be a positive integer no greater than MAX_RECENT_UPDATES, or exactly false to disable. Any other value (non-integer, 0, too large) throws. This bounds how many recent memory updates are injected into prompts.","triggerScenarios":"Configuring activity: { recentUpdates: 0 }, a float, a non-integer, or a value above MAX_RECENT_UPDATES; passing a string from parsed JSON/env config.","commonSituations":"JSON config parsed from a file yielding a string like \"10\"; tuning the value upward past the cap; confusing 'false' (string) with false (boolean) from env vars.","solutions":["Set activity.recentUpdates to a positive integer within [1, MAX_RECENT_UPDATES], or false to disable.","Parse and coerce config values (Number(), strict boolean handling) before constructing Subconscious.","Omit recentUpdates to use DEFAULT_RECENT_UPDATES."],"exampleFix":"// before\nnew Subconscious({ activity: { recentUpdates: 0 } })\n// after\nnew Subconscious({ activity: { recentUpdates: 5 } })","handlingStrategy":"validation","validationCode":"const ru = config.activity === false ? false : config.activity?.recentUpdates;\nif (ru !== false && ru !== undefined && (!Number.isInteger(ru) || ru < 1 || ru > MAX_RECENT_UPDATES)) {\n  throw new Error(`recentUpdates must be an integer between 1 and ${MAX_RECENT_UPDATES}, or false`);\n}","typeGuard":"function isValidRecentUpdates(v: unknown): v is number | false {\n  return v === false || (Number.isInteger(v) && (v as number) >= 1 && (v as number) <= MAX_RECENT_UPDATES);\n}","tryCatchPattern":"try {\n  const sub = new Subconscious(config);\n} catch (err) {\n  if (err.message.includes('recentUpdates')) {\n    throw new ConfigError('Invalid activity.recentUpdates in Subconscious config');\n  } else throw err;\n}","preventionTips":["Beware string booleans from env: map \"false\" -> false explicitly.","Clamp parsed numbers to [1, MAX_RECENT_UPDATES] at config load.","Validate with a schema (zod) before constructing Subconscious."],"tags":["configuration","validation","subconscious"],"backgroundTag":"range-validation-failed","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}