Skip to content

research(memory): schema-based trajectory summarization for hard compaction (Manus pattern) #1738

@bug-ops

Description

@bug-ops

Background

The Manus agent (2025/10) uses a two-stage compaction strategy:

  1. Observation masking (soft compaction): Replace stale tool results with file-path references as context fills. Recent results stay in full.
  2. Schema-based trajectory summarization (hard compaction): When masking reaches diminishing returns, summarize the full trajectory using a structured schema that defines required fields (goal, decisions made, open questions, current state, last action, next steps).

Source: Context Engineering in Manus (Lance Martin, Oct 2025)

Problem

Zeph's current hard compaction () generates a free-form LLM summary with no schema. This produces variable-quality summaries — sometimes verbose, sometimes missing critical context (e.g., what tools were called, what decisions were made, what files were modified).

Proposal

Add a structured summarization schema to CompactionTier::Hard in crates/zeph-core/src/agent/context/summarization.rs:

## Summary Schema
- **Goal**: What the user asked for
- **Completed**: Actions/tools that succeeded (with results)
- **Decisions**: Key choices made with rationale
- **Open**: Unresolved questions or pending steps
- **Files modified**: List with brief descriptions
- **Next**: Recommended immediate action

The schema is injected into the compaction prompt as a response format requirement.

Applicability

  • Impact: High — structured summaries prevent loss of critical context (e.g., which files were modified) that causes agents to repeat work
  • Complexity: Low — prompt engineering change in build_compaction_prompt(), no structural changes
  • Risk: Low — existing tests cover compaction output; schema adds constraints, doesn't remove behavior

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestmemoryzeph-memory crate (SQLite)researchResearch-driven improvement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions