Skip to content

feat(memory): track trajectory elongation from hard compaction (#1739)#1787

Merged
bug-ops merged 1 commit intomainfrom
research-memory-track-trajecto
Mar 14, 2026
Merged

feat(memory): track trajectory elongation from hard compaction (#1739)#1787
bug-ops merged 1 commit intomainfrom
research-memory-track-trajecto

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented Mar 14, 2026

Summary

  • Add compaction_hard_count: u64 and turns_after_hard_compaction: Vec<u64> to MetricsSnapshot
  • Increment hard compaction counter and push per-segment turn count at each CompactionTier::Hard event in maybe_compact()
  • Turn counter increments before all early-return guards (exhaustion, server compaction, compacted_this_turn) so no turns are silently dropped
  • Final open segment is finalized at shutdown() and both fields are logged via tracing::info! when at least one hard compaction occurred
  • Closes research(memory): track trajectory elongation from hard compaction (summarization cost metric) #1739

Motivation

JetBrains Research (Dec 2025) found LLM summarization causes agents to run 13-15% longer on average. This change adds the instrumentation needed to detect and measure trajectory elongation in real Zeph sessions via .local/testing/debug/session.log.

Test plan

  • cargo +nightly fmt --check — pass
  • cargo clippy --workspace --features full -- -D warnings — pass
  • cargo nextest run --config-file .github/nextest.toml --workspace --features full --lib --bins — 5581 passed, 12 skipped
  • 4 new unit tests: compaction_hard_count_zero_by_default, compaction_hard_count_increments_on_hard_tier, compaction_turns_after_hard_tracks_segments, compaction_turn_counter_increments_before_exhaustion_guard

Add compaction_hard_count and turns_after_hard_compaction metrics to
MetricsSnapshot. Increment hard compaction counter and record per-segment
turn counts at each hard compaction event. Log both at agent shutdown via
tracing::info! for session-level trajectory analysis.

Turn counter is incremented before all early-return guards in maybe_compact
so proactive compression and exhaustion paths are counted accurately.
@github-actions github-actions bot added enhancement New feature or request documentation Improvements or additions to documentation size/M Medium PR (51-200 lines) rust Rust code changes core zeph-core crate and removed enhancement New feature or request labels Mar 14, 2026
@bug-ops bug-ops enabled auto-merge (squash) March 14, 2026 21:13
@bug-ops bug-ops merged commit 8f31a0f into main Mar 14, 2026
15 checks passed
@bug-ops bug-ops deleted the research-memory-track-trajecto branch March 14, 2026 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core zeph-core crate documentation Improvements or additions to documentation rust Rust code changes size/M Medium PR (51-200 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

research(memory): track trajectory elongation from hard compaction (summarization cost metric)

1 participant