Normalized for Mintlify from
knowledge-base/neurigraph-memory-architecture/neurigraph-tool-references/06-Hierarchical-Agentic-Memory-Auto-Taxonomy.mdx.Clean-Room Specification: Hierarchical Agentic Memory with LLM-Driven Auto-Taxonomy
Purpose of This Document
This document specifies the complete architecture of a hierarchical memory system that uses LLM agents to automatically organize, chunk, and retrieve information. Instead of fixed schemas or vector databases, the system uses LLM reasoning to: (1) chunk documents intelligently, (2) generate structured memory summaries, (3) create and maintain a hierarchical taxonomy as a directory tree, and (4) navigate that tree at query time using tool-based exploration. All memories are stored as Markdown files in a filesystem hierarchy, with README files at each level describing the contents. This specification is detailed enough that a professional AI coding model can produce a functionally identical working system without reference to any existing codebase.1. System Overview
1.1 Core Concept
Traditional memory systems use embedding-based retrieval. This system instead leverages LLM reasoning for both storage and retrieval:- Storage: An LLM reads input text, generates structured memory summaries, and decides where to place them in a directory hierarchy
- Retrieval: An LLM agent navigates the directory tree using filesystem tools (ls, cat, grep), reading README files to decide which paths to explore
1.2 Architecture
1.3 Key Design Principles
- LLM-native organization: The LLM decides the taxonomy structure, not hard-coded rules
- Filesystem as database: Directory tree = taxonomy, files = memories, READMEs = indexes
- Agentic retrieval: A reasoning agent navigates the tree at query time, not a similarity search
- Separation of concerns: Tree (read-only view), Workspace (write operations), Generator (LLM calls)
- Incremental updates: New content can be added without rebuilding the entire taxonomy
2. Data Model
2.1 FSNode (In-Memory Tree Node)
2.2 MemorizedChunk (Memory Unit)
2.3 DirectoryNode (Taxonomy Planning)
chunk_indices — they only contain subdirectories.
2.4 GAM Metadata File
Stored at<gam_dir>/.gam_meta.json:
2.5 ChatResult (Query Response)
3. Filesystem Storage Structure
3.1 Directory Layout
3.2 README Format
Each directory contains a README.md describing its contents:4. LLM Generator
4.1 Interface
4.2 OpenAI-Compatible Implementation
concurrent.futures.ThreadPoolExecutor with configurable worker count.
Structured output: When a schema parameter is provided, the generator uses OpenAI’s JSON schema response format to ensure valid structured output. On parse failure, uses a JSON repair library to fix common issues.
4.3 LLM Prompt Templates
Memory Generation Prompt
Batch Organization Prompt
Chunk Assignment Prompt (Incremental)
README Generation Prompt
5. Memory Building Pipeline (GAM Agent)
5.1 Full Build (Empty GAM)
When adding content to an empty GAM directory: Step 1 — Input Resolution:- Accept file paths (PDF, TXT, MD) or raw text strings
- Extract text from PDFs using a PDF parser
- Concatenate all input into a single text corpus
- Count total tokens using a tokenizer (tiktoken)
- If total tokens > max_chunk_tokens: split into chunks
- Chunking algorithm (see Section 5.2)
- For each chunk, call LLM with memory generation prompt
- Use ThreadPoolExecutor for parallel processing
- Collect
MemorizedChunkobjects with index, title, memory, tldr
- Send all chunk summaries (index, title, tldr) to LLM
- LLM returns a DirectoryNode tree
- Validate: every chunk index appears in exactly one leaf
- Create directory structure
- Write each chunk as
{title}.mdin its assigned directory - Generate README.md at each directory level via LLM
- Write
.gam_meta.jsonwith creation info
5.2 Chunking Algorithm
5.3 Incremental Add (Existing GAM)
When adding new content to an existing taxonomy: Step 1-3: Same as full build (resolve input, chunk, generate memories) Step 4 — Placement Decision: For each new chunk:- Load current taxonomy structure (directory tree + READMEs)
- Ask LLM: “Which existing directory best fits this chunk?”
- If good fit found: place chunk in that directory
- If no good fit: create new directory
- Ask LLM to re-plan the taxonomy for that subtree
- Compute file movements needed
- Execute movements (rename/move files)
- Update affected README files
5.4 ReorganizeOperation
6. Retrieval Pipeline (Chat Agent)
6.1 Agent Loop
The chat agent is an LLM with access to filesystem tools. It explores the GAM tree to answer queries.6.2 Exploration Guidelines (System Prompt)
6.3 Tool Definitions
ls — List Directory
cat — Read File
grep — Search Files
bm25_search — Full-Text Search (Optional)
answer — Provide Final Answer
7. Workspace Layer
7.1 Local Workspace
7.2 Docker Workspace (Optional)
For sandboxed execution:8. GAM Tree (Read-Only View)
8.1 Tree Construction
8.2 Tree Operations
9. Workflow API
9.1 Public Interface
9.2 CLI Entry Points
10. Configuration
10.1 Environment Variables
10.2 Chunk Configuration
11. Behavioral Test Specifications
11.1 Memory Building Tests
11.2 Retrieval Tests
11.3 Tool Execution Tests
11.4 Edge Case Tests
12. Dependencies
12.1 Required
12.2 Optional
13. Project Structure
14. Key Algorithm: Taxonomy Validation
This specification provides complete architectural and behavioral detail for independent implementation of a hierarchical agentic memory system with LLM-driven auto-taxonomy, filesystem storage, and multi-strategy retrieval.