Skip to main content
Hierarchical summaries build file → folder → project abstractions so agents route queries efficiently across large knowledge bases. The user asks a broad or specific question; routing picks the right summary level.

How It Works

Quick Start

1

Build a three-level hierarchy

2

Persist and reload


Overview

The HierarchicalSummarizer provides:
  • Multi-level summaries at file, folder, and project levels
  • Query routing to appropriate summary levels
  • Incremental updates when files change
  • Persistent storage of summary hierarchies

Building Hierarchies

From Directory

Summary Levels

Query Routing

Automatic Routing

Manual Level Selection

Persistence

Durable persistence

The hierarchy JSON written by build_hierarchy() is saved atomically as of PR #6111. A crash, OOM kill, or non-serialisable value during the save cannot truncate the previous hierarchy file — the last-known-good hierarchy survives, and the failure is logged at WARNING level (Failed to save hierarchy ...).
Before #6111, a failed write could leave a partial or empty hierarchy file with no log entry, so the next load had no routing data and no explanation.

CLI Usage

Integration with Agents

Best Practices

File, folder, and project summaries balance routing precision with build cost for typical documentation corpora.
Keep file summaries shorter than folder summaries, and folder summaries shorter than the project root — avoids bloated parent nodes.
Save to JSON after the initial build so startup skips re-summarising unchanged files.
Call update_file() or rebuild_folder() instead of rebuilding the entire tree when only part of the corpus changes.

Knowledge

Knowledge sources and retrieval

Smart Retrieval

Query routing and relevance strategies

Context Compression

Compress long contexts before LLM calls

RAG Overview

Retrieval-augmented generation patterns