Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

feat(mcp): guidance batches lists of names and independent calls; search says keyword mode takes OR

garrytanfa520b72bcd5
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ad72f72b9f..6ae04e1d90 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -20,6 +20,7 @@ On a company brain, most records never repeat a customer's full name. They use a
| Where | What changed |
|---|---|
+| Instructions and `search` | The answering clause keeps separate parts of a question in separate searches but batches lists of names or codes (`entity` with `names`, or one keyword `search` for `"A" OR "B" OR …`) and asks for independent calls in the same turn; `search` says keyword mode takes OR across quoted names. In the development rounds the reader that wrote keyword OR searches solved as many cells in a third of the calls of one that searched one name at a time. |
| `entity` names | `names` (up to 50 names, codes or aliases) resolves a whole list in one call, one compact row per name with the page, its names, its opening lines (`lead`) and its identity siblings. Opus resolved account codes and nicknames from handoff mails one search at a time and ran out of turns; on the development world's account pages one call resolved the 43 names one such run looked up separately, in 1.4 s. |
| `entity` card | New `identity_siblings` (pages about the same subject under another title prefix, each with its own aliases, never merged), `identity_excerpt` (verbatim lines that may carry another name, with the page they came from), `aka_sources` and `alias_guidance` (what `aka` covers, which names to search). `aka` is unchanged. |
| Alias learning | Prose cues ("also known as", "goes by", "formerly", "doing business as", a quoted name after "calls it"), alias label lines and table rows ("Internal nickname: Copper Fox"), labels later in a line ("Account: Widget Co. Nickname used by the team: Copper Fox."), multi-word names, and 2-3 character codes the page declares for itself ("Also called JOF in my notes", `a.k.a.`, `known as`, `short for` or an alias label; common capitals and acronyms such as `IT`, `US`, `OK`, `AI` never count). The short-code rule comes from the Program Primary Hard root cause (gbrain-evals#109), where mails naming a customer only by its code never linked to it. A name two sibling pages share now links mentions to both instead of neither. |
diff --git a/docs/TOOL_CATALOG.md b/docs/TOOL_CATALOG.md
index 9903c3db3a..192f5b3e59 100644
--- a/docs/TOOL_CATALOG.md
+++ b/docs/TOOL_CATALOG.md
@@ -15,7 +15,7 @@ Every non-localOnly operation on the MCP surface: 140 tools across 23 areas. **S
| `get_status_snapshot` | Snapshot for `gbrain status` thin-client mode: sync freshness + last cycle + queue depths + worker liveness. | admin | | |
| `get_usage` | Aggregate chat usage + cost from the chat_usage_log ledger (per-model and per-phase token counts, cache reads/writes, USD estimates) with explicit coverage fields. | admin | | |
| `get_write_attribution` | Admin read: who created and who last changed a page, or one of its facts, takes or timeline entries. | admin | | |
-| `mute_notice` | Stop a coaching or info notice (or first_run_decisions) from appearing for this client; muted: false unmutes. | write | yes | |
+| `mute_notice` | Mute a coaching or info notice (or first_run_decisions) for this client; muted: false unmutes. | write | yes | |
| `quarantine_list` | List quarantined (hidden) and optionally content-flagged pages by scanning page frontmatter, newest-updated first. | admin | | |
| `run_doctor` | Run brain health checks and return a structured DoctorReport (thin-client doctor surface). | admin | | |
| `run_onboard` | Probe brain health + optionally submit onboard remediations. | admin | | |
@@ -52,7 +52,7 @@ Every non-localOnly operation on the MCP surface: 140 tools across 23 areas. **S
| Tool | Description | Scope | Starter | Gate |
|---|---|---|---|---|
-| `request_tools` | More tools: no arguments lists your catalog; {tools: [names]} returns schemas; {surface} widens it (per OAuth client; stdio: this session). | read | yes | |
+| `request_tools` | More tools: no arguments lists your catalog; {tools: [names]} returns schemas; {surface} widens it (per OAuth client or stdio session). | read | yes | |
## entities
@@ -161,7 +161,7 @@ Every non-localOnly operation on the MCP surface: 140 tools across 23 areas. **S
| Tool | Description | Scope | Starter | Gate |
|---|---|---|---|---|
| `cancel_write_request` | Cancel your accepted write before it publishes. | write | yes | |
-| `capture` | Quick note ("just remember this"): auto-slugged under inbox/ by date + content hash, so recapturing is idempotent. | write | yes | |
+| `capture` | Quick note ("just remember this"): slugged under inbox/ by date + content hash, so recapturing is idempotent. | write | yes | |
| `delete_page` | Soft-delete a page and remove its markdown file from the source working tree (the source local_path, or sync.repo_path when the source has none). | write | | |
| `edit_page` | Change part of a page: prefer this over put_page for small changes. | write | yes | |
| `fetch` | Fetch the full text of one search result by its opaque, source-qualified `id` (OpenAI deep-research contract: the search/fetch pair). | read | | |
@@ -199,7 +199,7 @@ Every non-localOnly operation on the MCP surface: 140 tools across 23 areas. **S
|---|---|---|---|---|
| `assemble_evidence` | Deliver whole evidence for an ordered list of search hits (each {source_id, slug, chunk_id} from a prior search/query result): the same windows, sections or pages `query` returns with return_unit, packed into token_budget. | read | | |
| `cache_stats` | Semantic query-cache introspection: resolved knobs (enabled, similarity threshold, TTL) plus row counts and total hits. | admin | | |
-| `query` | Hybrid search plus multi-query expansion for concept or landscape questions (expansion recovers synonym-phrased matches). | read | yes | |
+| `query` | Hybrid search plus multi-query expansion for concept or landscape questions (expansion recovers synonyms). | read | yes | |
| `rate_answer` | Rate how useful an answer's retrieved evidence was, so this brain ranks better next time (zero LLM calls). | write | | |
| `search` | Cheap hybrid search, no LLM expansion, top 20: exact tokens, names, field values. | read | yes | |
| `search_by_image` | Image-as-query retrieval. | read | | |
diff --git a/src/core/behavior-change-notice.ts b/src/core/behavior-change-notice.ts
index 05d125777d..7411b175b9 100644
--- a/src/core/behavior-change-notice.ts
+++ b/src/core/behavior-change-notice.ts
@@ -358,6 +358,7 @@ export const BEHAVIOR_CHANGES: ReadonlyArray<{ since: string; text: ChangeText }
{ since: '0.60.116.0', text: '`remember` with an entity, when the same claim is an active fact saved without one, now supersedes that copy (`status: superseded`, `superseded_fact_id`; batch receipts carry it too) instead of saving a duplicate. `forget` of a fact saved without an entity is refused with `invalid_params` and the prefix `claim_linked` while the same claim is active on entity-linked facts, which it used to withdraw as well.' },
{ since: '0.60.116.0', text: 'An entity page can now give itself a 2 or 3 character code ("Also called JOF in my notes", "Joffrey Foods, a.k.a. JOF", "Account code: JOF"): it becomes one of the entity\'s names and pages that write it exactly as written link to the entity. Lower-case words, common capitals and acronyms (`IT`, `US`, `OK`, `AI`, `CEO`, `API` ...) and codes declared in another entity\'s sentence never qualify. Every brain re-derives aliases and rescans mentions once.' },
{ since: '0.60.116.0', text: '`entity` accepts `names` (up to 50 names, codes or aliases) instead of `name` and returns one compact row per name: the page, its names, the opening lines of its body (`lead`) and its identity siblings, without references or facts. `name` is no longer a required parameter in the tool schema; passing neither, or both, is `invalid_params`.' },
+ { since: '0.60.116.0', text: 'The served instructions now say to keep separate parts of a question in separate searches but batch lists: resolve many names or codes in one call (`entity` with `names`, or one keyword `search` for "A" OR "B"), and issue independent calls together in one turn. The `search` description says keyword mode takes OR across quoted names or codes.' },
];
/** The newest disclosed change's release: the notice id moves only when a release adds rows. */
diff --git a/src/core/operations-descriptions.ts b/src/core/operations-descriptions.ts
index d421c7107f..cd219cae5c 100644
--- a/src/core/operations-descriptions.ts
+++ b/src/core/operations-descriptions.ts
@@ -46,13 +46,13 @@ export const GET_RECENT_TRANSCRIPTS_DESCRIPTION =
// ──────────────────────────────────────────────────────────────────────────────
export const LIST_PAGES_DESCRIPTION =
- "List pages with filters. For 'what's recent / what did I touch this week' use sort=updated_desc. Default 50 rows (remote max 100); a full page may be truncated: continue with updated_after + updated_after_slug from the last row.";
+ "List pages with filters. For 'what's recent / what did I touch this week' use sort=updated_desc. Default 50 rows; a full page may be truncated: continue with updated_after + updated_after_slug from the last row.";
export const QUERY_DESCRIPTION =
- "Hybrid search plus multi-query expansion for concept or landscape questions (expansion recovers synonym-phrased matches). Still top-K; return_unit returns whole sections or conversations. Lists: list_pages. Exact tokens: `search` is cheaper (no expansion LLM call). Personal: get_recent_salience, find_anomalies; transcripts: `gbrain transcripts recent` on the host. Do NOT assume 'crazy' means impressive (often difficult or emotionally charged). Needs an embedding key (else keyword-only); expansion needs a chat key. fields: \"full\" adds diagnostics.";
+ "Hybrid search plus multi-query expansion for concept or landscape questions (expansion recovers synonyms). Still top-K; return_unit: whole sections or conversations. Lists: list_pages. Exact tokens: `search` is cheaper (no LLM call). Personal: get_recent_salience, find_anomalies; transcripts: host `gbrain transcripts recent`. Do NOT assume 'crazy' means impressive (often difficult or emotionally charged). Needs an embedding key (else keyword-only); expansion needs a chat key. fields: \"full\" adds diagnostics.";
export const SEARCH_DESCRIPTION =
- "Cheap hybrid search, no LLM expansion, top 20: exact tokens, names, field values. NOT proof of coverage; match: \"keyword\" pages every keyword match. Concepts or landscape: `query`; lists: list_pages; personal: get_recent_salience. return_unit: sections or conversations. fields: \"full\" adds diagnostics.";
+ "Cheap hybrid search, no LLM expansion, top 20: exact tokens, names, field values. NOT proof of coverage; match: \"keyword\" pages every keyword match and takes OR across quoted names or codes (\"A\" OR \"B\" OR …): one call lists every page matching any. Name lists: entity names. Concepts or landscape: `query`; lists: list_pages; personal: get_recent_salience. return_unit: sections or conversations. fields: \"full\" adds diagnostics.";
/** `search`'s `match` param (Cat 40 Hard F2). */
export const SEARCH_MATCH_DESCRIPTION = 'keyword: every keyword match, paged.';
@@ -203,4 +203,4 @@ export const SKILL_CLIENT_GUIDANCE = {
* test/operations-descriptions.test.ts.
*/
export const CAPTURE_DESCRIPTION =
- "Quick note (\"just remember this\"): auto-slugged under inbox/ by date + content hash, so recapturing is idempotent. Use put_page to control slug or type; remember for facts about entities.";
+ "Quick note (\"just remember this\"): slugged under inbox/ by date + content hash, so recapturing is idempotent. Use put_page to control slug or type; remember for facts about entities.";
diff --git a/src/core/ops/notices.ts b/src/core/ops/notices.ts
index d97d992b37..78223ae892 100644
--- a/src/core/ops/notices.ts
+++ b/src/core/ops/notices.ts
@@ -16,7 +16,7 @@ const mute_notice: Operation = {
mutating: true,
idempotent: true,
outputRedaction: 'no_stored_text',
- description: 'Stop a coaching or info notice (or first_run_decisions) from appearing for this client; muted: false unmutes.',
+ description: 'Mute a coaching or info notice (or first_run_decisions) for this client; muted: false unmutes.',
params: {
code: { type: 'string', required: true, description: 'Notice code, the word after `[gbrain notice` in the block.' },
muted: { type: 'boolean', description: 'false unmutes. Default true.' },
diff --git a/src/core/ops/request-tools.ts b/src/core/ops/request-tools.ts
index 7e64661b97..74d9f626c7 100644
--- a/src/core/ops/request-tools.ts
+++ b/src/core/ops/request-tools.ts
@@ -159,7 +159,7 @@ const request_tools: Operation = {
name: 'request_tools',
idempotent: false,
outputRedaction: 'no_stored_text',
- description: 'More tools: no arguments lists your catalog; {tools: [names]} returns schemas; {surface} widens it (per OAuth client; stdio: this session).',
+ description: 'More tools: no arguments lists your catalog; {tools: [names]} returns schemas; {surface} widens it (per OAuth client or stdio session).',
area: 'discovery',
// FOV-4: callable by read OR agent scope — discovery for every token class.
agentCallable: true,
diff --git a/src/core/ops/search.ts b/src/core/ops/search.ts
index feceb6d192..39d35a02ac 100644
--- a/src/core/ops/search.ts
+++ b/src/core/ops/search.ts
@@ -830,8 +830,8 @@ const query: Operation = {
source_id: { type: 'string', description: SOURCE_ID_PARAM_DESCRIPTION },
cross_modal: { type: 'string', enum: ['text', 'image', 'both', 'auto'], description: 'Default auto.' },
embedding_column: { type: 'string', description: 'Registered embedding column.' },
- adaptive_return: { type: 'boolean', description: 'true when one answer is wanted (fewer rows; never returns empty); omit for breadth.' },
- autocut: { type: 'boolean', description: 'Default on (never returns empty); false gives full top-K for breadth, unlike adaptive_return.' },
+ adaptive_return: { type: 'boolean', description: 'true for one answer (fewer rows, never empty); omit for breadth.' },
+ autocut: { type: 'boolean', description: 'Default on (never empty); false: full top-K for breadth.' },
relational: { type: 'boolean', description: 'Relationship-graph arm (default on).' },
...EXPLAIN_PARAMS,
},
diff --git a/src/mcp/instructions.ts b/src/mcp/instructions.ts
index 886c47430d..d14a5bcf5f 100644
--- a/src/mcp/instructions.ts
+++ b/src/mcp/instructions.ts
@@ -69,8 +69,11 @@ function contractClauses(c: CallablePredicate, writeback?: AmbientWritebackOpts
const brief = c('entity') ? `For a brief on an account, person or company, call \`entity\`, then walk \`referenced_by\`${c('get_backlinks') ? ' or `get_backlinks`' : ''} by type.` : null;
if (brief && !any('search', 'query')) out.push(brief);
if (any('search', 'query')) {
- // Cat 40 (#5932): measured answer-completeness guidance; keep its wording.
- out.push(`Answering from the brain: a search returns the best-ranked excerpts, not every relevant page, so keep going until the evidence is complete. Run separate searches for separate parts of a question. ${brief ?? 'People and companies appear under several names (abbreviations, codes, nicknames); when a page lists another name, search for that too.'} For what is true now, prefer the newest governing source: a later correction, handoff or executed change outranks an older record, and drafts, proposals and agent-written notes do not override records.`);
+ // Cat 40 (#5932): measured answer-completeness guidance. Cat 40 Hard round 4: separate parts stay separate,
+ // but lists of names are batched and independent calls go out together (one call per name ran readers out of turns).
+ const batchVia = [c('entity') ? '`entity` with `names`' : null, c('search') ? 'one keyword `search` for "A" OR "B" OR …' : null].filter(Boolean);
+ const batch = `Keep separate parts of a question in separate searches, but batch lists: resolve many names or codes in one call${batchVia.length ? ` (${batchVia.join(' or ')})` : ''}, and issue independent calls together in one turn, not one per turn.`;
+ out.push(`Answering from the brain: a search returns the best-ranked excerpts, not every relevant page, so keep going until the evidence is complete. ${batch} ${brief ?? 'People and companies appear under several names (abbreviations, codes, nicknames); when a page lists another name, search for that too.'} For what is true now, prefer the newest governing source: a later correction, handoff or executed change outranks an older record, and drafts, proposals and agent-written notes do not override records.`);
}
if (c('list_skills') && c('get_skill')) {
out.push(`When the task calls for a procedure or workflow, discover available skills with list_skills using schema_version:2 when supported. Match descriptions and frontmatter triggers to the task, then read the matching skill in full with get_skill using its qualified_id, revision and schema_version:2.${c('get_skill_asset') ? ' Load approved dependencies from that exact revision with get_skill_asset.' : ''} If an older server explicitly rejects version 2, use its documented legacy discovery; an unavailable catalog is not empty.`);
diff --git a/test/fixtures/goldens/cli/help-and-errors.json b/test/fixtures/goldens/cli/help-and-errors.json
index 7fb4031952..b59c7b6bcd 100644
--- a/test/fixtures/goldens/cli/help-and-errors.json
+++ b/test/fixtures/goldens/cli/help-and-errors.json
@@ -679,7 +679,7 @@
"stdout": [
"Usage: gbrain query <query> [options]",
"",
- "Hybrid search plus multi-query expansion for concept or landscape questions (expansion recovers synonym-phrased matches). Still top-K; return_unit returns whole sections or conversations. Lists: list_pages. Exact tokens: `search` is cheaper (no expansion LLM call). Personal: get_recent_salience, find_anomalies; transcripts: `gbrain transcripts recent` on the host. Do NOT assume 'crazy' means impressive (often difficult or emotionally charged). Needs an embedding key (else keyword-only); expansion needs a chat key. fields: \"full\" adds diagnostics.",
+ "Hybrid search plus multi-query expansion for concept or landscape questions (expansion recovers synonyms). Still top-K; return_unit: whole sections or conversations. Lists: list_pages. Exact tokens: `search` is cheaper (no LLM call). Personal: get_recent_salience, find_anomalies; transcripts: host `gbrain transcripts recent`. Do NOT assume 'crazy' means impressive (often difficult or emotionally charged). Needs an embedding key (else keyword-only); expansion needs a chat key. fields: \"full\" adds diagnostics.",
"",
"Options:",
" <query> Question or topic (required unless image).",
@@ -707,8 +707,8 @@
" --source-id One source, or '__all__'.",
" --cross-modal Default auto.",
" --embedding-column Registered embedding column.",
- " --adaptive-return true when one answer is wanted (fewer rows; never returns empty); omit for breadth.",
- " --autocut Default on (never returns empty); false gives full top-K for breadth, unlike adaptive_return.",
+ " --adaptive-return true for one answer (fewer rows, never empty); omit for breadth.",
+ " --autocut Default on (never empty); false: full top-K for breadth.",
" --relational Relationship-graph arm (default on).",
" --explain Per-row score_details.",
" --explain-target Expected page (slug or source:slug): why it is missing."
diff --git a/test/fixtures/goldens/cli/tools-json.json b/test/fixtures/goldens/cli/tools-json.json
index 9445eb0e6b..b02b9c4cd9 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": 210193,
- "stdoutSha256": "6543b5b532af34a3afd496641a444850b0364e78403a9483170a2a5ef2a4609b",
+ "stdoutBytes": 210189,
+ "stdoutSha256": "0818902795a0fd2468b0ebb50ab21ad91a2f64a548e3e3704b5a955fee7a4575",
"toolNames": [
"remember",
"entity",
@@ -561,7 +561,7 @@
"scope": "write"
},
{
- "description": "List pages with filters. For 'what's recent / what did I touch this week' use sort=updated_desc. Default 50 rows (remote max 100); a full page may be truncated: continue with updated_after + updated_after_slug from the last row.",
+ "description": "List pages with filters. For 'what's recent / what did I touch this week' use sort=updated_desc. Default 50 rows; a full page may be truncated: continue with updated_after + updated_after_slug from the last row.",
"idempotent": true,
"local_only": false,
"mutating": false,
@@ -700,7 +700,7 @@
"scope": "admin"
},
{
- "description": "Quick note (\"just remember this\"): auto-slugged under inbox/ by date + content hash, so recapturing is idempotent. Use put_page to control slug or type; remember for facts about entities.",
+ "description": "Quick note (\"just remember this\"): slugged under inbox/ by date + content hash, so recapturing is idempotent. Use put_page to control slug or type; remember for facts about entities.",
"idempotent": true,
"local_only": false,
"mutating": true,
@@ -1027,7 +1027,7 @@
"scope": "write"
},
{
- "description": "Cheap hybrid search, no LLM expansion, top 20: exact tokens, names, field values. NOT proof of coverage; match: \"keyword\" pages every keyword match. Concepts or landscape: `query`; lists: list_pages; personal: get_recent_salience. return_unit: sections or conversations. fields: \"full\" adds diagnostics.",
+ "description": "Cheap hybrid search, no LLM expansion, top 20: exact tokens, names, field values. NOT proof of coverage; match: \"keyword\" pages every keyword match and takes OR across quoted names or codes (\"A\" OR \"B\" OR …): one call lists every page matching any. Name lists: entity names. Concepts or landscape: `query`; lists: list_pages; personal: get_recent_salience. return_unit: sections or conversations. fields: \"full\" adds diagnostics.",
"idempotent": true,
"local_only": false,
"mutating": false,
@@ -1149,7 +1149,7 @@
"scope": "read"
},
{
- "description": "Hybrid search plus multi-query expansion for concept or landscape questions (expansion recovers synonym-phrased matches). Still top-K; return_unit returns whole sections or conversations. Lists: list_pages. Exact tokens: `search` is cheaper (no expansion LLM call). Personal: get_recent_salience, find_anomalies; transcripts: `gbrain transcripts recent` on the host. Do NOT assume 'crazy' means impressive (often difficult or emotionally charged). Needs an embedding key (else keyword-only); expansion needs a chat key. fields: \"full\" adds diagnostics.",
+ "description": "Hybrid search plus multi-query expansion for concept or landscape questions (expansion recovers synonyms). Still top-K; return_unit: whole sections or conversations. Lists: list_pages. Exact tokens: `search` is cheaper (no LLM call). Personal: get_recent_salience, find_anomalies; transcripts: host `gbrain transcripts recent`. Do NOT assume 'crazy' means impressive (often difficult or emotionally charged). Needs an embedding key (else keyword-only); expansion needs a chat key. fields: \"full\" adds diagnostics.",
"idempotent": true,
"local_only": false,
"mutating": false,
@@ -1190,11 +1190,11 @@
"schema": {
"properties": {
"adaptive_return": {
- "description": "true when one answer is wanted (fewer rows; never returns empty); omit for breadth.",
+ "description": "true for one answer (fewer rows, never empty); omit for breadth.",
"type": "boolean"
},
"autocut": {
- "description": "Default on (never returns empty); false gives full top-K for breadth, unlike adaptive_return.",
+ "description": "Default on (never empty); false: full top-K for breadth.",
"type": "boolean"
},
"cross_modal": {
@@ -4595,7 +4595,7 @@
"scope": "read"
},
{
- "description": "More tools: no arguments lists your catalog; {tools: [names]} returns schemas; {surface} widens it (per OAuth client; stdio: this session).",
+ "description": "More tools: no arguments lists your catalog; {tools: [names]} returns schemas; {surface} widens it (per OAuth client or stdio session).",
"idempotent": false,
"local_only": false,
"mutating": true,
@@ -6664,7 +6664,7 @@
"scope": "write"
},
{
- "description": "Stop a coaching or info notice (or first_run_decisions) from appearing for this client; muted: false unmutes.",
+ "description": "Mute a coaching or info notice (or first_run_decisions) for this client; muted: false unmutes.",
"idempotent": true,
"local_only": false,
"mutating": true,
diff --git a/test/mcp-instructions-batching.test.ts b/test/mcp-instructions-batching.test.ts
new file mode 100644
index 0000000000..8f4b876504
--- /dev/null
+++ b/test/mcp-instructions-batching.test.ts
@@ -0,0 +1,41 @@
+/**
+ * Batching guidance (Cat 40 Hard round 4): the answering clause keeps separate
+ * parts of a question in separate searches but tells agents to resolve a list
+ * of names or codes in one call and to issue independent calls together, and
+ * `search` says keyword mode takes OR across quoted names.
+ *
+ * Protects: readers resolved 13-45 names one search per turn and ran out of
+ * turns; the old clause said "Run separate searches for separate parts of a
+ * question" and nothing mentioned keyword OR or `entity` names.
+ */
+import { describe, expect, test } from 'bun:test';
+import { buildMcpInstructions, GBRAIN_MCP_INSTRUCTIONS } from '../src/mcp/instructions.ts';
+import { SEARCH_DESCRIPTION } from '../src/core/operations-descriptions.ts';
+
+const answering = (text: string) => text.split('\n').find(l => l.includes('Answering from the brain')) ?? '';
+const only = (...names: string[]) => ({ tools: { callable: (op: string) => names.includes(op) } });
+
+describe('batching guidance', () => {
+ test('the default contract batches lists through entity names or one keyword OR search and keeps going', () => {
+ const clause = answering(GBRAIN_MCP_INSTRUCTIONS);
+ expect(clause).toContain('keep going until the evidence is complete');
+ expect(clause).toContain('Keep separate parts of a question in separate searches, but batch lists');
+ expect(clause).toContain('(`entity` with `names` or one keyword `search` for "A" OR "B" OR …)');
+ expect(clause).toContain('issue independent calls together in one turn, not one per turn');
+ expect(clause).not.toContain('Run separate searches');
+ });
+
+ test('only callable tools are named', () => {
+ expect(answering(buildMcpInstructions(only('search')))).toContain('in one call (one keyword `search` for "A" OR "B" OR …)');
+ expect(answering(buildMcpInstructions(only('search')))).not.toContain('`entity` with `names`');
+ expect(answering(buildMcpInstructions(only('query', 'entity')))).toContain('in one call (`entity` with `names`)');
+ const neither = answering(buildMcpInstructions(only('query')));
+ expect(neither).toContain('resolve many names or codes in one call, and issue independent calls together');
+ });
+
+ test('search says keyword mode takes OR across quoted names and points to entity names', () => {
+ expect(SEARCH_DESCRIPTION).toContain('match: "keyword" pages every keyword match and takes OR across quoted names or codes ("A" OR "B" OR …)');
+ expect(SEARCH_DESCRIPTION).toContain('one call lists every page matching any');
+ expect(SEARCH_DESCRIPTION).toContain("Name lists: entity names.");
+ });
+});
diff --git a/test/mcp-schema-budget.test.ts b/test/mcp-schema-budget.test.ts
index d5ddeda2b7..fe9c439b9d 100644
--- a/test/mcp-schema-budget.test.ts
+++ b/test/mcp-schema-budget.test.ts
@@ -53,7 +53,7 @@ const SERVED_STARTER_MAX_TOKENS = 5_700;
/** 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). */
const SERVED_STARTER_MAX_JSON_CHARS = 26_700;
/** 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 = 4_868; // #6007: +240 for the issue-required write guidance (put_pages, wait_ms)
+const INSTRUCTIONS_MAX_CHARS = 4_975; // #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
const DESCRIPTION_HARD_CAP = 1_200;
const PARAM_DESCRIPTION_HARD_CAP = 200;
@@ -62,6 +62,8 @@ const PARAM_DESCRIPTION_HARD_CAP = 200;
* remember 1330 -> 1370: the additive `items` batch param (save up to 20 facts
* before compaction), measured at 1,344 after its descriptions were shortened so the
* served starter list stays under 25,000 next to #6007's put_page growth.
+ * search 1670 -> 1800: keyword OR across quoted names and the pointer to entity names (Cat 40 Hard
+ * round 4), paid for by trimming query, list_pages, capture, mute_notice and request_tools text.
* entity 470 -> 550: the additive `names` param (resolve up to 50 names in one
* call, Cat 40 Hard round 4), measured at 546 with the `name` example and part
* of the miss sentence trimmed so the served starter list stays under 25,000.
@@ -72,7 +74,7 @@ const TOOL_BUDGETS: Record<string, number> = {
get_backlinks: 770, get_ingest_log: 280, get_page: 930, get_recent_salience: 660, get_skill: 910,
get_skill_asset: 790, get_write_request: 360, join_brain: 560, leave_brain: 540, list_brain_skillpack: 230,
list_link_sources: 220, list_pages: 1060, list_skills: 670, list_write_requests: 450, put_page: 1460,
- mute_notice: 460, put_skill: 1420, query: 3100, recall: 1540, remember: 1370, request_tools: 560, resolve_slugs: 410, search: 1670,
+ mute_notice: 460, put_skill: 1420, query: 3100, recall: 1540, remember: 1370, request_tools: 560, resolve_slugs: 410, search: 1800,
submit_agent: 750, sync_brain_skills: 770, synthesize: 550, traverse_graph: 810, whoami: 230,
};