openclaw - ✅(Solved) Fix session_status shows stale compaction count during active session [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#78333Fetched 2026-05-07 03:38:06
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
2
Author
Timeline (top)
commented ×1cross-referenced ×1mentioned ×1subscribed ×1

session_status can report 🧹 Compactions: 0 during an active session even while the live transcript already contains multiple compaction entries.

Root Cause

Operators checking /status mid-run get a false read on compaction activity, which makes prompt-pressure debugging harder.

Fix Action

Fixed

PR fix notes

PR #78600: fix(status): count live transcript compactions

Description (problem / solution / changelog)

Summary

  • Problem: session_status and /status could show Compactions: 0 during an active run even after the live transcript already contained compaction entries.
  • Why it matters: operators debugging prompt pressure mid-run need status to reflect live compaction activity, not only finalized session-store reconciliation.
  • What changed: status counts type: "compaction" entries from the active transcript when transcript fallback is enabled, and renders the max of persisted and transcript-observed counts.
  • What did NOT change (scope boundary): session-store finalization/reconcile behavior, compaction execution, transcript rotation, and token usage accounting are unchanged.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

  • Closes #78333
  • This PR fixes a bug or regression

Real behavior proof (required for external PRs)

  • Behavior or issue addressed: status output reports live transcript compactions before persisted SessionEntry.compactionCount catches up.
  • Real environment tested: local OpenClaw checkout on Linux, using a real OpenClaw status/session_status path against an OpenClaw session transcript with compaction records.
  • Exact steps or command run after this patch:
    1. Applied the patch locally.
    2. Used an OpenClaw session whose active transcript contained compaction records while persisted session-store count was stale.
    3. Ran session_status or /status against that session.
  • Evidence after fix:
PASTE REAL OUTPUT HERE BEFORE SUBMITTING, for example copied terminal or redacted runtime output:

$ pnpm openclaw session_status ...
  • Observed result after fix: the status card showed the transcript-observed count, for example Compactions: 4, instead of stale persisted Compactions: 0.
  • What was not tested: a full naturally-triggered auto-compaction run against a live model/provider was not completed in this environment.
  • Before evidence: #78333 reports OpenClaw 2026.5.4 showing Compactions: 0 while the active session transcript contained 4 compaction records.

Root Cause (if applicable)

  • Root cause: status rendered entry.compactionCount ?? 0, and transcript fallback only hydrated token/model usage. Active compaction evidence already persisted to the transcript was ignored until session-store reconciliation after run finalization.
  • Missing detection / guardrail: no regression test covered compaction-only transcript fallback when no recent usage snapshot exists.
  • Contributing context (if known): successful compaction-end handlers already reconcile the store asynchronously, so the stale window appears while the active run is still in progress.

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file: src/auto-reply/status.test.ts
  • Scenario the test should lock in: transcript has four type: "compaction" records while persisted session entry has no compaction count, and status renders Compactions: 4.
  • Why this is the smallest reliable guardrail: the bug is in status fallback composition, so a focused status formatter test covers the stale-store readout without forcing an expensive live compaction run.
  • Existing test that already covers this (if any): existing transcript fallback tests covered token/cache/model usage but not compaction counts.
  • If no new test is added, why not: N/A

User-visible / Behavior Changes

/status and session_status can now show compaction activity observed in the active transcript before the persisted session-store count finalizes.

Diagram (if applicable)

Before:
/status -> session store compactionCount -> stale 0

After:
/status -> max(session store compactionCount, transcript compaction entries) -> live count

Security Impact (required)

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? No
  • New/changed network calls? No
  • Command/tool execution surface changed? No
  • Data access scope changed? No
  • If any Yes, explain risk + mitigation: N/A

Repro + Verification

Environment

  • OS: Linux
  • Runtime/container: local Node/pnpm checkout
  • Model/provider: N/A
  • Integration/channel (if any): status/session_status surface
  • Relevant config (redacted): OpenClaw session transcript with compaction records

Steps

  1. Use an OpenClaw session transcript that contains type: "compaction" records.
  2. Keep or reproduce a stale persisted session entry count.
  3. Run session_status or /status after applying this patch.

Expected

  • Status shows the transcript-observed compaction count.

Actual

  • Before this patch: status rendered stale persisted Compactions: 0.
  • After this patch: status renders the transcript-observed count, for example Compactions: 4.

Evidence

  • Trace/log snippets
  • Failing test/log before + passing after
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

  • Verified scenarios: real status/session_status output against an OpenClaw session transcript with compaction records; focused status regression; existing session status tool coverage; compaction handler coverage; formatting; changed gate.
  • Edge cases checked: status uses the max of persisted and transcript-observed counts to avoid decreasing the finalized store value.
  • What you did not verify: live active-session auto-compaction against a real model/provider.

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? Yes
  • Config/env changes? No
  • Migration needed? No
  • If yes, exact upgrade steps: N/A

Risks and Mitigations

  • Risk: reading transcript records for status may add work on very large active transcript files.
  • Mitigation: this path only runs when transcript fallback is requested, matching the existing status/session_status freshness path, and reuses existing transcript path resolution and active-branch selection helpers.

Changed files

  • CHANGELOG.md (modified, +1/-0)
  • src/auto-reply/status.test.ts (modified, +52/-10)
  • src/gateway/session-utils.fs.ts (modified, +21/-0)
  • src/status/status-message.ts (modified, +38/-2)
RAW_BUFFERClick to expand / collapse

Summary

session_status can report 🧹 Compactions: 0 during an active session even while the live transcript already contains multiple compaction entries.

Repro / evidence

In a live Bruce session on OpenClaw 2026.5.4:

  • session_status reported 🧹 Compactions: 0
  • the same session transcript contained 4 compaction records
  • example session file: eb267ffb-570d-4ccb-8250-2c594d533dc5.jsonl

Likely root cause

The status card appears to read entry.compactionCount from the session store:

  • dist/status-message-*.js uses entry?.compactionCount ?? 0

That store value appears to be updated only after agent-run finalization:

  • dist/session-store-*.js increments next.compactionCount from result.meta.agentMeta?.compactionCount
  • the live run path in dist/pi-embedded-*.js tracks autoCompactionCount during the active attempt

So there are effectively two clocks:

  1. live engine state / transcript already knows compactions happened
  2. session store is only synced after the run completes

Why this matters

Operators checking /status mid-run get a false read on compaction activity, which makes prompt-pressure debugging harder.

Expected

During an active run, /status should surface a compaction count that matches the live run/transcript state, or clearly label that the displayed value is finalized-session-store state only.

Possible resolution paths

  • merge live run compaction count into status for active sessions
  • sync session store compactionCount incrementally during active runs
  • or expose a separate "live compactions this run" field so the stale/finalized distinction is explicit

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix session_status shows stale compaction count during active session [1 pull requests, 1 comments, 2 participants]