Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

test(agent-journey): keyless recall(query) carries the recall_hint and facts_order (W1 TC7 contract)

garrytanadf324a582fa
diff --git a/test/agent-journey.serial.test.ts b/test/agent-journey.serial.test.ts
index aeade6f4b4..768ebf5d65 100644
--- a/test/agent-journey.serial.test.ts
+++ b/test/agent-journey.serial.test.ts
@@ -252,11 +252,12 @@ describe('H1a keyless MCP journey (stdio)', () => {
expect(JSON.stringify(result)).toContain(MARKER);
expect(result.results.length).toBe(PAGES);
// The degraded notice is its own prefixed block (the model sees it) and mirrored in _meta.
+ // A recall that passes only `query` also carries the recall_hint (TC7) naming `question`.
const blocks = noticeBlocks(recalled);
- expect(blocks).toHaveLength(1);
- expect(blocks[0]!.split('\n')[0]).toBe('[gbrain notice degraded_recall kind=degraded]');
+ expect(blocks.map(b => b.split('\n')[0])).toEqual(['[gbrain notice degraded_recall kind=degraded]', '[gbrain notice recall_hint kind=info]']);
expect(blocks[0]).toContain('never as "the brain has nothing on this"');
- expect(recalled._meta?.gbrain_notices?.map((n: { code: string }) => n.code)).toEqual(['degraded_recall']);
+ expect(recalled._meta?.gbrain_notices?.map((n: { code: string }) => n.code)).toEqual(['degraded_recall', 'recall_hint']);
+ expect(result.facts_order).toBe('newest');
journeyGolden('recall-degraded.json', recalled, { home });
// Caller mistake: one block, an envelope with a fix the agent runs as given.
diff --git a/test/fixtures/agent-contract/v1/journey/recall-degraded.json b/test/fixtures/agent-contract/v1/journey/recall-degraded.json
index 7c16ceb483..91e4c8ab76 100644
--- a/test/fixtures/agent-contract/v1/journey/recall-degraded.json
+++ b/test/fixtures/agent-contract/v1/journey/recall-degraded.json
@@ -6,17 +6,53 @@
"kind": "degraded",
"why": "Recall was degraded (keyword_only_no_embedding_provider): semantic (vector) search did not run, so matches phrased differently from the query can be missing. Treat a thin or empty result as \"not found with a degraded search\", never as \"the brain has nothing on this\". This brain was set up keyword-only by the user's choice; mention it only if the user asks why something was not found. No query text was sent to an embedding provider. If the user wants semantic search, `gbrain doctor --json` names the enable command; turning it on needs their consent.",
"contract_version": 1
+ },
+ {
+ "code": "recall_hint",
+ "kind": "info",
+ "why": "The facts in this response are the newest saved facts: `query` searches pages and does not rank facts. `question` ranks saved facts by relevance to a question (it does not search pages).",
+ "fix": {
+ "argv": [
+ "gbrain",
+ "recall",
+ "--question",
+ "quokka-journey-marker",
+ "--query",
+ "quokka-journey-marker",
+ "--brain",
+ "host",
+ "--source",
+ "default"
+ ],
+ "command": "gbrain recall --question quokka-journey-marker --query quokka-journey-marker --brain host --source default",
+ "mcp": {
+ "tool": "recall",
+ "arguments": {
+ "query": "quokka-journey-marker",
+ "question": "quokka-journey-marker"
+ }
+ },
+ "consent": [],
+ "actor": "agent",
+ "why": "The same recall with question set to the query, so saved facts come back ranked by relevance and pages are still searched.",
+ "requires_exclusive": false
+ },
+ "contract_version": 1
}
]
},
"content": [
{
"type": "text",
- "text": "{\n \"facts\": [\n {\n \"id\": 1,\n \"fact\": \"quokka-journey-marker is the install-check fact\",\n \"kind\": \"fact\",\n \"entity_slug\": null,\n \"source_id\": \"default\",\n \"visibility\": \"world\",\n \"notability\": \"medium\",\n \"valid_from\": \"{{TIME}}\",\n \"valid_until\": null,\n \"expired_at\": null,\n \"superseded_by\": null,\n \"consolidated_at\": null,\n \"consolidated_into\": null,\n \"source\": \"install-check\",\n \"source_session\": null,\n \"context\": null,\n \"confidence\": 1,\n \"created_at\": \"{{TIME}}\",\n \"fact_id\": \"1\",\n \"provenance\": \"install-check\",\n \"trust_tier\": \"agent_written\",\n \"origin\": \"mcp:remember\"\n }\n ],\n \"total\": 1,\n \"protocol_version\": 1,\n \"results\": [\n {\n \"slug\": \"journey-note-3\",\n \"title\": \"Journey note 3\",\n \"chunk\": \"# Journey note 3\\n\\nThe quokka-journey-marker 3 lives in note 3.\",\n \"evidence\": \"keyword_exact\",\n \"create_safety\": \"probable\",\n \"provenance\": \"journey-note-3\",\n \"source_id\": \"default\",\n \"trust_tier\": \"operator_curated\",\n \"origin\": \"managed_file_import\"\n },\n {\n \"slug\": \"journey-note-2\",\n \"title\": \"Journey note 2\",\n \"chunk\": \"# Journey note 2\\n\\nThe quokka-journey-marker 2 lives in note 2.\",\n \"evidence\": \"keyword_exact\",\n \"create_safety\": \"probable\",\n \"provenance\": \"journey-note-2\",\n \"source_id\": \"default\",\n \"trust_tier\": \"operator_curated\",\n \"origin\": \"managed_file_import\"\n },\n {\n \"slug\": \"journey-note-1\",\n \"title\": \"Journey note 1\",\n \"chunk\": \"# Journey note 1\\n\\nThe quokka-journey-marker 1 lives in note 1.\",\n \"evidence\": \"keyword_exact\",\n \"create_safety\": \"probable\",\n \"provenance\": \"journey-note-1\",\n \"source_id\": \"default\",\n \"trust_tier\": \"operator_curated\",\n \"origin\": \"managed_file_import\"\n }\n ],\n \"search_degraded\": \"keyword_only_embedding_disabled\"\n}"
+ "text": "{\n \"facts\": [\n {\n \"id\": 1,\n \"fact\": \"quokka-journey-marker is the install-check fact\",\n \"kind\": \"fact\",\n \"entity_slug\": null,\n \"source_id\": \"default\",\n \"visibility\": \"world\",\n \"notability\": \"medium\",\n \"valid_from\": \"{{TIME}}\",\n \"valid_until\": null,\n \"expired_at\": null,\n \"superseded_by\": null,\n \"consolidated_at\": null,\n \"consolidated_into\": null,\n \"source\": \"install-check\",\n \"source_session\": null,\n \"context\": null,\n \"confidence\": 1,\n \"created_at\": \"{{TIME}}\",\n \"fact_id\": \"1\",\n \"provenance\": \"install-check\",\n \"trust_tier\": \"agent_written\",\n \"origin\": \"mcp:remember\"\n }\n ],\n \"total\": 1,\n \"facts_order\": \"newest\",\n \"protocol_version\": 1,\n \"results\": [\n {\n \"slug\": \"journey-note-3\",\n \"title\": \"Journey note 3\",\n \"chunk\": \"# Journey note 3\\n\\nThe quokka-journey-marker 3 lives in note 3.\",\n \"evidence\": \"keyword_exact\",\n \"create_safety\": \"probable\",\n \"provenance\": \"journey-note-3\",\n \"source_id\": \"default\",\n \"trust_tier\": \"operator_curated\",\n \"origin\": \"managed_file_import\"\n },\n {\n \"slug\": \"journey-note-2\",\n \"title\": \"Journey note 2\",\n \"chunk\": \"# Journey note 2\\n\\nThe quokka-journey-marker 2 lives in note 2.\",\n \"evidence\": \"keyword_exact\",\n \"create_safety\": \"probable\",\n \"provenance\": \"journey-note-2\",\n \"source_id\": \"default\",\n \"trust_tier\": \"operator_curated\",\n \"origin\": \"managed_file_import\"\n },\n {\n \"slug\": \"journey-note-1\",\n \"title\": \"Journey note 1\",\n \"chunk\": \"# Journey note 1\\n\\nThe quokka-journey-marker 1 lives in note 1.\",\n \"evidence\": \"keyword_exact\",\n \"create_safety\": \"probable\",\n \"provenance\": \"journey-note-1\",\n \"source_id\": \"default\",\n \"trust_tier\": \"operator_curated\",\n \"origin\": \"managed_file_import\"\n }\n ],\n \"search_degraded\": \"keyword_only_embedding_disabled\"\n}"
},
{
"type": "text",
"text": "[gbrain notice degraded_recall kind=degraded]\nwhy: Recall was degraded (keyword_only_no_embedding_provider): semantic (vector) search did not run, so matches phrased differently from the query can be missing. Treat a thin or empty result as \"not found with a degraded search\", never as \"the brain has nothing on this\". This brain was set up keyword-only by the user's choice; mention it only if the user asks why something was not found. No query text was sent to an embedding provider. If the user wants semantic search, `gbrain doctor --json` names the enable command; turning it on needs their consent."
+ },
+ {
+ "type": "text",
+ "text": "[gbrain notice recall_hint kind=info]\nwhy: The facts in this response are the newest saved facts: `query` searches pages and does not rank facts. `question` ranks saved facts by relevance to a question (it does not search pages).\nfix: recall {\"query\":\"quokka-journey-marker\",\"question\":\"quokka-journey-marker\"}\nnext: {{next}}"
}
]
}