Skip to content

feat(context): hierarchical summary packing for prompt-ready recall #318

Open

Description

@hurttlocker

Summary

Add a prompt-ready hierarchical summary layer that lets Cortex compress large memory neighborhoods into progressively smaller, provenance-preserving summaries for recall-time use.

Why

The current Cortex/OpenClaw path is strong at retrieval, provenance, and fact infrastructure, but it still relies heavily on injecting raw memories or top-N results. The next quality/cost step is to let Cortex hand the agent a compact summary tree when the raw set is too large for the prompt budget.

This is inspired by the pattern seen in ByteRover-style context trees, but the implementation should stay fully local-first and native to Cortex.

Desired outcome

When a query hits a large or diffuse memory neighborhood, Cortex should be able to return:

  • a high-level summary node
  • optional mid-level project/file/section summaries
  • exact provenance pointers back to underlying source memories/facts

The agent should be able to expand from the summary back into the raw material when needed.

Proposed scope

  • Build or derive hierarchical summaries over existing Cortex memory/project/file/section structure
  • Preserve provenance to underlying source ids/paths/lines where possible
  • Support summary selection as a lower-cost alternative to injecting many raw items
  • Keep the implementation compatible with local SQLite-backed storage and existing hybrid retrieval

Acceptance criteria

  • Cortex can generate/store hierarchical summaries for at least one real recall surface (project/file/section or equivalent)
  • Summary records preserve links to underlying memories/facts/provenance
  • Recall can prefer summary nodes when the raw candidate set would exceed a prompt budget
  • A follow-up expansion path exists from summary -> underlying raw memories
  • Tests cover both compression quality and provenance preservation

Implementation hints

Relevant current surfaces:

  • internal/ingest/markdown.go already builds hierarchical section paths
  • internal/extract/extract.go intentionally preserves structured markdown / section information
  • OpenClaw recall currently happens through plugin/index.ts on before_agent_start

Out of scope

  • Cloud-hosted context trees
  • Any vendor lock-in or remote dependency
  • Replacing raw retrieval entirely

Activity

  1. added
    enhancement
    search
    llm
    on Mar 11, 2026
  2. hurttlocker commented on Mar 11, 2026

    @hurttlocker
    OwnerAuthor

    Q explicitly approved moving straight into #318-lite after #324 merge.

    This is not full #318 yet. Keep it to the bounded lite slice only:

    • grouped recall packing by project/file/section
    • provenance-safe collapse of same-source hits
    • use existing retrieval/recall surfaces where possible
    • keep it prompt-budget-aware

    Still out of scope:

    Planned sequence after this:

    1. ship feat(context): hierarchical summary packing for prompt-ready recall #318-lite
    2. run integrated recall-lane dogfood/test
    3. only then decide whether feat(search): ghost cues + archive stubs for long-tail memory resurfacing #320 earns its way in
  3. added 2 commits that reference this issue on Mar 11, 2026
  4. hurttlocker commented on Mar 11, 2026

    @hurttlocker
    OwnerAuthor

    Release-board hygiene note:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementllmsearch

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions