Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
remember: provenance may be given per item with items[] (the schema no longer requires a top-level provenance; an absent single-fact provenance still answers invalid_params, an empty one provenance_required)
garrytanecd6ea4c3cd8
diff --git a/docs/protocol/MEMORY_VERBS_v1.md b/docs/protocol/MEMORY_VERBS_v1.mdindex 17564c7fc7..9145cd5513 100644--- a/docs/protocol/MEMORY_VERBS_v1.md+++ b/docs/protocol/MEMORY_VERBS_v1.md@@ -288,7 +288,8 @@ Optional response fields; clients must ignore any they do not know.context compaction. Each item is a fact string or an object with `fact` plusoptional `entity`, `kind`, `ttl`, `visibility`, `provenance` and`infer_entity`; top-level `provenance`,-`kind`, `ttl`, `visibility` and `infer_entity` are the defaults. Passing both+`kind`, `ttl`, `visibility` and `infer_entity` are the defaults, so top-level+`provenance` is optional when every item carries its own. Passing both`fact` and `items` is `invalid_params`.Every item is validated before any is written: one invalid item refuses thediff --git a/llms-full.txt b/llms-full.txtindex 71f8a8cad3..940302f948 100644--- a/llms-full.txt+++ b/llms-full.txt@@ -8811,7 +8811,8 @@ Optional response fields; clients must ignore any they do not know.context compaction. Each item is a fact string or an object with `fact` plusoptional `entity`, `kind`, `ttl`, `visibility`, `provenance` and`infer_entity`; top-level `provenance`,-`kind`, `ttl`, `visibility` and `infer_entity` are the defaults. Passing both+`kind`, `ttl`, `visibility` and `infer_entity` are the defaults, so top-level+`provenance` is optional when every item carries its own. Passing both`fact` and `items` is `invalid_params`.Every item is validated before any is written: one invalid item refuses thediff --git a/src/core/verbs.ts b/src/core/verbs.tsindex b28bf5df26..ac32111b12 100644--- a/src/core/verbs.ts+++ b/src/core/verbs.ts@@ -73,8 +73,8 @@ const remember: Operation = {},provenance: {type: 'string',- required: true,- description: 'Where the fact came from (max 500 chars).',+ // Required for a single fact (the handler refuses with provenance_required); with items it may be given per item.+ description: 'Where the fact came from (max 500 chars); per item with items.',},ttl: {type: 'string',@@ -116,6 +116,14 @@ const remember: Operation = {'Pass the claim to remember, e.g. fact: "picked Stripe over Adyen — onboarding speed".',);}+ // v1 contract: an absent provenance is a missing required parameter (invalid_params), an empty one is provenance_required.+ if (p.provenance === undefined) {+ throw verbError(+ 'invalid_params',+ 'Missing required parameter: provenance',+ 'Pass `provenance` as a string (where the fact came from), e.g. provenance: "user told me, 2026-06-12". With items, provenance may be given per item instead.',+ );+ }const provenance = typeof p.provenance === 'string' ? p.provenance.trim() : '';if (!provenance) {throw verbError(diff --git a/test/core-cli.test.ts b/test/core-cli.test.tsindex 107e8f54c6..f2f72830df 100644--- a/test/core-cli.test.ts+++ b/test/core-cli.test.ts@@ -154,6 +154,15 @@ describe('remember items[]', () => {expect(after).toBe(n);});+ test('provenance may be given per item instead of at the top level', async () => {+ const r = await call('remember', { items: [{ fact: 'Runs on Saturdays', provenance: 'user said' }, { fact: 'Uses Hoka shoes', provenance: 'user said' }] }, true);+ expect({ isError: r.isError, text: r.text }).toMatchObject({ isError: false });+ expect(r.body).toMatchObject({ saved: 2, failed: 0 });+ const missing = await call('remember', { items: [{ fact: 'No source' }] }, true);+ expect(missing.isError).toBe(true);+ expect(missing.text).toContain('items[0]');+ });+test('one invalid item refuses the batch before any write', async () => {const bad = await call('remember', { provenance: 'p', items: [{ fact: 'ok' }, { fact: '' }] }, true);expect(bad.isError).toBe(true);