mastra-ai/mastra · warning
Invalid Subconscious record time: ${value}
Error message
Invalid Subconscious record time: ${value} What it means
parseWhen converts a model-provided 'when' string into a Date for Subconscious record timestamps. If the value is non-empty but unparseable (NaN time), it throws rather than silently storing an invalid date.
Source
Thrown at packages/memory/src/processors/observational-memory/subconscious/capture.ts:106
}
return [`org:${organizationId}`, `resource:${resourceId}`, `thread:${context.threadId}`];
}
async function getKnowledgeStore(context: ExtractorRuntimeContext): Promise<KnowledgeStorage> {
if (!context.memory) throw new Error('Subconscious capture requires an active Memory instance.');
const store = await context.memory.storage.getStore('knowledge');
if (!store) {
throw new Error(
'Subconscious requires a knowledge storage domain. Configure a storage adapter that provides stores.knowledge.',
);
}
return store;
}
function parseWhen(value: string | undefined): Date | undefined {
if (!value) return undefined;
const when = new Date(value);
if (Number.isNaN(when.getTime())) throw new Error(`Invalid Subconscious record time: ${value}`);
return when;
}
export interface CaptureExtractorOptions {
config?: SubconsciousCaptureConfig;
defaultScope: KnowledgeScopeLevel;
maxScope?: KnowledgeScopeLevel;
learnedGuidance: boolean;
activityRecentUpdates?: number;
/** Resolved pins config; capture-time pinning activates only when `capturePinning` is true. */
pins?: false | { maxPins: number; maxCharacters: number; capturePinning: boolean };
}
export class SubconsciousCaptureExtractor extends Extractor<SubconsciousCaptureOutput> {
constructor(options: CaptureExtractorOptions) {
const capturePinning = options.pins !== false && options.pins !== undefined && options.pins.capturePinning;
// Dropped-pin notes per extraction call, surfaced through the activity publish.
// Keyed on the extraction OUTPUT (context.current): a custom onExtracted hookView on GitHub (pinned to 75dd419e61)
Solutions
- Tighten the Subconscious capture prompt/schema to require ISO-8601 (e.g. '2026-08-29T12:00:00Z')
- Pre-sanitize model output: normalize or drop invalid `when` values before capture
- Use a stronger model for extraction if malformed dates persist
Example fix
// before
// LLM output: when: "last Tuesday"
// after — enforce ISO in prompt/schema
schema: z.object({ when: z.string().datetime().optional() }) Defensive patterns
Strategy: validation
Validate before calling
const d = new Date(value); if (value && Number.isNaN(d.getTime())) return undefined; // or normalize
Type guard
const isParseableDate = (v?: string): v is string => !!v && !Number.isNaN(new Date(v).getTime());
Try / catch
try { rec = await capture(params) } catch (e) { if (String(e).includes('Invalid Subconscious record time')) { sanitizeDatesAndRetry(); } else throw e; } Prevention
- Constrain extractor schemas to ISO-8601 datetime strings
- Validate/normalize LLM date output before persistence
- Prefer models with strong structured-output support
When it happens
Trigger: The extractor/LLM emitted a malformed timestamp for a knowledge record's `when` field — e.g. 'yesterday', '2024-13-45', or partial dates — which new Date() fails to parse.
Common situations: Weak models producing natural-language dates; prompt templates not enforcing ISO-8601; locale-formatted dates in LLM output.
Related errors
- Invalid notification dispatch time: ${input}
- Subconscious semantic knowledge requires a vector store. Pas
- Subconscious semantic knowledge requires an embedder. Pass a
- Subconscious ${phase} agent name is required.
- Duplicate Subconscious ${phase} agent: ${name}
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/934527fe074a8604.
Report an issue: GitHub.