{"record":{"id":"446d55f8aa77bf08","repo":"mastra-ai/mastra","slug":"subconscious-curationcadence-must-be-a-positive-in","errorCode":null,"errorMessage":"Subconscious curationCadence must be a positive integer.","messagePattern":"Subconscious curationCadence must be a positive integer\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/memory/src/processors/observational-memory/subconscious/index.ts","lineNumber":136,"sourceCode":"      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 ||\n        pins.maxCharacters > MAX_PINNED_MAX_CHARACTERS\n      ) {\n        throw new Error(\n          `Subconscious pins.maxCharacters must be an integer between 1 and ${MAX_PINNED_MAX_CHARACTERS}.`,\n        );\n      }\n    }\n\n    if (\n      config.curationCadence !== undefined &&\n      (!Number.isInteger(config.curationCadence) || config.curationCadence < 1)\n    ) {\n      throw new Error('Subconscious curationCadence must be a positive integer.');\n    }\n\n    this.config = Object.freeze({ ...config, observation: [...observation], reflection: [...reflection] });\n    this.resolved = Object.freeze({\n      observation: observation.map(entry =>\n        entryName(entry) === 'remind'\n          ? resolveAgent(entry, BUILT_IN_OBSERVATION, config.model, maxSteps)\n          : resolveExtractor(entry),\n      ),\n      reflection: reflection.map(entry => resolveAgent(entry, BUILT_IN_REFLECTION, config.model, maxSteps)),\n      defaultScope: config.defaultScope ?? 'resource',\n      maxScope: config.maxScope,\n      learnedGuidance: config.learnedGuidance !== false,\n      tools: config.tools !== false,\n      activity: recentUpdates === false ? false : { recentUpdates },\n      pins,\n      curationCadence: config.curationCadence,\n    });","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/memory/src/processors/observational-memory/subconscious/index.ts#L118-L154","documentation":"config.curationCadence controls how often (in observed turns) the curation phase runs; when provided it must be a positive integer. Zero, negatives, floats, or non-numbers throw at construction. Omitting it keeps the built-in default cadence.","triggerScenarios":"Configuring curationCadence: 0 (e.g. intending 'every turn'), a negative value, a float, or a string like \"5\" from parsed env/JSON config.","commonSituations":"Setting 0 expecting curation on every observation instead of using 1; unparsed env values; arithmetic producing NaN (NaN fails Number.isInteger).","solutions":["Set curationCadence to a positive integer; use 1 for every-turn curation.","Omit curationCadence to use the default cadence.","Coerce env/JSON values with Number() and validate Number.isInteger(n) && n >= 1 before constructing."],"exampleFix":"// before\nnew Subconscious({ curationCadence: 0 })\n// after\nnew Subconscious({ curationCadence: 1 })","handlingStrategy":"validation","validationCode":"if (config.curationCadence !== undefined && (!Number.isInteger(config.curationCadence) || config.curationCadence < 1)) {\n  throw new Error('curationCadence must be a positive integer');\n}","typeGuard":"function isValidCadence(v: unknown): v is number {\n  return Number.isInteger(v) && (v as number) >= 1;\n}","tryCatchPattern":"try {\n  const sub = new Subconscious(config);\n} catch (err) {\n  if (err.message.includes('curationCadence')) {\n    throw new ConfigError('Set curationCadence to a positive integer (1 = every turn), or omit for default');\n  } else throw err;\n}","preventionTips":["Use 1 (not 0) for curation on every observed turn.","Parse env/JSON values with Number() and check Number.isInteger.","Cover cadence parsing in a unit test when loading config from external sources."],"tags":["configuration","validation","subconscious"],"backgroundTag":"range-validation-failed","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}