This post is an engineering roadmap for upgrading the chong (Crush) agent based on a detailed comparison with GenericAgent (GA), a framework whose core thesis is *Contextual Information Density Maximization*: long-horizon agent performance depends not on context length but on how much decision-relevant information fits in a limited context budget.
Key points
Gap analysis (GA vs chong)
- Layered memory: GA uses a 5-layer pyramid — L0 constitution, L1 index (≤30 lines), L2 facts, L3 SOPs, L4 archives. Chong has 4 flat categories (preference/pattern/decision/fact) with no constitution layer.
- Context compression: GA runs 6 cooperative strategies; chong only has a single LLM summarizer (
StructuredCompressor) triggered at a 70% token threshold. - Self-evolution: GA crystallizes validated execution paths into SOPs and reuses them via an index; chong only promotes high-importance memories to patterns, with no SOP crystallization and no write governance.
- Skill tree: GA's skills grow autonomously from seed code; chong's skills are hand-written SKILL.md/SKILL.lua files.
- Token efficiency: GA completes complex tasks within a <30K context window (others need 200K–1M); chong uses 128K with threshold-based compression.
- Web content: GA's
optHTMLpipeline (DOM denoising, list sampling, smart truncation) has no chong equivalent —web_scanreturns raw HTML. - Archiving: GA keeps L4 session archives (compressed every 12h) for long-range recall; chong only retains one-off summaries.
- Phase 0 — Memory constitution & layered indexing (2–3 weeks): create
constitution.md(global + project) with the 4 axioms and a write-permission matrix; implement a GoConstitution.ValidateWriteguard; build anL1IndexManager(≤30 lines, ≤1K tokens) storing keyword→pointer mappings and RULE entries; inject L1 + RULES into the system prompt instead of dumping all matched memories; migrate high-importance SQLite memories into a structuredfacts.md(L2) via a dual-write adapter; add access interceptors to track SOP usage and scene keywords. - Phase 1 — Context density engine (2–3 weeks): implement tool-schema hashing/dedup, history tag compression, working-memory folding,
WebSimplifier(list sampling, stripping SVG/styles/long URLs, smart truncation), aSummaryEnforcerwith 80-char truncation, and aContextTrimmerprotecting head/tail; add density metrics (decision vs noise tokens, tokens saved). Acceptance: peak context under 40K tokens for 70-turn tasks (currently ~90K+), 50%+ HTML token reduction. - Phase 2 — Skill crystallization & skill tree growth (3–4 weeks): a
Crystallizerthat turns validated execution paths into reusable SOPs (task prompt, tool-call records, success flag, new files, dependencies as candidate inputs), auto-updating the L1 index. - Phase 3 — Autonomous reflection loop and Phase 4 — Advanced features follow, mirroring GA's scheduler/reflector architecture.
GA's ten leading design principles
1. Information density maximization — stuffing more content into context is harmful; density beats length.
2. Memory constitution (L0) — 4 axioms govern all writes: Action-Verified Only, Sanctity of Verified Data, No Volatile State, Minimum Sufficient Pointer, plus an information-classification decision tree.
3. Existential coding — L1 only tells the LLM that knowledge exists (scene keyword → memory pointer); the agent reads details on demand.
4. Tool description deduplication — unchanged tool schemas are replaced by one line ("Tools: still active, protocol unchanged"), saving ~2,000+ tokens/turn (140K+ over a 70-turn task).
5. Six cooperative compression strategies: tool dedup, history tag truncation (every 5 turns), working-memory folding (consecutive agent turns → [Agent] (N turns)), HTML simplification, enforced <summary> (≤80 chars), and context trimming beyond 3× context window.
6. Skill crystallization — new task → autonomous exploration →固化 SOP into L3 → update L1 index → direct reuse, gated by the L0 constitution.
7. Enforced summaries — every response must contain a <summary> tag (missing one triggers a nag prompt); summaries build a session-level narrative chain that survives compression.
8. Extreme HTML compression — simphtml.py: enhanced DOM copy, token-oriented stripping, findMainList keeping 3 representative items, size-based recursive truncation; 50%+ token savings on list pages.
9. Autonomous reflection scheduling — reflect/ system with a singleton scheduler (120s checks), autonomous reflector (30-min idle checks), and BBS-based multi-agent team worker, sharing a uniform check()/on_done() interface.
10. Continuous working-memory folding — only the last 30 entries stay unfolded, preventing history from flooding context.
Upgrade roadmap (phases with estimates)
Architecture blueprint
The target design stacks four engines under L0 governance: the layered memory pyramid (L1–L4), the six-strategy context density engine, and the crystallization/self-evolution engine (crystallizer, SOP generator, skill-tree indexer, autonomous reflector, L4 archiver on a 12h cron, and a constitution guardian auditing all writes).
The post includes Go interface sketches (constitution.go, index_manager.go, history_compressor.go, folder.go, web_simplifier.go, summary_enforcer.go, context_trimmer.go, crystallizer.go), verification checklists per phase, and appendices covering a three-dimension comparison matrix, key interface designs, and a glossary.