Problem
The "Compact Session Log" button in the OpenClaw UI (macOS app / web control panel) performs a raw JSONL file truncation — it simply keeps the last N lines and discards the rest. This results in complete context loss after compaction.
Meanwhile, the /compact text command uses the Pi Coding Agent SDK's intelligent compaction, which:
- Generates a structured LLM summary (Goal, Progress, Key Decisions, Next Steps, Critical Context)
- Keeps recent messages (
keepRecentTokens: 20000)
- Tracks file operations (read/modified files)
- Supports iterative summarization (merges with previous summaries)
This is the same compaction mechanism used by Claude Code, and it produces seamless context continuity.
Root Cause
The UI button calls sessions.compact in src/gateway/server-methods/sessions.ts, which does:
const keptLines = lines.slice(-maxLines);
fs.writeFileSync(filePath, keptLines.join("\n") + "\n", "utf-8");
No LLM call, no summarization — just file truncation.
The /compact text command (src/auto-reply/reply/commands-compact.ts) calls compactEmbeddedPiSession(), which uses the full Pi SDK session.compact() with structured summarization prompts.
Additional Issue: /compact unreachable on Slack
The /compact command has scope: "text" and textAlias: "/compact", but on Slack, all /-prefixed messages are intercepted by Slack as native slash commands and never reach OpenClaw. This means there is no way for Slack users to trigger smart compaction manually.
Suggested Fix
- UI button: Change
sessions.compact to call compactEmbeddedPiSession() instead of raw file truncation
- Slack accessibility: Either register
/compact as a Slack slash command, or support a non-/ prefix alternative (e.g., !compact)
Environment
- OpenClaw with Slack channel
- Pi Coding Agent SDK (shared with Claude Code)
- Discovered by source code analysis comparing
sessions.compact vs commands-compact.ts
Problem
The "Compact Session Log" button in the OpenClaw UI (macOS app / web control panel) performs a raw JSONL file truncation — it simply keeps the last N lines and discards the rest. This results in complete context loss after compaction.
Meanwhile, the
/compacttext command uses the Pi Coding Agent SDK's intelligent compaction, which:keepRecentTokens: 20000)This is the same compaction mechanism used by Claude Code, and it produces seamless context continuity.
Root Cause
The UI button calls
sessions.compactinsrc/gateway/server-methods/sessions.ts, which does:No LLM call, no summarization — just file truncation.
The
/compacttext command (src/auto-reply/reply/commands-compact.ts) callscompactEmbeddedPiSession(), which uses the full Pi SDKsession.compact()with structured summarization prompts.Additional Issue:
/compactunreachable on SlackThe
/compactcommand hasscope: "text"andtextAlias: "/compact", but on Slack, all/-prefixed messages are intercepted by Slack as native slash commands and never reach OpenClaw. This means there is no way for Slack users to trigger smart compaction manually.Suggested Fix
sessions.compactto callcompactEmbeddedPiSession()instead of raw file truncation/compactas a Slack slash command, or support a non-/prefix alternative (e.g.,!compact)Environment
sessions.compactvscommands-compact.ts