AI Skill Report Card

Building RTM Narrative Memory Systems

A-83·Oct 19, 2026·Source: Extension-page
14 / 15

Encode a narrative into a hierarchical tree and inspect it at multiple abstraction levels:

TypeScript
// 1. Build the tree (K = branching factor, D = max recall depth) const tree = await tools.call('rtm_create_narrative_tree', { text: narrativeText, title: "The Lost Kingdom", type: "story", maxBranchingFactor: 4, // working-memory chunk size maxRecallDepth: 6 }); // 2. Get a high-level (abstract) summary const abstract = await tools.call('rtm_traverse_narrative', { text: narrativeText, title: "The Lost Kingdom", traversalDepth: 1 }); // 3. Get a detailed summary const detailed = await tools.call('rtm_traverse_narrative', { text: narrativeText, title: "The Lost Kingdom", traversalDepth: 4 }); // 4. Model population-level recall variance const ensemble = await tools.call('rtm_generate_ensemble', { text: narrativeText, title: "The Lost Kingdom", ensembleSize: 200 });
Recommendation▾
Add a 'bad output' example (e.g., degenerate single-node tree from empty text) to contrast with good outcomes, since all three examples currently show success cases only
14 / 15

Use this checklist when implementing or extending an RTM system (new tool, new corpus, or new deployment):

Progress:
- [ ] 1: Parse narrative into atomic clauses/units (segmentation layer)
- [ ] 2: Choose K (branching factor) and D (max depth) based on text length and desired compression
- [ ] 3: Recursively partition clauses into a tree (rtm-builder) — each node summarizes its children
- [ ] 4: Validate tree statistics (node count, depth, branching distribution) against expected scaling laws
- [ ] 5: Expose traversal at arbitrary depth (rtm-traversal) to retrieve summaries at any abstraction level
- [ ] 6: If modeling human variance, generate an ensemble of trees with randomized partition points (rtm-ensemble)
- [ ] 7: Compute compression ratio = (#leaf clauses) / (#nodes at depth d) for each level
- [ ] 8: If target recall length is given, binary-search traversal depth to match it (findOptimalDepth)
- [ ] 9: Wrap each capability as an MCP tool with strict input validation and typed JSON output

Core algorithm notes

  • Tree construction (rtm-builder): Recursively split the clause sequence into ≤K contiguous chunks; each chunk becomes a child subtree. Stop recursion at D levels or when a chunk is a single clause. Each internal node stores a generated/extracted summary of its subtree's text span.
  • Traversal (rtm-traversal): To recall at depth d, walk the tree and collect node summaries at level d (or leaves, whichever is shallower) — this is the "clause recall sequence." Concatenating these summaries in order reconstructs a depth-appropriate retelling.
  • Ensemble (rtm-ensemble): Fix the text but randomize partition boundaries (within K/D constraints) across N tree instances. Aggregate statistics (mean/variance of node count, compression ratio, recall-sequence length) approximate population-level recall differences.
  • Optimal depth search (findOptimalDepth): Since recall length grows roughly geometrically with depth (~K^d leaves per level), use the relation depth ≈ log_K(targetRecallLength / rootBranches) as a starting estimate, then refine by direct traversal-length comparison at adjacent depths.
  • Scale invariance: For long narratives, compression ratio between adjacent depths should stabilize (approach a constant), reflecting the K-ary branching; deviations signal uneven clause density and may require re-segmentation.
Recommendation▾
Clarify what 'summary' generation mechanism nodes actually use (extractive vs abstractive, or delegated to an LLM) — this is left implicit and is a key implementation detail
16 / 20

Example 1: Creating a tree Input:

JSON
{"text": "Once upon a time... [500-word story]", "title": "The Lost Kingdom", "type": "story", "maxBranchingFactor": 4, "maxRecallDepth": 6}

Output:

JSON
{ "treeId": "rtm_a1b2c3", "stats": {"totalNodes": 85, "leafCount": 64, "depth": 6, "avgBranching": 3.8}, "compressionRatio": {"depth1": 0.015, "depth3": 0.12, "depth6": 1.0} }

Example 2: Depth-controlled traversal Input: traversalDepth: 1 on the above tree Output:

JSON
{ "summaries": ["A wise king protects his kingdom from a growing threat."], "recallSequence": ["A wise king protects his kingdom from a growing threat."], "compressionRatio": 0.015 }

Example 3: Optimal depth search Input: targetRecallLength: 50 clauses Output:

JSON
{"optimalDepth": 4, "actualRecallLength": 48, "accuracy": 0.96}
Recommendation▾
Consider trimming the 'Core algorithm notes' prose slightly — some reasoning (e.g., scale invariance paragraph) could be tightened given Claude's existing familiarity with tree/recursion concepts
  • Default K=4, D=6 reflect empirical working-memory capacity (Miller's ~4±1 chunk limit); only override with justification (e.g., very short or very long texts).
  • Segment text into clauses (not sentences) before building — clauses are the atomic unit RTM theory assumes.
  • Always report compression ratio alongside summaries so callers understand information loss at each depth.
  • For population modeling, prefer ensembleSize ≥ 100 to get stable variance estimates; report mean ± std, not just the mean.
  • Cache tree builds keyed by (text hash, K, D) — traversal and depth-search tools should reuse an existing tree rather than rebuilding.
  • Validate traversalDepth against the tree's actual max depth and clamp/report rather than silently failing.
  • Don't conflate sentence count with clause count when computing branching factor — inflates apparent compression.
  • Don't use a single tree instance to claim "the" human recall pattern — always use an ensemble for variance claims.
  • Don't allow unbounded K or D from user input without caps — pathological values cause combinatorial blowup in tree size.
  • Don't skip input validation on text/title (empty or whitespace-only text should error clearly, not produce a degenerate single-node tree).
  • Don't assume linear relationship between depth and recall length — it's approximately geometric (K^d); use log-scale search for findOptimalDepth, not linear scanning, for long narratives.
0
Grade A-AI Skill Framework
Scorecard
Criteria Breakdown
Quick Start
14/15
Workflow
14/15
Examples
16/20
Completeness
17/20
Format
14/15
Conciseness
13/15