memory-hierarchy-management
Skill5 starsChanged 35 days agoMITView on GitHub
Use when context window is getting crowded, when agent needs to recall past experiences, or when starting a long-running task that spans multiple sessions. Triggers when you have 43+ skills and can't fit them all in context, when you need to decide "what should be in working memory right now", or when persisting new learnings for future sessions.
In this repository63 other files it gives its agents.
- AGENTS.mdAGENTS.md
- adversarial-validation-kaggleSkill
- agent-nurture-frameworkSkill
- agent-session-memory-protocolSkill
- arxiv-paper-searchSkill
- autogluon-firstSkill
- autogluon-preset-strategySkill
- autogluon-timeseries-strategySkill
- catboost-first-tabularSkill
- claudeceptionSkill
- code-competition-artifact-pipelineSkill
- competition-orchestration-multimodelSkill
- context-engineeringSkill
- controlled-submission-experimentSkill
- cross-competition-feature-transferSkill
- cv-lb-gap-acknowledgmentSkill
- domain-knowledge-constraints-trapSkill
- ensemble-model-correlation-trapSkill
- feature-engineering-saturation-detectionSkill
- gpu-readiness-assessmentSkill
- gsd-loop-engineeringSkill
- kaggle-cognitive-cost-optimizationSkill
- kaggle-competition-best-practicesSkill
- kaggle-competition-type-strategySkill
- kaggle-data-format-firstSkill
- kaggle-discussion-searchSkill
- kaggle-experiment-sopSkill
- kaggle-oof-lb-validation-protocolSkill
- kaggle-optimal-blendingSkill
- kaggle-submission-format-by-metricSkill
- kaggle-top-performer-replicationSkill
- knowledge-crystallization-feedback-loopSkill
- ladder-drift-and-meta-aware-regressionSkill
- learned-value-beats-heuristic-augmentationSkill
- llm-competition-pipelineSkill
- mcts-pipeline-searchSkill
- mem0-dynamic-graph-memorySkill
- ml-sweet-spot-principleSkill
- model-ensemble-negative-weight-effectSkill
- multi-agent-rolesSkill
- multi-level-aggregation-overfittingSkill
- okf-visualize-knowledgeSkill
- onnx-minimal-network-designSkill
- per-category-modeling-backfireSkill
- progressive-verification-debuggingSkill
- ptcg-2ply-bounded-searchSkill
- ptcg-bc-large-model-submissionSkill
- retail-eda-frameworkSkill
- rmsle-zero-threshold-asymmetrySkill
- runtime-reflexionSkill
- sc-tir-mathematical-reasoningSkill
- self-evolving-skillsSkill
- skill-governance-and-automationSkill
- spatiotemporal-graph-feature-engineeringSkill
- store-sales-darts-chronos-blendSkill
- tabular-polynomial-features-breakthroughSkill
- three-layer-wisdom-extractionSkill
- time-series-walk-forward-validationSkill
- trueskill-simulation-competition-strategySkill
- ts-day-specific-forecastingSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 7 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 74
All 43 skills need to be in context (~25K chars) → leaves no room for actual work
- Distinctive: line 76
No way to know "which skill is most relevant right now"
- Distinctive: line 79
Only 5-20 items in working memory at any time
- Distinctive: line 89
After learning something valuable worth preserving
- Distinctive: line 90
When context window feels crowded
- Distinctive: line 91
When you need to recall past experience ("have we tried X before?")
- Distinctive: line 96
When working memory isn't full (overhead not worth it)
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Memory Hierarchy Management (MemGPT-Style)
Context
With 43+ skills and growing, stuffing everything into the agent's context window is impossible and wasteful. The naive approach (read SKILL.md on demand) is slow and lossy. This skill provides a 3-layer memory architecture: Working Memory (limited, in-context), Archival Store (unlimited, OKF-indexed), Long-term Storage (filesystem). Recall is multi-strategy (keyword + importance + recency + frequency).
The core insight: context is RAM, vault is disk. We treat them differently.
Guidance
The 3 Layers
Working Memory (in-context, ≤8000 chars)
↑↓ auto-promote / LRU evict
Archival Store (OKF graph, unlimited)
↑↓ write to filesystem on persist
Long-term Storage (docs/ml-agent-memory/auto-search/)When to Recall
from framework.src.memory import MemoryHierarchy
mem = MemoryHierarchy(okf_dir="docs/ml-agent-memory")
mem.bootstrap(extra_dirs=["skills/examples", "docs"])
# At decision points — recall relevant skills
items = mem.recall("time series walk-forward validation", k=5)
for item in items:
print(f"[{item.type}] {item.id} (imp={item.importance})")When to Remember
from framework.src.memory import MemoryItem
# High-importance → auto-archive
mem.remember(MemoryItem(
id="auto-finding-2026-08-05-catboost-vs-xgboost",
content="In S6E2, CatBoost OOF 0.8124 beat XGBoost 0.8003 (+0.012)",
type="experiment",
importance=0.8,
tags=["tabular","catboost","s6e2"],
), persist=True)Multi-Strategy Recall (Advanced)
from framework.src.memory.recall import multi_strategy_recall, RecallConfig
cfg = RecallConfig(
use_keyword=True,
use_recency=True, # Decay old items
use_importance=True, # Promote high-imp
use_access_frequency=True, # Frequently-used stays
recency_decay_days=30,
final_top_k=5,
)
results = multi_strategy_recall(mem.archival, "tabular feature engineering", cfg)Why This Matters
Without hierarchy:
- All 43 skills need to be in context (~25K chars) → leaves no room for actual work
- Agent forgets what worked yesterday
- No way to know "which skill is most relevant right now"
With hierarchy:
- Only 5-20 items in working memory at any time
- Skills auto-promoted based on multi-strategy score
- Important findings auto-persist to vault
ROI: 3-5x reduction in context usage; 2x improvement in skill relevance at decision points.
When to Apply
When to Use
- Starting any new ML competition/task
- After learning something valuable worth preserving
- When context window feels crowded
- When you need to recall past experience ("have we tried X before?")
When NOT to Use
- Truly novel task with no history (no skills exist yet)
- One-off quick question
- When working memory isn't full (overhead not worth it)
Notes
- Importance threshold: ≥0.7 items auto-archive; <0.5 stay in working only
- Recall vs Read: recall = multi-strategy ranking; read = direct fetch (when you know exactly which skill you want)
- Bootstrap once per session: indexing 43+ skills is slow; cache the index
- Combine with knowledge_search: for new techniques not in vault, also call
arxiv_searchorkaggle_search - See also:
runtime-self-reflection(uses memory hierarchy for anti-pattern storage)
References
- Architecture:
framework/src/memory/hierarchy.py - Recall strategies:
framework/src/memory/recall.py - OKF integration:
framework/src/memory/okf_index.py - Inspired by: MemGPT (Packer et al. 2023), Letta framework
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

