Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix(graph): traverse_graph hops walk live relationships, matching the starter surface

garrytanef3b86c2becb
diff --git a/docs/guides/multi-hop.md b/docs/guides/multi-hop.md
index f4c54e9cc3..6ff5f50978 100644
--- a/docs/guides/multi-hop.md
+++ b/docs/guides/multi-hop.md
@@ -131,8 +131,8 @@ ended is skipped, while events such as founding and investing stay true after
they happen. A tense marker right before a relationship that can end sets
that hop alone: "the companies Alice formerly advised" walks ended advisory
roles, "used to work at" and "worked at" walk every job, "currently works at"
-walks live ones; the other hops keep the default. `traverse_graph` with `hops` takes `status` and `as_of` like a
-plain walk, and `graph.edge_validity off` turns the rule off.
+walks live ones; the other hops keep the default. `traverse_graph` with
+`hops` walks live relationships, and `graph.edge_validity off` turns the rule off.
## Direction and evidence
diff --git a/docs/mcp/TOOL_REFERENCE.md b/docs/mcp/TOOL_REFERENCE.md
index d6f0efeae1..5daddbbc69 100644
--- a/docs/mcp/TOOL_REFERENCE.md
+++ b/docs/mcp/TOOL_REFERENCE.md
@@ -422,7 +422,7 @@ Traverse link graph from a page. Remote callers default to bidirectional edges (
| `depth` | number | Max traversal depth (capped at 10). Default 5, except a remote call that lets direction default to 'both' uses 2 (bidirectional path enumeration is combinatorial on hubs); an explicit depth is always honored up to the cap. |
| `link_type` | string | Filter to one link type (per-edge filter, traversal only follows matching edges) |
| `direction` | string (`in`, `out`, `both`) | Traversal direction ('in', 'out', or 'both'). Remote callers default to 'both'; trusted local no-filter callers get the legacy outgoing-node output. |
-| `hops` | array of `{link_type, toward}` | Typed chain of 1-3 hops from the start page, e.g. `[{"link_type":"invested_in","toward":"object"},{"link_type":"founded","toward":"subject"}]` (companies the person invested in, then their founders). `toward` follows the relationship's meaning (`object`: subject → object; `subject`: object → subject), not stored link direction. Returns `{anchor, answers, paths, diagnostics}` with each answer's evidence edges; a chain that finds nothing carries a `relational_chain` notice with the next call. Not combinable with `depth`, `link_type` or `direction`; `status` and `as_of` pick which relationships each hop walks (live by default). Chain link types: founded, invested_in, led_round, advises, works_at, attended, yc_partner. See docs/guides/multi-hop.md. |
+| `hops` | array of `{link_type, toward}` | Typed chain of 1-3 hops from the start page, e.g. `[{"link_type":"invested_in","toward":"object"},{"link_type":"founded","toward":"subject"}]` (companies the person invested in, then their founders). `toward` follows the relationship's meaning (`object`: subject → object; `subject`: object → subject), not stored link direction. Returns `{anchor, answers, paths, diagnostics}` with each answer's evidence edges; a chain that finds nothing carries a `relational_chain` notice with the next call. Not combinable with `depth`, `link_type` or `direction`; each hop walks live relationships. Chain link types: founded, invested_in, led_round, advises, works_at, attended, yc_partner. See docs/guides/multi-hop.md. |
| `source_id` | string | Scope the read to one source (a multi-source brain can hold the same slug in several sources). Omitted: your granted sources remotely (a connection with no grant reads every federated source); locally, the resolved source, or every federated source when no --source / GBRAIN_SOURCE / .gbrain-source pinned it. '__all__' spans every source for trusted local callers and only your readable sources for remote callers. |
| `all_sources` | boolean | Span sources (equivalent to source_id=__all__): every source locally, only your readable sources remotely. |
diff --git a/test/fixtures/goldens/cli/tools-json.json b/test/fixtures/goldens/cli/tools-json.json
index e5de88af93..f14056a793 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": 199254,
- "stdoutSha256": "61d83356099b57f1ad5d538d8a9bad4770eb427597f084fb42200b5cf754a0a6",
+ "stdoutBytes": 199096,
+ "stdoutSha256": "df226db4f7613a8e9c158b25db57bc595413bf3cfc5ccef5130111051f18b2d9",
"toolNames": [
"remember",
"entity",
@@ -1648,6 +1648,7 @@
"type": "boolean"
},
"as_of": {
+ "description": "YYYY-MM-DD",
"type": "string"
},
"slug": {
@@ -1659,6 +1660,7 @@
"type": "string"
},
"status": {
+ "description": "Default live.",
"enum": [
"live",
"all"
@@ -1696,14 +1698,12 @@
"name": "traverse_graph",
"parameters": {
"all_sources": "boolean?",
- "as_of": "string?",
"depth": "number?",
"direction": "string?",
"hops": "array?",
"link_type": "string?",
"slug": "string",
- "source_id": "string?",
- "status": "string?"
+ "source_id": "string?"
},
"required_scopes": [],
"schema": {
@@ -1712,9 +1712,6 @@
"description": "Same as source_id __all__.",
"type": "boolean"
},
- "as_of": {
- "type": "string"
- },
"depth": {
"description": "Max depth (cap 10).",
"type": "number"
@@ -1756,13 +1753,6 @@
"source_id": {
"description": "One source, or '__all__'.",
"type": "string"
- },
- "status": {
- "enum": [
- "live",
- "all"
- ],
- "type": "string"
}
},
"required": [
diff --git a/test/mcp-schema-budget.test.ts b/test/mcp-schema-budget.test.ts
index 770e81f864..30175682f6 100644
--- a/test/mcp-schema-budget.test.ts
+++ b/test/mcp-schema-budget.test.ts
@@ -40,8 +40,8 @@ import { cl100kAvailable, estimateTokens } from '../src/core/chunkers/token-esti
const SERVED_STARTER_MAX_CHARS = 25_000;
const SERVED_STARTER_MAX_TOKENS = 5_700;
-/** The whole tools/list JSON, annotations included (25,735 measured at v0.60.46.0; temporal status/as_of params under 26,000; +279 for traverse_graph's optional `hops` typed-chain parameter, 26,278 measured). */
-const SERVED_STARTER_MAX_JSON_CHARS = 26_300;
+/** The whole tools/list JSON, annotations included (25,735 measured at v0.60.46.0; +279 for traverse_graph's optional `hops` typed-chain parameter, 26,220 measured with the temporal params on get_links/get_backlinks). */
+const SERVED_STARTER_MAX_JSON_CHARS = 26_250;
/** 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_628;
const DESCRIPTION_HARD_CAP = 1_200;
@@ -55,7 +55,7 @@ const TOOL_BUDGETS: Record<string, number> = {
get_skill_asset: 790, get_write_request: 330, join_brain: 560, leave_brain: 540, list_brain_skillpack: 230,
list_link_sources: 220, list_pages: 1090, list_skills: 670, list_write_requests: 450, put_page: 1320,
put_skill: 1420, query: 3250, recall: 1590, remember: 1370, request_tools: 560, resolve_slugs: 410, search: 1760,
- submit_agent: 750, sync_brain_skills: 770, synthesize: 550, traverse_graph: 1090, whoami: 230,
+ submit_agent: 750, sync_brain_skills: 770, synthesize: 550, traverse_graph: 960, whoami: 230,
};
/** DX-14: phrases each tool's description must keep. */
diff --git a/test/traverse-graph-hops.test.ts b/test/traverse-graph-hops.test.ts
index b2565b4410..d2c953a496 100644
--- a/test/traverse-graph-hops.test.ts
+++ b/test/traverse-graph-hops.test.ts
@@ -113,7 +113,7 @@ describe('traverse_graph hops', () => {
});
describe('traverse_graph hops: relationship validity', () => {
- test('an ended state relationship is not walked by default; status "all" walks it', async () => {
+ test('an ended state relationship is not walked; a "formerly" question walks it', async () => {
await engine.putPage('people/carol-example', { type: 'person', title: 'carol', compiled_truth: 'carol', timeline: '' });
await engine.putPage('companies/old-example', { type: 'company', title: 'old', compiled_truth: 'old', timeline: '' });
await engine.addLink('companies/old-example', 'people/bob-example', 'founded by bob', 'founded', 'markdown');
@@ -124,10 +124,6 @@ describe('traverse_graph hops: relationship validity', () => {
const live = await runLocal({ slug: 'people/carol-example', hops });
expect(live.answers).toEqual([]);
expect(live.diagnostics.status).toBe('no_edges');
- const all = await runLocal({ slug: 'people/carol-example', hops, status: 'all' });
- expect(all.answers.map((a: { slug: string }) => a.slug)).toEqual(['people/bob-example']);
- const then = await runLocal({ slug: 'people/carol-example', hops, as_of: '2020-03-01' });
- expect(then.answers.map((a: { slug: string }) => a.slug)).toEqual(['people/bob-example']);
// The search arm: present tense walks live relationships, "formerly" walks the ended one.
for (const slug of ['people/bob-example', 'companies/old-example']) {