Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

test(mcp): memory_conversation_mode on starter within trimmed budgets (GBRA-108 decision A)

garrytan777fe824a36f
diff --git a/docs/TOOL_CATALOG.md b/docs/TOOL_CATALOG.md
index 954680b8fb..974e5cbce2 100644
--- a/docs/TOOL_CATALOG.md
+++ b/docs/TOOL_CATALOG.md
@@ -152,7 +152,7 @@ Every non-localOnly operation on the MCP surface: 167 tools across 26 areas. **S
| Tool | Description | Scope | Starter | Gate |
|---|---|---|---|---|
| `get_memory_settings` | Memory writeback settings: the mode agents follow, the exact rule text, every mode's rule, background capture state, and whether you may change it. | read | | |
-| `memory_conversation_mode` | Use when the user says "save everything from here" (all) or "stop saving" (off: explicit saves only): returns the memory rule for the rest of this conversation. | write | yes | |
+| `memory_conversation_mode` | Use when the user says "save everything from here" (all) or "stop saving" (off): returns this conversation's memory rule. | write | yes | |
| `set_memory_writeback` | Change the brain-wide writeback mode agents are told to follow (inherit uses the operator's setting). | admin | | `mcp.publish_memory_settings` |
## memory-verbs
diff --git a/src/core/operation-manifest.generated.ts b/src/core/operation-manifest.generated.ts
index 9ab95a24fb..b246dda373 100644
--- a/src/core/operation-manifest.generated.ts
+++ b/src/core/operation-manifest.generated.ts
@@ -6288,7 +6288,7 @@ export const OPERATION_MANIFEST: OperationMeta[] = [
{
"name": "memory_conversation_mode",
"outputRedaction": "no_stored_text",
- "description": "Use when the user says \"save everything from here\" (all) or \"stop saving\" (off: explicit saves only): returns the memory rule for the rest of this conversation. Stores nothing.",
+ "description": "Use when the user says \"save everything from here\" (all) or \"stop saving\" (off): returns this conversation's memory rule. Stores nothing.",
"params": {
"mode": {
"type": "string",
@@ -6299,7 +6299,7 @@ export const OPERATION_MANIFEST: OperationMeta[] = [
"salient",
"all"
],
- "description": "all | salient | off (only what the user explicitly asks to keep) | brain (this brain's mode)."
+ "description": "all | salient | off (explicit saves only) | brain (this brain's mode)."
}
},
"scope": "write",
diff --git a/src/core/ops/memory-settings.ts b/src/core/ops/memory-settings.ts
index c3349d3770..e0cea82323 100644
--- a/src/core/ops/memory-settings.ts
+++ b/src/core/ops/memory-settings.ts
@@ -200,9 +200,9 @@ const set_memory_writeback: Operation = {
const memory_conversation_mode: Operation = {
name: 'memory_conversation_mode',
outputRedaction: 'no_stored_text',
- description: 'Use when the user says "save everything from here" (all) or "stop saving" (off: explicit saves only): returns the memory rule for the rest of this conversation. Stores nothing.',
+ description: 'Use when the user says "save everything from here" (all) or "stop saving" (off): returns this conversation\'s memory rule. Stores nothing.',
params: {
- mode: { type: 'string', required: true, enum: [...CONVERSATION_MODES], description: 'all | salient | off (only what the user explicitly asks to keep) | brain (this brain\'s mode).' },
+ mode: { type: 'string', required: true, enum: [...CONVERSATION_MODES], description: 'all | salient | off (explicit saves only) | brain (this brain\'s mode).' },
},
scope: 'write',
area: 'memory-settings',
diff --git a/src/mcp/instructions.ts b/src/mcp/instructions.ts
index dfbf78e3d1..af369e973a 100644
--- a/src/mcp/instructions.ts
+++ b/src/mcp/instructions.ts
@@ -138,7 +138,7 @@ function contractClauses(c: CallablePredicate, writeback?: AmbientWritebackOpts
out.push('Preserve the caller\'s brain and source scope. Do not broaden access, invent missing content, or write outside the requested task.');
if (c('forget')) out.push('`forget` withdraws active memory; it does not promise erasure of source material, history, or backups.');
// GBRA-219: after the governing rule, so it never pushes that rule past the 2,048 characters capped harnesses read; the tool's description carries the trigger phrases too.
- if (c('memory_conversation_mode')) out.push('When the user asks to save everything from here, or to stop saving, call `memory_conversation_mode` and follow its rule for the rest of the conversation.');
+ if (c('memory_conversation_mode')) out.push('If the user asks to save everything from here, or to stop saving, call `memory_conversation_mode` and follow its rule.');
out.push(`When you need this connection's effective permissions or setup readiness, read gbrain://capabilities${c('whoami') ? ' (or `whoami`)' : ''}. A full tool surface does not imply administrative or delegation authority. Missing capabilities require an explicit host grant.`);
out.push('MCP admin scope does not authorize the owner dashboard or client management. For an admin login link, client registration, setup instructions, permission edits, token invalidation, revocation, or deletion, use the mcp-access skill when available, or https://github.com/garrytan/gbrain/blob/master/docs/mcp/ADMIN.md directly. Ask the server-hosting harness or a separately authorized administrator to use gbrain mcp admin with the configured server URL and its protected owner credential. Native OAuth clients initiate their own PKCE connection; preserve oauth_request when requesting a login link, and never fetch a generated single-use login link before delivering it to the owner.');
if (c('join_brain') && c('sync_brain_skills')) {
diff --git a/test/fixtures/goldens/cli/tools-json.json b/test/fixtures/goldens/cli/tools-json.json
index 1aa49ce632..26c5249956 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": 271005,
- "stdoutSha256": "e3ba5ed101382f6e0f990c2046a20d1730cc41cb88111ec449c76f9eda49e5b4",
+ "stdoutBytes": 270943,
+ "stdoutSha256": "7c79fd98e53d0f3c3d4b0b18131b6b5ef694d21ce3bdafb216d66de24a77e1d6",
"toolNames": [
"remember",
"entity",
@@ -7263,7 +7263,7 @@
"scope": "admin"
},
{
- "description": "Use when the user says \"save everything from here\" (all) or \"stop saving\" (off: explicit saves only): returns the memory rule for the rest of this conversation. Stores nothing.",
+ "description": "Use when the user says \"save everything from here\" (all) or \"stop saving\" (off): returns this conversation's memory rule. Stores nothing.",
"idempotent": false,
"local_only": false,
"mutating": false,
@@ -7275,7 +7275,7 @@
"schema": {
"properties": {
"mode": {
- "description": "all | salient | off (only what the user explicitly asks to keep) | brain (this brain's mode).",
+ "description": "all | salient | off (explicit saves only) | brain (this brain's mode).",
"enum": [
"brain",
"off",
diff --git a/test/mcp-initialize-instructions.test.ts b/test/mcp-initialize-instructions.test.ts
index 3edc76f4c4..0a75877be5 100644
--- a/test/mcp-initialize-instructions.test.ts
+++ b/test/mcp-initialize-instructions.test.ts
@@ -51,7 +51,7 @@ const BATCHING_CLAUSE_BYTES = 200;
const NAMES_ROW_REFERENCES_BYTES = 70;
/**
* GBRA-219: the per-conversation memory switch clause ("save everything from here" / "stop saving" →
- * memory_conversation_mode), 146 bytes on every surface serving the tool (starter and full), placed after the
+ * memory_conversation_mode), 111 bytes on every surface serving the tool (starter and full), placed after the
* governing rule so that rule's offsets do not move (test/mcp-instructions-governing-rule.test.ts).
*/
const CONVERSATION_SWITCH_CLAUSE_BYTES = 150;
diff --git a/test/mcp-schema-budget.test.ts b/test/mcp-schema-budget.test.ts
index 6b234dcd68..d5c7e13205 100644
--- a/test/mcp-schema-budget.test.ts
+++ b/test/mcp-schema-budget.test.ts
@@ -63,16 +63,16 @@ import { stdioVisibleTools } from '../src/mcp/server.ts';
import { buildMcpInstructions, GBRAIN_MCP_INSTRUCTIONS } from '../src/mcp/instructions.ts';
import { cl100kAvailable, estimateTokens } from '../src/core/chunkers/token-estimate.ts';
-const SERVED_STARTER_MAX_CHARS = 18_300; // GST-927: +100 for get_page's one-window-selector rule (GPT-6.1 Sol sent lines, bytes and around_chunk_id together on 436 of 607 recorded calls); get_page's own text paid 3
+const SERVED_STARTER_MAX_CHARS = 18_707; // GBRA-219 (#7795, GBRA-108 decision A): memory_conversation_mode joins starter (the per-conversation save switch, approved in the GBRA-219 plan), its description and the instructions clause trimmed first: +407 (18,507 served, 200 headroom kept); GST-927: +100 for get_page's one-window-selector rule (GPT-6.1 Sol sent lines, bytes and around_chunk_id together on 436 of 607 recorded calls); get_page's own text paid 3
/** Headroom the served starter list must keep under the ceiling (wave 16: 24,998 of 25,000 left 2 characters; 200 is what the wave reaches without touching text other threads own, raised to 300 once the entity card and query/search trims land). */
const SERVED_STARTER_MIN_HEADROOM = 200;
const SERVED_STARTER_MAX_TOKENS = 4_300;
/** The whole tools/list JSON, annotations included (25,735 measured at v0.60.46.0; traverse_graph's `hops` is full-surface-only, 25,941 measured; 26,402 once mute_notice, the dismissal for the coaching notices starter sessions receive, joined starter; 26,671 with #6007's put_page wait_ms param and write guidance, which carry the put_pages hint and the receipt poll rule starter agents need; 26,679 with delta's opaque `cursor` param, paid for by trimming delta's own descriptions, model-visible 24,985; 26,692 with recall's `question` param, paid for by trimming recall's own parameter text, model-visible 24,998; 24,996 after the #6446 merge, recall's grep text trimmed again). */
-const SERVED_STARTER_MAX_JSON_CHARS = 19_900; // GBRA-156: 19,431 measured; GST-927: +100 for get_page's one-window-selector rule
+const SERVED_STARTER_MAX_JSON_CHARS = 20_201; // GBRA-219 (#7795, GBRA-108 decision A): +301 for memory_conversation_mode on starter, trimmed first; GBRA-156: 19,431 measured; GST-927: +100 for get_page's one-window-selector rule
/** GBRA-156: the UTF-8 bytes of the served starter tools/list result (`{"tools":[...]}`, annotations included) that harnesses re-fetch every turn. */
-const SERVED_STARTER_MAX_RESULT_BYTES = 19_900; // 26,546 before GBRA-156, 19,489 after; GST-927: +100 for get_page's one-window-selector rule
+const SERVED_STARTER_MAX_RESULT_BYTES = 20_260; // GBRA-219 (#7795, GBRA-108 decision A): memory_conversation_mode joins starter (the per-conversation save switch, approved in the GBRA-219 plan), its description and the instructions clause trimmed first: +360; 26,546 before GBRA-156, 19,489 after; GST-927: +100 for get_page's one-window-selector rule
/** 4,042 at the cost wave + 586 for the operator contract's error protocol, notice prefix and memory loop (F1); no schema guidance moved here. */
-const INSTRUCTIONS_MAX_CHARS = 5_108; // #6007: +240 for the issue-required write guidance (put_pages, wait_ms); Cat 40 Hard round 4: +107 for batching lists of names (entity names, keyword OR) and sending independent calls together; d5b: +70 for the brief naming the fields compact `entity names` rows carry (the maximal rendering, record types enrolled; +39 at the default) instead of a `referenced_by` walk batch mode cannot do; F4: +63 for instruction 7's governing rule (the record whose terms are in effect on the date asked about governs; page dates are named as page dates), 74 characters longer than the "prefer the newest governing source" sentence it replaces, 11 paid by cutting "the best-ranked excerpts" to "top excerpts" in the same clause
+const INSTRUCTIONS_MAX_CHARS = 5_219; // GBRA-219 (#7795, GBRA-108 decision A): memory_conversation_mode joins starter (the per-conversation save switch, approved in the GBRA-219 plan), its description and the instructions clause trimmed first: +111 for the switch clause at the maximal rendering; #6007: +240 for the issue-required write guidance (put_pages, wait_ms); Cat 40 Hard round 4: +107 for batching lists of names (entity names, keyword OR) and sending independent calls together; d5b: +70 for the brief naming the fields compact `entity names` rows carry (the maximal rendering, record types enrolled; +39 at the default) instead of a `referenced_by` walk batch mode cannot do; F4: +63 for instruction 7's governing rule (the record whose terms are in effect on the date asked about governs; page dates are named as page dates), 74 characters longer than the "prefer the newest governing source" sentence it replaces, 11 paid by cutting "the best-ranked excerpts" to "top excerpts" in the same clause
const DESCRIPTION_HARD_CAP = 1_200;
const PARAM_DESCRIPTION_HARD_CAP = 200;
@@ -107,7 +107,7 @@ const TOOL_BUDGETS: Record<string, number> = {
get_backlinks: 710, get_ingest_log: 280, get_page: 600, get_recent_salience: 450, get_skill: 490,
get_skill_asset: 530, get_write_request: 360, join_brain: 560, leave_brain: 540, list_brain_skillpack: 230,
list_link_sources: 220, list_pages: 850, list_skills: 400, list_write_requests: 370, put_page: 1090,
- mute_notice: 420, put_skill: 1420, query: 1700, recall: 840, remember: 940, request_tools: 530, resolve_slugs: 410, search: 1420,
+ memory_conversation_mode: 420, mute_notice: 420, put_skill: 1420, query: 1700, recall: 840, remember: 940, request_tools: 530, resolve_slugs: 410, search: 1420,
submit_agent: 420, sync_brain_skills: 770, synthesize: 510, traverse_graph: 600, whoami: 230,
};
@@ -161,10 +161,10 @@ async function served(publishSkills: boolean): Promise<Operation[]> {
}
describe('served starter tool list (Cat 40 configuration)', () => {
- test('publish_skills on (the fresh-init default): 35 tools within the character ceiling', async () => {
+ test('publish_skills on (the fresh-init default): 36 tools within the character ceiling', async () => {
const ops = await served(true);
expect(ops.map(o => o.name)).toContain('get_skill');
- expect(ops.length).toBe(35);
+ expect(ops.length).toBe(36);
expect(size(ops)).toBeLessThanOrEqual(SERVED_STARTER_MAX_CHARS);
expect(json(ops)).toBeLessThanOrEqual(SERVED_STARTER_MAX_JSON_CHARS);
});
@@ -199,7 +199,7 @@ describe('served starter tool list (Cat 40 configuration)', () => {
});
// Per-arm renderings: all off (names-row off, no records, `newest`), names-row on / records off, F4 only
- // (`in_effect`, names-row off, no records), and the maximal one (records enrolled, names-row on, `in_effect`) at 5,108.
+ // (`in_effect`, names-row off, no records), and the maximal one (records enrolled, names-row on, `in_effect`) at 5,219.
test('every per-arm rendering stays at or below the recorded size; the maximal one is the recorded size', () => {
let max = 0;
for (const governingRule of ['newest', 'in_effect'] as const) {