Skip to content

fix(compact): /compact shows 'success' message when probe HardFail rejects compaction #2058

@bug-ops

Description

@bug-ops

Summary

When memory.compression.probe is enabled and a compaction probe HardFail occurs, the /compact command still displays "Context compacted successfully." to the user, even though the compaction was rejected and original messages were preserved.

Root Cause

In crates/zeph-core/src/agent/mod.rs (around line 2133), the /compact handler matches Ok(_) without distinguishing between CompactionOutcome::Compacted and CompactionOutcome::ProbeRejected:

match self.compact_context().await {
    Ok(_) => {
        let _ = self.channel.send("Context compacted successfully.").await;
    }
    Err(e) => {
        let _ = self.channel.send(&format!("Compaction failed: {e}")).await;
    }
}

When compact_context() returns Ok(CompactionOutcome::ProbeRejected), the user sees the success message despite compaction being rejected.

Reproduction

  1. Enable compaction probe in config:
    [memory.compression.probe]
    enabled = true
    threshold = 0.6
    hard_fail_threshold = 0.35
  2. Have a session with simple fact-saving turns (not complex enough for anchored summary to capture)
  3. Run /compact

Log output (WARN):

WARN zeph_core::agent::context::summarization: compaction probe HARD FAIL — keeping original messages score=0.0 threshold=0.35

User sees (incorrect):

Context compacted successfully.

Expected Behavior

When probe HardFail rejects compaction, the user should see a message like:

Compaction rejected: summary quality too low (probe hard fail, score=0.0). Original context preserved.

Probe Dump Analysis

From 0011-compaction-probe.json (CI-21 session):

  • "score": 0.0, "verdict": "HardFail"
  • All 3 questions answered "UNKNOWN" — summary (anchored) captured high-level decisions but not specific fact content
  • Compaction correctly rejected by probe, but user messaging is misleading

Additional Observation

The anchored summarization format (session_intent, decisions_made, files_modified, etc.) is not designed to preserve specific factual content from simple fact-saving sessions. The probe correctly detects this lossiness, confirming the probe's detection logic is working. The only issue is the user-facing message.

Fix Suggestion

Match on CompactionOutcome::ProbeRejected in mod.rs and send an appropriate user message. The compact_context() return type already supports this variant.

Test Evidence

  • Version: v0.16.0 (post-commit 15b3f07)
  • Config: .local/config/testing-ci21.toml
  • Debug dump: .local/testing/debug/ci21/1774023117/0011-compaction-probe.json
  • Log: .local/testing/debug/session-ci21-probe.log
  • CI session: CI-21 (2026-03-20)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2High value, medium complexitybugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions