| name | generic-agent |
| description | Self-evolving agent memory via context information density maximization. Crystallizes completed tasks into reusable Skills (L3), maintains layered memory (L0–L4), and compresses context to preserve decision-relevant signal. Hybrid model: project-scoped (.pi-memory/ in repo) + global (~/.pi/agent/skills/generic-agent/memory/). Project skills shadow global skills. Auto-triggered after reflect_capture to sync learnings, and before tasks to recall relevant skills. Use when building on prior work, iterating on similar tasks, preserving session learnings, or managing long-running sessions. |
GenericAgent — Self-Evolving Memory for pi
Core Principle
Context information density maximization. Performance is determined not by context length, but by how much decision-relevant information is maintained within a finite budget.
Auto-Trigger (Two-Way Integration with reflect)
After reflect_capture fires:
reflect_capture (auto) → generic-agent triggers → sync_from_reflect.py
→ Converts reflect captures → L3 Skills (patterns) / L2 Facts (process/knowledge)
→ Skills indexed and immediately available for future recall
Before any task:
recall.py --query "<user request>"
→ Searches project + global L3 Skills
→ Searches L2 Facts
→ Searches L4 Sessions
→ Searches reflect's captures (bonus)
→ Returns highest-density context for the current task
Memory Layers (L0–L4) × Hybrid Scope
| Layer | Global | Project | Purpose |
|---|
| L0 | memory/.l0_meta/ | <repo>/.pi-memory/.l0_meta/ | Agent meta-rules |
| L1 | memory/.l1_index/ | <repo>/.pi-memory/.l1_index/ | Fast-routing index |
| L2 | memory/.l2_facts/ | <repo>/.pi-memory/.l2_facts/ | Stable knowledge |
| L3 | memory/.l3_skills/ | <repo>/.pi-memory/.l3_skills/ | Reusable Skills |
| L4 | memory/.l4_sessions/ | <repo>/.pi-memory/.l4_sessions/ | Session archives |
Quick Commands
python memory/recall.py --query "<what you need>"
python memory/sync_from_reflect.py
python memory/evolve.py --session <id> --task "<description>"
python memory/compress_context.py --session <id> --budget 6000
python memory/recall.py --list-skills
python memory/recall.py --query "<q>" --global-only
python memory/recall.py --query "<q>" --project-only
Reflect → Skill Mapping
| reflect type | → generic-agent layer | Example |
|---|
type=pattern | L3 Skill | Error fix SOPs |
type=process | L2 Fact | Campaign lifecycle |
type=knowledge | L2 Fact | Domain insights |
Layer Detection
--project <path> — explicit project path
--global — force global layer
- Auto-detect
.pi-memory/ in cwd → project layer
- Fall back to global
Key Principle
After reflect_capture auto-runs, immediately call:
python memory/sync_from_reflect.py --dry-run
python memory/sync_from_reflect.py
This converts every reflect capture into a searchable, reusable Skill. The more you use pi, the smarter it gets — automatically.