Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix(remember): refusals name the whole valid call; description opens with the call (GST-1493)

garrytanb8e7aefca45b
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 305df12a8c..6bbe472419 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,18 @@ credits are retained; no result has been reassigned to another provider. Origina
identifiers and attribution are available in the pre-removal Git revision
`6040075c6cb95be5881cc2e1b76ef7d71f4e5d29` (retained on 2026-09-23).
+## [Unreleased]
+
+**A `remember` refused for its arguments now names the whole valid call, so an agent that never read the schema saves on its next try.**
+
+An agent on a harness that lists MCP tools as one line and shows parameters only on request sent `remember` its host's own memory shape, `facts: [{text}]`. gbrain answered "did you mean `fact`?", the agent resent `{fact, entity}` without provenance, and only the third call saved: two refusals per saved fact. The refusal now points `facts` at `items` and `text` at `fact`, and quotes a call that validates, provenance included. provenance stays required.
+
+### Itemized changes
+
+- `src/mcp/validate-params.ts`, `src/mcp/dispatch.ts`: an unknown `facts` on `remember` suggests `items` and an unknown `text` suggests `fact`; the refusal then appends the operation's `callShape`, a valid call as JSON that says provenance is required. `callShape` is a new optional `Operation` field; only `remember` sets it.
+- `src/core/verbs.ts`: `remember`'s description opens with the call itself, `{fact, provenance (required: source), \`entity\` (subject; recall needs it)} or items[]`, inside the 117 characters a one-line tool listing keeps. A missing `fact` quotes the same valid call instead of an example without provenance.
+- `src/core/remember-batch.ts`: an item that carries `text` is told to rename it to `fact`.
+
## [0.60.585.0] - 2026-11-05
**CI shard weights are re-mined from the 2026-11-05 nightlies, so the unit and serial lanes pack their shards on current timings.** Nothing changes for users.
diff --git a/docs/TOOL_CATALOG.md b/docs/TOOL_CATALOG.md
index 3fa32c5baa..88cbb58ec8 100644
--- a/docs/TOOL_CATALOG.md
+++ b/docs/TOOL_CATALOG.md
@@ -164,7 +164,7 @@ Every non-localOnly operation on the MCP surface: 168 tools across 26 areas. **S
| `entity` | Person/company/account card, zero LLM. | read | yes | |
| `forget` | Expire a remembered fact by its fact_id (never a page slug). | write | yes | |
| `recall` | Read facts by entity, since or session_id; `query` also searches pages. | read | yes | |
-| `remember` | Save facts with provenance; set `entity` (the subject) or recall misses it. | write | yes | |
+| `remember` | Save {fact, provenance (required: source), `entity` (subject; recall needs it)} or items[]. | write | yes | |
| `synthesize` | [EXPENSIVE / SLOW: LLM calls] Cited answer to a broad question across pages. | read | yes | |
## ontology
diff --git a/src/core/operation-manifest.generated.ts b/src/core/operation-manifest.generated.ts
index 771642857f..eefec5ac65 100644
--- a/src/core/operation-manifest.generated.ts
+++ b/src/core/operation-manifest.generated.ts
@@ -14,7 +14,8 @@ export const OPERATION_MANIFEST: OperationMeta[] = [
"name": "remember",
"idempotent": true,
"outputRedaction": "no_stored_text",
- "description": "Save facts with provenance; set `entity` (the subject) or recall misses it. Branch on `status`; write_pending: poll get_write_request.",
+ "description": "Save {fact, provenance (required: source), `entity` (subject; recall needs it)} or items[]. Branch on `status`; write_pending: poll get_write_request.",
+ "callShape": "A valid call: {\"fact\": \"Alice Example prefers email\", \"entity\": \"alice-example\", \"provenance\": \"user told me, 2026-06-12\"}; several: items: [{fact, entity, provenance}, ...]. provenance (where the fact came from) is required.",
"params": {
"source_id": {
"type": "string",
diff --git a/src/core/ops/contract.ts b/src/core/ops/contract.ts
index f01004f4da..a210fa1a80 100644
--- a/src/core/ops/contract.ts
+++ b/src/core/ops/contract.ts
@@ -792,6 +792,11 @@ export interface Operation {
name: string;
description: string;
params: Record<string, ParamDef>;
+ /**
+ * GST-1493: one sentence with a valid call as JSON, appended to the suggestion when dispatch refuses an unknown
+ * parameter, so a client that never read the schema gets the whole required shape, not only the nearest name.
+ */
+ callShape?: string;
handler: (ctx: OperationContext, params: Record<string, unknown>) => Promise<unknown>;
outputRedaction: OutputRedactionPolicy;
mutating?: boolean;
diff --git a/src/core/remember-batch.ts b/src/core/remember-batch.ts
index f80e629f83..a4fc215af1 100644
--- a/src/core/remember-batch.ts
+++ b/src/core/remember-batch.ts
@@ -79,7 +79,8 @@ export async function runRememberBatch(ctx: OperationContext, p: Record<string,
throw verbError('invalid_params', `items[${index}] must be an object.`, 'Each item is { "fact": "...", optional entity, kind, ttl, visibility, provenance, content_origin, valid_from }.');
}
const extra = Object.keys(raw).filter(k => !ITEM_KEYS.has(k));
- if (extra.length) throw verbError('invalid_params', `items[${index}] has unknown field(s): ${extra.join(', ')}.`, `Allowed item fields: ${[...ITEM_KEYS].join(', ')}.`);
+ if (extra.length) throw verbError('invalid_params', `items[${index}] has unknown field(s): ${extra.join(', ')}.`,
+ `${extra.includes('text') ? 'Rename text to fact. ' : ''}Allowed item fields: ${[...ITEM_KEYS].join(', ')}.`);
return { ...shared, ...(raw as Record<string, unknown>) };
});
// All-or-none validation before any admission.
diff --git a/src/core/verbs.ts b/src/core/verbs.ts
index 23ae491902..cef0b8c2a2 100644
--- a/src/core/verbs.ts
+++ b/src/core/verbs.ts
@@ -59,6 +59,7 @@ const FACT_KINDS = ['event', 'preference', 'commitment', 'belief', 'fact'] as co
*/
const FACT_KINDS_RESPONSE = [...FACT_KINDS, 'idea'] as const;
const PROVENANCE_MAX = 500;
+const REMEMBER_CALL_SHAPE = 'A valid call: {"fact": "Alice Example prefers email", "entity": "alice-example", "provenance": "user told me, 2026-06-12"}; several: items: [{fact, entity, provenance}, ...]. provenance (where the fact came from) is required.';
// ─── remember ────────────────────────────────────────────────────────────────
@@ -66,7 +67,8 @@ const remember: Operation = {
name: 'remember',
idempotent: true,
outputRedaction: 'no_stored_text',
- description: 'Save facts with provenance; set `entity` (the subject) or recall misses it. Branch on `status`; write_pending: poll get_write_request.',
+ description: 'Save {fact, provenance (required: source), `entity` (subject; recall needs it)} or items[]. Branch on `status`; write_pending: poll get_write_request.',
+ callShape: REMEMBER_CALL_SHAPE,
params: {
...AGENT_CONTENT_PARAMS,
fact: { type: 'string', description: 'One claim.' },
@@ -133,7 +135,7 @@ const remember: Operation = {
'fact must be a non-empty string.',
p.fact === undefined && Object.keys(p).length === 0
? 'The call arrived with no arguments; a tool call cut off at your output-token limit looks like this. Pass fact, or items with fewer entries per call.'
- : 'Pass the claim to remember, e.g. fact: "picked Stripe over Adyen — onboarding speed", or several as items: [{fact, provenance}].',
+ : `Pass the claim to remember in fact. ${REMEMBER_CALL_SHAPE}`,
);
}
// v1 contract: an absent provenance is a missing required parameter (invalid_params), an empty one is provenance_required.
diff --git a/src/mcp/dispatch.ts b/src/mcp/dispatch.ts
index 3fce62c0a3..b1fb7f898b 100644
--- a/src/mcp/dispatch.ts
+++ b/src/mcp/dispatch.ts
@@ -1150,7 +1150,7 @@ async function dispatchResolvedCall(
.map(w => w.suggestion
? `Unknown parameter "${w.param}" — did you mean "${w.suggestion}"?`
: `Unknown parameter "${w.param}".`)
- .join(' ');
+ .join(' ') + (op.callShape ? ` ${op.callShape}` : '');
const strict = new OperationError('invalid_params',
`${n} unknown parameter${n === 1 ? '' : 's'} not declared in the ${name} tool schema (${op.mutating === true ? 'write operations always reject unknown parameters; nothing was written' : 'mcp.strict_params=reject'}). See suggestion for the submitted name${n === 1 ? '' : 's'}.`,
suggestion);
diff --git a/src/mcp/validate-params.ts b/src/mcp/validate-params.ts
index 06d670dbde..2cf42c0aae 100644
--- a/src/mcp/validate-params.ts
+++ b/src/mcp/validate-params.ts
@@ -192,6 +192,7 @@ export const UNKNOWN_PARAM_ALLOWLIST: ReadonlySet<string> = new Set(['_meta', 'd
*/
const PARAM_ALIAS_HINTS: Readonly<Record<string, Readonly<Record<string, string>>>> = {
add_timeline_entry: { content: 'detail', text: 'detail', body: 'detail' },
+ remember: { facts: 'items', text: 'fact' },
};
/**
diff --git a/test/fixtures/goldens/cli/tools-json.json b/test/fixtures/goldens/cli/tools-json.json
index 37f2de931b..d3cc3a798d 100644
--- a/test/fixtures/goldens/cli/tools-json.json
+++ b/test/fixtures/goldens/cli/tools-json.json
@@ -2,8 +2,8 @@
"golden": {
"exitCode": 0,
"stderr": "",
- "stdoutBytes": 279122,
- "stdoutSha256": "4fa524c9f6f7549030069ef990a65f02fac7b48d8d854e802882eb5de7744669",
+ "stdoutBytes": 279138,
+ "stdoutSha256": "dc5e4cd7b6f2191ea8582926b5c59a575b495f4f8ce4093bfdc06b2b1f573aed",
"toolNames": [
"remember",
"entity",
@@ -199,7 +199,7 @@
],
"tools": [
{
- "description": "Save facts with provenance; set `entity` (the subject) or recall misses it. Branch on `status`; write_pending: poll get_write_request.",
+ "description": "Save {fact, provenance (required: source), `entity` (subject; recall needs it)} or items[]. Branch on `status`; write_pending: poll get_write_request.",
"idempotent": true,
"local_only": false,
"mutating": true,
diff --git a/test/fixtures/goldens/exports/types.json b/test/fixtures/goldens/exports/types.json
index e82a42ae81..cead8cfc01 100644
--- a/test/fixtures/goldens/exports/types.json
+++ b/test/fixtures/goldens/exports/types.json
@@ -6770,6 +6770,7 @@
"agentCallable?: true | undefined",
"annotations?: { title?: string; readOnlyHint?: boolean; destructiveHint?: boolean; idempotentHint?: boolean; } | undefined",
"area?: string | undefined",
+ "callShape?: string | undefined",
"cliHints?: { name?: string; aliases?: string[]; positional?: string[]; stdin?: string; hidden?: boolean; } | undefined",
"cliOnly?: { argv: readonly string[]; } | undefined",
"description: string",
diff --git a/test/remember-invalid-params-shapes-gst1493.test.ts b/test/remember-invalid-params-shapes-gst1493.test.ts
new file mode 100644
index 0000000000..309f83b11e
--- /dev/null
+++ b/test/remember-invalid-params-shapes-gst1493.test.ts
@@ -0,0 +1,105 @@
+/**
+ * GST-1493 (HARN-1 QM M1 eval): a schema-less client (QM lists each MCP tool as one line, its description cut to 117
+ * characters, and shows parameters only through tool_search) called remember 67 times; 44 were refused invalid_params.
+ * Every refused session ran the same three calls: facts: [{text, entity}] (22), then {fact, entity} with no
+ * provenance (22), then {fact, entity, provenance}, which saved. These replay those argument shapes with placeholders.
+ * provenance stays required: only the refusal text and the description change.
+ */
+import { describe, expect, test } from 'bun:test';
+import { dispatchToolCall } from '../src/mcp/dispatch.ts';
+import { operations } from '../src/core/operations.ts';
+import type { BrainEngine } from '../src/core/engine.ts';
+
+const engine = {
+ kind: 'pglite',
+ getConfig: async () => null,
+ executeRaw: async () => [],
+} as unknown as BrainEngine;
+const OPTS = { remote: true, transport: 'http' as const, sourceId: 'default' };
+const FACT = 'Alice Example uses Dock 12 for Acme Example pickups (from 2026-01-05 onward).';
+
+async function call(args: Record<string, unknown>) {
+ const out = await dispatchToolCall(engine, 'remember', args, OPTS);
+ return { isError: out.isError === true, envelope: JSON.parse(out.content[0]!.text) };
+}
+
+/** The first JSON object quoted in a suggestion: the corrected example. */
+function quotedExample(suggestion: string): Record<string, unknown> {
+ const start = suggestion.indexOf('{');
+ let depth = 0;
+ for (let i = start; i < suggestion.length; i++) {
+ if (suggestion[i] === '{') depth++;
+ if (suggestion[i] === '}' && --depth === 0) return JSON.parse(suggestion.slice(start, i + 1));
+ }
+ throw new Error('no JSON example in: ' + suggestion);
+}
+
+describe('remember refusals name the rule and a corrected example (GST-1493)', () => {
+ for (const [label, args] of [
+ ['facts[] with a top-level entity (18 of 44)', { facts: [{ text: FACT }], entity: 'Alice Example' }],
+ ['facts[] with entity inside the item (4 of 44)', { facts: [{ text: FACT, entity: 'Alice Example' }] }],
+ ] as const) {
+ test(label + ': points at items, says provenance is required, and quotes a call that validates', async () => {
+ const { isError, envelope } = await call(args);
+ expect(isError).toBe(true);
+ expect(envelope.error).toBe('invalid_params');
+ expect(envelope.suggestion).toContain('Unknown parameter "facts"');
+ expect(envelope.suggestion).toContain('did you mean "items"');
+ expect(envelope.suggestion).not.toContain('did you mean "fact"');
+ expect(envelope.suggestion).toMatch(/provenance[^.]*required/);
+ const example = quotedExample(envelope.suggestion);
+ expect(Object.keys(example).sort()).toEqual(['entity', 'fact', 'provenance']);
+ const retried = await call({ ...example, dry_run: true });
+ expect(retried.isError).toBe(false);
+ expect(retried.envelope.dry_run).toBe(true);
+ });
+ }
+
+ test('{fact, entity} with no provenance (22 of 44) is still refused and names provenance', async () => {
+ const { isError, envelope } = await call({ fact: FACT, entity: 'Alice Example' });
+ expect(isError).toBe(true);
+ expect(envelope.error).toBe('invalid_params');
+ expect(envelope.message).toBe('Missing required parameter: provenance');
+ expect(envelope.suggestion).toContain('provenance');
+ });
+
+ test('the saved shape {fact, entity, provenance} validates', async () => {
+ const { isError } = await call({ fact: FACT, entity: 'Alice Example', provenance: 'Alice Example told the assistant in a DM, 2026-01-05', dry_run: true });
+ expect(isError).toBe(false);
+ });
+
+ test('text for fact gets "did you mean fact" and the example', async () => {
+ const { isError, envelope } = await call({ text: FACT, entity: 'Alice Example', provenance: 'chat 2026-01-05' });
+ expect(isError).toBe(true);
+ expect(envelope.suggestion).toContain('did you mean "fact"');
+ expect(Object.keys(quotedExample(envelope.suggestion)).sort()).toEqual(['entity', 'fact', 'provenance']);
+ });
+
+ test('items[] whose entries use text for fact names fact', async () => {
+ const { isError, envelope } = await call({ items: [{ text: FACT, entity: 'Alice Example', provenance: 'chat 2026-01-05' }] });
+ expect(isError).toBe(true);
+ expect(envelope.error).toBe('invalid_params');
+ expect(envelope.suggestion).toContain('fact');
+ expect(envelope.suggestion).toMatch(/text[^.]*fact/);
+ });
+
+ test('items[] without provenance is still refused', async () => {
+ const { isError, envelope } = await call({ items: [{ fact: FACT, entity: 'Alice Example' }] });
+ expect(isError).toBe(true);
+ expect(envelope.error).toBe('invalid_params');
+ expect(envelope.message).toContain('provenance');
+ });
+
+ test('a missing fact quotes an example that includes provenance', async () => {
+ const { isError, envelope } = await call({ fact: '', entity: 'Alice Example', provenance: 'chat 2026-01-05' });
+ expect(isError).toBe(true);
+ expect(Object.keys(quotedExample(envelope.suggestion)).sort()).toEqual(['entity', 'fact', 'provenance']);
+ });
+
+ test('the description\'s first 117 characters name the call: fact, provenance (required), entity, items', () => {
+ // QM lists each MCP tool as its first 117 characters plus "..."; "Save facts" read as a parameter named facts.
+ const head = operations.find(o => o.name === 'remember')!.description.slice(0, 117);
+ for (const word of ['fact', 'provenance', 'required', 'entity', 'items']) expect(head).toContain(word);
+ expect(head).not.toMatch(/\bfacts\b/);
+ });
+});