Existing memory agents process long documents using flat token-based chunking, which disrupts the intrinsic hierarchical relationships in structured data (e.g., JSON, HTML, API responses). TreeAgent identifies three limitations arising from this approach:
1. Fixed-length chunking splits fields belonging to the same record across chunks, requiring cross-chunk reconstruction of associations.
2. Chunks lack hierarchical positional information, preventing agents from recognizing their structural context.
3. Sequential memory updates discard fine-grained details of earlier sibling nodes, impairing subsequent reasoning.
## Technical Positioning
**Domain**: Memory context window optimization technique
## Three Key Innovations of TreeAgent
### 1. Structural Chunking
Preserves complete subtrees or groups of adjacent sibling subtrees as single chunks, ensuring local structural relationships remain intact within each memory update. Applying this strategy recursively over the entire tree provides a theoretical upper bound on the number of chunks.
### 2. Structural Path Annotation
Each chunk is annotated with its path in the original tree (e.g., /root/child[2]/grandchild[1]), enabling the agent to identify its ancestor nodes and hierarchical position—thus avoiding erroneous associations between fragments from different levels.
### 3. Residual Memory Linking
Establishes direct information flow from lower-level child-node chunks to higher-level parent-node chunks, analogous to ResNet’s skip connections. This bypasses intermediate memory updates and prevents critical evidence from being lost during successive compression.
## Experimental Results
Experiments were conducted on four formats—JSON, HTML, YAML, and JavaScript—with input lengths ranging from 8K to 1M tokens, covering eight retrieval and aggregation tasks. Results show:
- TreeAgent improves the average score of four representative memory agents by 3.61%.
- All agents achieve performance gains across all datasets.
- Ablation studies confirm that structural path annotation and residual linking provide additional gains beyond structural chunking alone.
## Implications for Agent Systems
This technique offers direct insights for codebase dialogue scenarios: TreeAgent’s structural path annotation and residual linking enhance preservation of hierarchical information—especially valuable when handling large-project directory trees and dependency graphs.
For Hermes’ paper-processing workflow, when dealing with long documents containing nested structures (e.g., multi-author papers, technical reports with appendices), TreeAgent’s approach—preserving document hierarchy rather than naively splitting by token count—can be directly adopted.