rohitg00/agentmemory · error
validation_failed
validation_failed
Error message
validation_failed
What it means
After the provider returns a summary, mem::summarize validates the parsed summary XML against schema/rules (validation.result). If validation reports errors, the function logs them and returns success:false with error 'validation_failed', refusing to persist an invalid summary to KV.summaries.
Source
Thrown at src/functions/summarize.ts:355
concepts: summary.concepts,
};
const validation = validateOutput(
SummaryOutputSchema,
summaryForValidation,
"mem::summarize",
);
if (!validation.valid) {
const latencyMs = Date.now() - startMs;
if (metricsStore) {
await metricsStore.record("mem::summarize", latencyMs, false);
}
logger.warn("Summary validation failed", {
sessionId,
errors: validation.result.errors,
});
return { success: false, error: "validation_failed" };
}
const qualityScore = scoreSummary(summaryForValidation);
await kv.set(KV.summaries, sessionId, summary);
await safeAudit(kv, "compress", "mem::summarize", [sessionId], {
title: summary.title,
observationCount: compressed.length,
});
const latencyMs = Date.now() - startMs;
if (metricsStore) {
await metricsStore.record(
"mem::summarize",
latencyMs,
true,
qualityScore,
);
}View on GitHub (pinned to e04ba88819)
Solutions
- Retry — nondeterministic LLM output may validate on a second attempt.
- Use a stronger model that reliably follows the summary XML schema.
- Update agentmemory (or the model prompt) so the expected schema matches the produced output.
- Check the logged validation.result.errors to see exactly which fields failed and adjust configuration accordingly.
Example fix
// before
await sdk.trigger({ function_id: "mem::summarize", payload: { sessionId } }); // ignored validation_failed
// after
const r = await sdk.trigger({ function_id: "mem::summarize", payload: { sessionId } });
if (r.error === "validation_failed") await sdk.trigger({ function_id: "mem::summarize", payload: { sessionId, model: "stronger-model" } }); Defensive patterns
Strategy: retry
Validate before calling
// confirm the model in config matches the one your schema was validated against
if (!/strong-model/.test(provider.model)) console.warn("model may not produce schema-valid summary XML"); Type guard
function isValidationFailed(res: unknown): res is { success: false; error: "validation_failed" } {
return typeof res === "object" && res !== null && (res as any).error === "validation_failed";
} Try / catch
const res = await sdk.trigger({ function_id: "mem::summarize", payload: { sessionId } });
if (isValidationFailed(res)) {
const retry = await sdk.trigger({ function_id: "mem::summarize", payload: { sessionId } });
if (isValidationFailed(retry)) escalateOrFallback(retry);
} Prevention
- Use models known to follow strict XML output instructions.
- Keep agentmemory and its expected summary schema in sync with your prompts.
- Retry automatically on validation_failed before surfacing to users.
- Read logged validation errors to target prompt fixes.
When it happens
Trigger: registerSummarizeFunction: the LLM output parses to a summary but validation.result.valid is false (missing required fields like title, malformed structure, constraint violations), so the handler returns error 'validation_failed'.
Common situations: Smaller/weaker model omitting required summary fields; prompt/model changes altering XML shape; schema updated in a new agentmemory version while responses follow the old format; truncation dropping required trailing elements.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- too_many_chunks_skipped: ${skipped}/${chunks.length} chunks
- too_many_chunks_skipped
- Invalid dateFrom: ${filter.dateFrom}
- Invalid dateTo: ${filter.dateTo}
- Refusing to read image outside managed store: ${data.raw.ima
AI-assisted analysis of rohitg00/agentmemory@e04ba88819 (2026-08-30).
Data as JSON: /api/errors/5076b5f688e53571.
Report an issue: GitHub.