Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 fix(memory): align extraction prompts with schemas (#17988)

Neko7345079329fc
diff --git a/packages/memory-user-memory/src/prompts/layers/activity.ts b/packages/memory-user-memory/src/prompts/layers/activity.ts
index a10ac80df61..1311beaa538 100644
--- a/packages/memory-user-memory/src/prompts/layers/activity.ts
+++ b/packages/memory-user-memory/src/prompts/layers/activity.ts
@@ -20,10 +20,12 @@ export const activityPrompt = [
'\n',
'Extract **ALL** activity layer information from the conversation. Activities are time-bound events',
'with people, places, status, and a factual narrative of what happened. Capture how it felt via',
- 'feedback. Temporal (startsAt, endsAt, timezone) and association fields are OPTIONAL—only include',
- 'them when explicitly provided. If missing, **omit the fields entirely** (do not set null/empty) instead of guessing.',
+ 'feedback. Temporal (startsAt, endsAt, timezone) and association values are OPTIONAL—only populate',
+ 'them when explicitly provided. Keep every schema key present: use null for an unknown optional scalar/object',
+ 'and [] for an unknown optional array instead of guessing.',
'\n',
- '**CRITICAL**: Return an **array** of activity memory items. Extract each distinct activity as a separate item.',
+ '**CRITICAL**: Return exactly one JSON object shaped as `{ "memories": [...] }`.',
+ 'Put each distinct activity in the `memories` array. Never return a bare array.',
'Before extracting, review the retrieved similar memories (top {{ topK }} items shown above). Extract items',
'that are NEW or MATERIALLY UPDATED compared to retrieved entries. Avoid duplicates or near-duplicates.',
'\n',
@@ -35,7 +37,7 @@ export const activityPrompt = [
'## Output Format',
'\n',
'Return structured JSON data according to the provided schema:',
- '- Basic fields: title, summary, details, memoryLayer, memoryType, memoryCategory, sourceIds, tags',
+ '- Basic fields: title, summary, details, memoryType, memoryCategory, sourceIds, tags',
'- If messages contain source metadata with stable message ids, set sourceIds to the exact ids that support this memory. Use [] when no source id is available.',
'- Activity-specific fields in withActivity: type (enum), status (planned/completed/cancelled/ongoing/on_hold/pending),',
' optional timezone, startsAt, endsAt (ISO 8601), associatedSubjects (self-aware entities: people, pets, groups, orgs), associatedObjects',
@@ -66,20 +68,20 @@ export const activityPrompt = [
'\n',
'## Layer-Specific Guidance',
'- Focus on discrete events (meetings, calls, trips, workouts, meals, appointments).',
- '- Always capture mentioned locations in associatedLocations. If none are stated, omit the field.',
+ '- Always capture mentioned locations in associatedLocations. If none are stated, use an empty array.',
'- If the activity is a trip, record transportation modes or specific rides/tickets in associatedObjects.',
'- Route any self-aware entity without a known identity ID (people, pets, groups, institutions/orgs) to associatedSubjects.',
'- type choices: meeting, appointment, exercise, meal, social, trip, task, workshop, conference, call, errand, celebration, class, project-session, other.',
- '- Status handling: use provided status markers (planned, completed, cancelled, ongoing, on_hold, pending). If no status is stated, omit.',
+ '- Status handling: use provided status markers (planned, completed, cancelled, ongoing, on_hold, pending). If no status is stated, use null.',
'- Do not add the user as an associatedSubject; only include other mentioned living entities.',
'- Feedback captures how the activity felt (effort, mood, satisfaction); narrative captures the factual sequence.',
- '- Location and temporal fields are optional—only include when stated.',
+ '- Location and temporal values are optional—use null or [] when they are not stated, but do not omit their keys.',
'- Temporal anchoring: when the conversation uses relative time phrases (yesterday, tomorrow, last week), anchor calculations to the specific message timestamp (created_at) if present; otherwise fall back to sessionDate. Keep the anchor timezone/time-of-day when converting relative references and do not invent new times if none are given.',
'\n',
'## Few-shot Hints',
'- Meeting with known person, time stated → include type=meeting, startsAt/endsAt/timezone, associatedSubjects for participants, location name if given.',
- '- Workout described without time/place → type=exercise, omit time/timezone/location, keep narrative/feedback.',
- '- Dinner with friends mentioned without exact time → type=meal or social, include attendees if named, omit time/place if absent.',
+ '- Workout described without time/place → type=exercise, use null for time/timezone and [] for locations, keep narrative/feedback.',
+ '- Dinner with friends mentioned without exact time → type=meal or social, include attendees if named, use null/[] for absent values.',
'\n',
'## Security Considerations',
'**NEVER extract or store sensitive information:** passwords, API keys, financial account numbers, or private encryption keys.',
@@ -88,5 +90,5 @@ export const activityPrompt = [
'Final instructions:',
'1. Extract each distinct activity memory as a separate item.',
'2. Ensure memories are self-contained and in {{ language }}.',
- '3. Return JSON matching the schema. Use [] when nothing should be extracted.',
+ '3. Return JSON matching the schema. Use `{ "memories": [] }` when nothing should be extracted.',
].join('\\n');
diff --git a/packages/memory-user-memory/src/prompts/layers/context.ts b/packages/memory-user-memory/src/prompts/layers/context.ts
index d7fc46eef6d..9b2c0ab9caf 100644
--- a/packages/memory-user-memory/src/prompts/layers/context.ts
+++ b/packages/memory-user-memory/src/prompts/layers/context.ts
@@ -23,8 +23,9 @@ export const contextPrompt = [
'Situational frameworks that span memories (projects,',
'relationships, goals, ongoing situations).',
'\n',
- '**CRITICAL**: Return an **array** of memory items. One conversation',
- 'can contain context memories. Extract each as a separate item.',
+ '**CRITICAL**: Return exactly one JSON object shaped as `{ "memories": [...] }`.',
+ 'One conversation can contain multiple context memories. Put each one in the',
+ '`memories` array and never return a bare array.',
'\n',
'Before extracting, review the retrieved similar memories first (top {{ topK }}',
'items shown below). Extract items that are NEW or MATERIALLY UPDATED',
@@ -44,11 +45,11 @@ export const contextPrompt = [
'Return structured JSON data according to the provided schema. A strict schema',
'validates the output and includes:',
'\n',
- '- Basic fields: title, summary, details, memoryLayer, memoryType, memoryCategory, sourceIds',
+ '- Every memory item must include: title, summary, details, memoryType, memoryCategory, sourceIds, tags, withContext.',
'- If messages contain source metadata with stable message ids, set sourceIds to the exact ids that support this memory. Use [] when no source id is available.',
- '- Context-specific fields in withContext: title, description, extractedLabels,',
+ '- Every withContext object must include: title, description, labels,',
' associatedSubjects (array of object), associatedObjects (array of object),',
- ' currentStatus, type, scoreImpact, scoreUrgency.',
+ ' currentStatus, type, scoreImpact, scoreUrgency. Use [] for association or label arrays when none exist.',
'- For associatedSubjects and associatedObjects, the following fields are possible',
' to have:',
' - name (string)',
@@ -102,9 +103,9 @@ export const contextPrompt = [
'Summarize enduring situations connecting related memories (projects, goals,',
'relationships). Name actors (associatedSubjects) and resources',
'(associatedObjects) explicitly for downstream reasoning. Track currentStatus to',
- 'signal lifecycle stage ("exploring", "active", "on-hold", "completed"). Update',
+ 'signal lifecycle stage (planned, ongoing, completed, aborted, on_hold, cancelled). Update',
'existing contexts incrementally rather than duplicating entries. Provide',
- 'extractedLabels for thematic tagging; downstream systems handle embeddings.',
+ 'labels for thematic tagging; downstream systems handle embeddings.',
'Assess impact and urgency scores for prioritization.',
'\n',
'Examples of context information:',
@@ -149,8 +150,8 @@ export const contextPrompt = [
'1. Analyze the conversation for context layer information',
'2. Extract each distinct context memory as a separate item',
'3. Ensure all memories are self-contained (no pronouns, complete context)',
- '4. Return a JSON array conforming to the schema above',
- '5. Return `[]` if no context memories found',
+ '4. Return a JSON object conforming to the schema above; never return a bare array',
+ '5. Return `{ "memories": [] }` if no context memories are found',
'6. No matter what the language of the retrieved language is, always use {{ language }} for output',
'\n',
'Respond with valid JSON and no commentary.',
diff --git a/packages/memory-user-memory/src/prompts/layers/experience.ts b/packages/memory-user-memory/src/prompts/layers/experience.ts
index 6a0640d4d66..605a9b05ff1 100644
--- a/packages/memory-user-memory/src/prompts/layers/experience.ts
+++ b/packages/memory-user-memory/src/prompts/layers/experience.ts
@@ -25,8 +25,9 @@ export const experiencePrompt = [
'problems that were solved, and practical wisdom that is enjoyable to revisit and',
'share.',
'\n',
- '**CRITICAL**: Return an **array** of memory items. One conversation can include',
- 'more than one experience memory. Extract each as a separate item.',
+ '**CRITICAL**: Return exactly one JSON object shaped as `{ "memories": [...] }`.',
+ 'One conversation can include more than one experience memory. Put each one in',
+ 'the `memories` array and never return a bare array.',
'\n',
'Deduplicate aggressively: review the retrieved similar memories first (top',
'{{ topK }} items shown below). Extract items that are NEW or MATERIALLY UPDATED',
@@ -46,12 +47,12 @@ export const experiencePrompt = [
'Return structured JSON data according to the provided schema. The output must',
'pass validation against a strict schema including:',
'\n',
- '- Basic fields: title, summary, details, memoryLayer, memoryType, memoryCategory,',
+ '- Every memory item must include: title, summary, details, memoryType, memoryCategory,',
' sourceIds, tags',
'- If messages contain source metadata with stable message ids, set sourceIds to the exact ids that support this memory. Use [] when no source id is available.',
- '- Experience-specific fields in withExperience: labels, situation, reasoning,',
+ '- Every withExperience object must include: labels, situation, reasoning,',
' possibleOutcome, action, keyLearning, scoreConfidence,',
- ' problemSolvingScore, knowledgeValueScore',
+ ' problemSolvingScore, knowledgeValueScore, and type. Use [] when there are no labels.',
'\n',
'## Memory Formatting Guidelines',
'\n',
@@ -156,8 +157,8 @@ export const experiencePrompt = [
'1. Analyze the conversation for experience layer information',
'2. Extract each distinct experience memory as a separate item',
'3. Ensure all memories are self-contained (no pronouns, complete context)',
- '4. Return a JSON array conforming to the schema above',
- '5. Return `[]` if you find no experience memories',
+ '4. Return a JSON object conforming to the schema above; never return a bare array',
+ '5. Return `{ "memories": [] }` if you find no experience memories',
'6. No matter what the language of the retrieved language is, always use {{ language }} for output',
'\n',
'Respond with valid JSON without commentary.',
diff --git a/packages/memory-user-memory/src/prompts/layers/identity.ts b/packages/memory-user-memory/src/prompts/layers/identity.ts
index 45543b3ebcc..0f3a294e1f0 100644
--- a/packages/memory-user-memory/src/prompts/layers/identity.ts
+++ b/packages/memory-user-memory/src/prompts/layers/identity.ts
@@ -61,15 +61,15 @@ export const identityPrompt = [
'produce `add`, `update`, and `remove` arrays (use empty arrays when there are no',
'actions of that type):',
'\n',
- '- Use `withIdentities.actions.add` for genuinely new identity aspects that are',
+ '- Use `add` for genuinely new identity aspects that are',
' absent from the existing list, especially meaningful highlights, achievements,',
' people who matter, and episodic milestones that shape self-view.',
- '- Use `withIdentities.actions.update` when an existing entry changes or gains',
+ '- Use `update` when an existing entry changes or gains',
' more precision. Prefer updates over new entries to prevent duplication. If',
' multiple statements describe the same role or biography (e.g., repeated',
' "developer/engineer/test maintainer" variants), consolidate them into a single',
' enriched entry rather than creating parallel items.',
- '- Use `withIdentities.actions.remove` to remove incorrect, obsolete, or',
+ '- Use `remove` to remove incorrect, obsolete, or',
' duplicated entries.',
'\n',
'Before extracting, review the existing identity entries and the retrieved',
@@ -220,7 +220,7 @@ export const identityPrompt = [
'1. Analyze the conversation for identity layer information',
'2. Extract each distinct identity memory as a separate item',
'3. Ensure all memories are self-contained (no pronouns, complete context)',
- '4. Return a JSON object conforming to the schema above with arrays (empty when none, e.g. `withIdentities: { "add": [], "update": [], "remove": [] }` if no any operations)',
+ '4. Return exactly `{ "add": [], "update": [], "remove": [] }`, filling the arrays with actions when needed',
'5. No matter what the language of the retrieved language is, always use {{ language }} for output',
'\n',
'Respond with valid JSON without commentary.',
diff --git a/packages/memory-user-memory/src/prompts/layers/outputContract.test.ts b/packages/memory-user-memory/src/prompts/layers/outputContract.test.ts
new file mode 100644
index 00000000000..4899fb01a6e
--- /dev/null
+++ b/packages/memory-user-memory/src/prompts/layers/outputContract.test.ts
@@ -0,0 +1,58 @@
+import { describe, expect, it } from 'vitest';
+
+import { activityPrompt } from './activity';
+import { contextPrompt } from './context';
+import { experiencePrompt } from './experience';
+import { identityPrompt } from './identity';
+import { preferencePrompt } from './preference';
+
+/**
+ * @example
+ * All memory-list prompts instruct the model to return `{ "memories": [...] }`.
+ */
+describe('memory layer prompt output contracts', () => {
+ /**
+ * @example
+ * An empty extraction is returned as `{ "memories": [] }`, never `[]`.
+ */
+ it.each([
+ ['activity', activityPrompt],
+ ['context', contextPrompt],
+ ['experience', experiencePrompt],
+ ['preference', preferencePrompt],
+ ])('%s prompt matches the memory-list schema', (_layer, prompt) => {
+ /**
+ * @example
+ * `{ "memories": [] }` is present while contradictory bare-array instructions are absent.
+ */
+ expect({
+ hasEmptyObjectExample: prompt.includes('{ "memories": [] }'),
+ hasMemoryLayerField: prompt.includes('memoryLayer'),
+ requestsBareArray: /Return (?:an|a JSON) \*{0,2}array/i.test(prompt),
+ }).toEqual({
+ hasEmptyObjectExample: true,
+ hasMemoryLayerField: false,
+ requestsBareArray: false,
+ });
+ });
+
+ /**
+ * @example
+ * Identity actions are direct root properties.
+ */
+ it('matches the identity actions schema', () => {
+ /**
+ * @example
+ * The prompt contains `{ "add": [], "update": [], "remove": [] }` without a wrapper.
+ */
+ expect({
+ hasActionsExample: identityPrompt.includes('{ "add": [], "update": [], "remove": [] }'),
+ hasLegacyWrapper: identityPrompt.includes('withIdentities'),
+ hasUnexpectedActionsWrapper: identityPrompt.includes('{ "actions":'),
+ }).toEqual({
+ hasActionsExample: true,
+ hasLegacyWrapper: false,
+ hasUnexpectedActionsWrapper: false,
+ });
+ });
+});
diff --git a/packages/memory-user-memory/src/prompts/layers/preference.ts b/packages/memory-user-memory/src/prompts/layers/preference.ts
index 869509c723b..96df665dc3a 100644
--- a/packages/memory-user-memory/src/prompts/layers/preference.ts
+++ b/packages/memory-user-memory/src/prompts/layers/preference.ts
@@ -21,8 +21,9 @@ export const preferencePrompt = [
'Extract **ALL** preference layer information from the conversation. Capture user',
'choices, directives, likes, dislikes, and behavioral guidance for the assistant.',
'\n',
- '**CRITICAL**: Return an **array** of memory items. One conversation can include',
- 'more than one preference memory. Extract each as a separate item.',
+ '**CRITICAL**: Return exactly one JSON object shaped as `{ "memories": [...] }`.',
+ 'One conversation can include more than one preference memory. Put each one in',
+ 'the `memories` array and never return a bare array.',
'\n',
'Before extracting, review the retrieved similar memories first (top {{ topK }}',
'items shown below). Extract items that are NEW or MATERIALLY UPDATED compared to',
@@ -52,13 +53,13 @@ export const preferencePrompt = [
'Return structured JSON data according to the provided schema. The output must',
'pass validation against a strict schema including:',
'\n',
- '- Basic fields: title, summary, details, memoryLayer, memoryType,',
- ' memoryCategory, sourceIds',
+ '- Every memory item must include: title, summary, details, memoryType,',
+ ' memoryCategory, sourceIds, tags, and withPreference',
'- If messages contain source metadata with stable message ids, set sourceIds to the exact ids that support this memory. Use [] when no source id is available.',
- '- Preference-specific fields in withPreference: extractedLabels,',
+ '- Every withPreference object must include: extractedLabels,',
' extractedScopes (array of strings), originContext (trigger, scenario, actor,',
' applicableWhen, notApplicableWhen), appContext (app, surface, feature,',
- ' route), conclusionDirectives, type, suggestions, scorePriority',
+ ' route), conclusionDirectives, type, suggestions, scorePriority. Use [] for arrays with no values and null for absent contexts.',
'\n',
'`extractedScopes` is a simple string array describing the preference scope.',
'\n',
@@ -158,8 +159,8 @@ export const preferencePrompt = [
'1. Analyze the conversation for preference layer information',
'2. Extract each distinct preference memory as a separate item',
'3. Ensure all memories are self-contained (no pronouns, complete context)',
- '4. Return a JSON array conforming to the schema above',
- '5. Return `[]` if you find no preference memories',
+ '4. Return a JSON object conforming to the schema above; never return a bare array',
+ '5. Return `{ "memories": [] }` if you find no preference memories',
'6. No matter what the language of the retrieved language is, always use {{ language }} for output',
'\n',
'Respond with valid JSON without commentary.',
diff --git a/packages/memory-user-memory/src/schemas/activity.test.ts b/packages/memory-user-memory/src/schemas/activity.test.ts
index e067b7c050f..eb86e0d3e06 100644
--- a/packages/memory-user-memory/src/schemas/activity.test.ts
+++ b/packages/memory-user-memory/src/schemas/activity.test.ts
@@ -1,6 +1,7 @@
+import type { JSONSchema7 } from 'json-schema';
import { describe, expect, it } from 'vitest';
-import { ActivityMemoryItemSchema } from './activity';
+import { ActivityMemoryItemSchema, ActivityMemorySchema } from './activity';
describe('ActivityMemoryItemSchema', () => {
it('accepts nullable activity metadata from generated schema output', () => {
@@ -30,4 +31,54 @@ describe('ActivityMemoryItemSchema', () => {
expect(result.success).toBe(true);
});
+
+ /**
+ * @example
+ * A context item must not pass validation as an activity item.
+ */
+ it('rejects a non-activity memory type', () => {
+ const result = ActivityMemoryItemSchema.safeParse({
+ details: 'The user completed a planned activity.',
+ memoryCategory: 'work',
+ memoryType: 'context',
+ summary: 'The user completed an activity.',
+ tags: ['activity'],
+ title: 'Completed an activity',
+ withActivity: {
+ narrative: 'The activity was completed.',
+ },
+ });
+
+ /**
+ * @example
+ * `memoryType: "context"` produces an unsuccessful parse.
+ */
+ expect(result.success).toBe(false);
+ });
+
+ /**
+ * @example
+ * An activity without an explicit lifecycle status emits `status: null`.
+ */
+ it('allows null in the generated activity status enum', () => {
+ const rootSchema = ActivityMemorySchema.schema as JSONSchema7;
+ const memoriesSchema = rootSchema.properties?.memories as JSONSchema7;
+ const memoryItemSchema = memoriesSchema.items as JSONSchema7;
+ const withActivitySchema = memoryItemSchema.properties?.withActivity as JSONSchema7;
+ const statusSchema = withActivitySchema.properties?.status as JSONSchema7;
+
+ /**
+ * @example
+ * The strict schema status enum contains both `"completed"` and `null`.
+ */
+ expect(statusSchema.enum).toEqual([
+ 'planned',
+ 'completed',
+ 'cancelled',
+ 'ongoing',
+ 'on_hold',
+ 'pending',
+ null,
+ ]);
+ });
});
diff --git a/packages/memory-user-memory/src/schemas/activity.ts b/packages/memory-user-memory/src/schemas/activity.ts
index 18d4d25fc3a..84f3c2e2c80 100644
--- a/packages/memory-user-memory/src/schemas/activity.ts
+++ b/packages/memory-user-memory/src/schemas/activity.ts
@@ -4,20 +4,18 @@ import { ActivityTypeEnum, TypesEnum } from '@lobechat/types';
import type { JSONSchema7 } from 'json-schema';
import { z } from 'zod';
-import { MemoryTypeSchema } from './common';
-
const ActivityAssociatedLocationSchema = z.object({
address: z.string().nullish(),
extra: z.string().nullish(),
- name: z.string().optional(),
+ name: z.string().nullish(),
tags: z.array(z.string()).nullish(),
- type: z.string().optional(),
+ type: z.string().nullish(),
});
const ActivityAssociationSchema = z.object({
extra: z.string().nullish(),
name: z.string(),
- type: z.string().optional(),
+ type: z.string().nullish(),
});
export const WithActivitySchema = z.object({
@@ -39,7 +37,7 @@ export const WithActivitySchema = z.object({
export const ActivityMemoryItemSchema = z.object({
details: z.string(),
memoryCategory: z.string(),
- memoryType: MemoryTypeSchema,
+ memoryType: z.literal(TypesEnum.Activity),
sourceIds: z.array(z.string()).nullish(),
summary: z.string(),
tags: z.array(z.string()),
@@ -60,7 +58,7 @@ export type ActivityMemory = z.infer<typeof ActivityMemoriesSchema>;
export const ActivityMemorySchema: GenerateObjectSchema = {
description:
- 'Extract episodic activities with clear timelines, participants, objects, subjects, locations, and feelings. Temporal and associated fields are optional—omit when missing rather than guessing.',
+ 'Extract episodic activities with clear timelines, participants, objects, subjects, locations, and feelings. Return every schema key, using null for unknown optional values and [] for empty arrays.',
name: 'activity_extraction',
schema: {
additionalProperties: false,
@@ -127,7 +125,7 @@ export const ActivityMemorySchema: GenerateObjectSchema = {
properties: {
details: {
description:
- 'Optional detailed information or longer notes supporting the summary and narrative.',
+ 'Detailed information or longer notes supporting the summary and narrative. Use an empty string when no additional detail exists.',
type: 'string',
},
memoryCategory: {
@@ -163,7 +161,7 @@ export const ActivityMemorySchema: GenerateObjectSchema = {
withActivity: {
additionalProperties: false,
description:
- 'Structured activity fields. Temporal and association values are optional—include only when the user mentioned them.',
+ 'Structured activity fields. Use null for unknown optional scalar values and [] for empty associations.',
properties: {
associatedLocations: {
description:
@@ -252,7 +250,7 @@ export const ActivityMemorySchema: GenerateObjectSchema = {
},
endsAt: {
description:
- 'ISO 8601 end time for the activity when specified. Omit if not explicitly provided.',
+ 'ISO 8601 end time for the activity when specified. Use null if not explicitly provided.',
format: 'date-time',
type: ['string', 'null'],
},
@@ -274,19 +272,27 @@ export const ActivityMemorySchema: GenerateObjectSchema = {
},
notes: {
description:
- 'Short annotations such as agenda, preparation, or quick bullets distinct from narrative.',
+ 'Short annotations such as agenda, preparation, or quick bullets distinct from narrative. Use null when absent.',
type: ['string', 'null'],
},
startsAt: {
description:
- 'ISO 8601 start time for the activity when specified. Omit if not explicitly provided.',
+ 'ISO 8601 start time for the activity when specified. Use null if not explicitly provided.',
format: 'date-time',
type: ['string', 'null'],
},
status: {
description:
- 'Lifecycle status when mentioned. Use planned/completed/cancelled/ongoing/on_hold/pending. Omit if unclear.',
- enum: ['planned', 'completed', 'cancelled', 'ongoing', 'on_hold', 'pending'],
+ 'Lifecycle status when mentioned. Use planned/completed/cancelled/ongoing/on_hold/pending. Use null if unclear.',
+ enum: [
+ 'planned',
+ 'completed',
+ 'cancelled',
+ 'ongoing',
+ 'on_hold',
+ 'pending',
+ null,
+ ],
type: ['string', 'null'],
},
tags: {
diff --git a/packages/memory-user-memory/src/schemas/context.ts b/packages/memory-user-memory/src/schemas/context.ts
index 0c69df3feac..de42d30149f 100644
--- a/packages/memory-user-memory/src/schemas/context.ts
+++ b/packages/memory-user-memory/src/schemas/context.ts
@@ -66,7 +66,7 @@ export const WithContextSchema = z.object({
.min(0)
.max(1)
.describe('Numeric score (0-1 (0% to 100%)) describing urgency'),
- title: z.string().describe('Optional synthesized context headline'),
+ title: z.string().describe('Required synthesized context headline'),
type: z
.string()
.describe("High level context archetype (e.g., 'project', 'relationship', 'goal')"),
@@ -76,7 +76,7 @@ export const WithContextSchema = z.object({
* Single context memory item
*/
export const ContextMemoryItemSchema = z.object({
- details: z.string().describe('Optional detailed information'),
+ details: z.string().describe('Detailed information; use an empty string when none is needed'),
memoryCategory: z.string().describe('Memory category'),
memoryType: MemoryTypeSchema.describe('Memory type'),
sourceIds: z
diff --git a/packages/memory-user-memory/src/schemas/experience.ts b/packages/memory-user-memory/src/schemas/experience.ts
index 216460968e9..50cf2e2e698 100644
--- a/packages/memory-user-memory/src/schemas/experience.ts
+++ b/packages/memory-user-memory/src/schemas/experience.ts
@@ -34,7 +34,7 @@ export const WithExperienceSchema = z.object({
* Single experience memory item
*/
export const ExperienceMemoryItemSchema = z.object({
- details: z.string().describe('Optional detailed information'),
+ details: z.string().describe('Detailed information; use an empty string when none is needed'),
memoryCategory: z.string().describe('Memory category'),
memoryType: MemoryTypeSchema.describe('Memory type'),
sourceIds: z
diff --git a/packages/memory-user-memory/src/schemas/preference.ts b/packages/memory-user-memory/src/schemas/preference.ts
index c50ff63e277..c4bf3f6a75f 100644
--- a/packages/memory-user-memory/src/schemas/preference.ts
+++ b/packages/memory-user-memory/src/schemas/preference.ts
@@ -63,7 +63,7 @@ export const WithPreferenceSchema = z.object({
* Single preference memory item
*/
export const PreferenceMemoryItemSchema = z.object({
- details: z.string().describe('Optional detailed information'),
+ details: z.string().describe('Detailed information; use an empty string when none is needed'),
memoryCategory: z.string().describe('Memory category'),
memoryType: MemoryTypeSchema.describe('Memory type'),
sourceIds: z