Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
explain params on the full MCP surface only (fullSurfaceOnly), keeping the starter list inside its 25,000-character budget; guide examples use query
garrytan3a1e3f11b08a
diff --git a/docs/guides/search-explain.md b/docs/guides/search-explain.mdindex 2a13e836de..71660d1936 100644--- a/docs/guides/search-explain.md+++ b/docs/guides/search-explain.md@@ -1,6 +1,6 @@# Explaining search results-`search` and `query` explain their own ranking. With `explain: true` every+`query` (and the CLI `gbrain search`) explain their own ranking. With `explain: true` everyreturned row carries `score_details`: which retrieval arms found it and atwhat rank, how fusion scored it, and every boost or demotion applied afterfusion. With `explain_target` the response says what happened to a page you@@ -16,7 +16,7 @@ expected but did not get, and what to do next.MCP:```json-{ "tool": "search", "arguments": { "query": "acme-example renewal terms", "explain": true } }+{ "tool": "query", "arguments": { "query": "acme-example renewal terms", "expand": false, "explain": true } }```CLI:@@ -46,7 +46,7 @@ reason, never as an invented value.MCP:```json-{ "tool": "search", "arguments": { "query": "acme-example renewal terms", "explain_target": "meetings/2026-03-02-acme-example" } }+{ "tool": "query", "arguments": { "query": "acme-example renewal terms", "expand": false, "explain_target": "meetings/2026-03-02-acme-example" } }```The response meta `explain_target` holds the diagnosis, and a notice carries@@ -67,9 +67,12 @@ the next step:| `target_ambiguous` | The slug exists in several sources. | Repeat with `explain_target` as `source:slug`. || `target_not_found_or_not_visible` | No page with that slug is readable here. | Ask the user whether it exists and where; private pages are never confirmed. |-Agents on the default seven-verb memory surface do not have `search` or-`query`; ask the brain host to run `gbrain search "<question>" --explain --json`,-or enable the full tool surface.+Both params are declared on `query` on the full MCP tool surface; the cheap+`search` tool and the starter list stay lean because every declared param is+re-sent to the model on each turn. A starter-surface session calls+`request_tools {"surface": "full"}` first. Agents on the default seven-verb+memory surface do not have `query`; ask the brain host to run+`gbrain search "<question>" --explain --json`, or enable the full tool surface.## Hub dampeningdiff --git a/src/core/ops/search.ts b/src/core/ops/search.tsindex 11c9148827..5c901163f7 100644--- a/src/core/ops/search.ts+++ b/src/core/ops/search.ts@@ -506,13 +506,15 @@ const SOURCE_ID_PARAM_DESCRIPTION = "One source, or '__all__'.";const SALIENCE_PARAM = { type: 'string' as const, enum: ['off', 'on', 'strong'], description: 'Boost emotional pages (default: auto).' };/**- * Ranking explanation params, declared on `query` only: every declared param- * is re-sent to the model on each turn, so the cheap `search` tool stays- * lean. The local CLI passes them to `search` too (`gbrain search --explain`).+ * Ranking explanation params, declared on `query` only and advertised on the+ * full MCP surface only: every declared param is re-sent to the model on each+ * turn, so the cheap `search` tool and the starter list stay lean (a starter+ * session reaches them with `request_tools {surface: 'full'}`). The local CLI+ * passes them to `search` too (`gbrain search --explain`).*/const EXPLAIN_PARAMS = {- explain: { type: 'boolean' as const, description: 'Per-row score_details.' },- explain_target: { type: 'string' as const, description: 'Expected page (slug or source:slug): why it is missing.' },+ explain: { type: 'boolean' as const, description: 'Per-row score_details.', fullSurfaceOnly: true },+ explain_target: { type: 'string' as const, description: 'Expected page (slug or source:slug): why it is missing.', fullSurfaceOnly: true },};/** `explain_target` is `slug` or `source_id:slug` (slugs never contain ':'). */diff --git a/test/mcp-schema-budget.test.ts b/test/mcp-schema-budget.test.tsindex e8c4924cd0..f769567eb8 100644--- a/test/mcp-schema-budget.test.ts+++ b/test/mcp-schema-budget.test.ts@@ -38,8 +38,6 @@* disclosure), get_write_request (poll cadence and final states),* add_timeline_entry (when no call is needed) and the instructions (write* guidance); the served list still fits 25,000 model-visible characters.- * query +175 (P2): the `explain` and `explain_target` params (score_details- * and missing-page diagnosis), declared on query only so search stays lean.*/import { afterAll, beforeAll, describe, expect, test } from 'bun:test';import { PGLiteEngine } from '../src/core/pglite-engine.ts';@@ -66,7 +64,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: 3280, recall: 1540, remember: 1330, request_tools: 560, resolve_slugs: 410, search: 1670,+ mute_notice: 460, put_skill: 1420, query: 3100, recall: 1540, remember: 1330, request_tools: 560, resolve_slugs: 410, search: 1670,submit_agent: 750, sync_brain_skills: 770, synthesize: 550, traverse_graph: 810, whoami: 230,};