8000 feat(commands): add /compact to summarize older messages on demand by geminixiang · Pull Request #164 · geminixiang/mikan · GitHub
[go: up one dir, main page]

Skip to content

feat(commands): add /compact to summarize older messages on demand - #164

Merged
geminixiang merged 1 commit into
mainfrom
feat/compact-command
Oct 9, 2026
Merged

geminixiang merged 1 commit into
mainfrom
feat/compact-command

Conversation

@geminixiang
Copy link
Copy Markdown
Owner

/compact [instructions] (/pi-compact in Slack) summarizes a session's older messages with pi-durable's Conversation.compact(), in DMs and channels.

Change

Part Change
Command Manifest entry compact (Slack /pi-compact, Discord, Telegram menu) and CompactCommandHandler
Runtime handleCompactCommand leases the session's runner, as a run does, so the model binding is in place; the command already runs in the session's queue, after its own run
Harness MikanAgentSession.compact(): attach, conversation.compact(instructions), wait for the task and its placed summary; reports Nothing to compact yet when pi-durable finds nothing to summarize. Sizes are estimated per context message with pi-ai's estimateMessageTokens
Slack manifests and docs /pi-compact added to the example manifests, the command docs (4 languages), and the minimal guide

Slack only: slash commands do not run in threads, and in a channel the reply is ephemeral, like other slash commands there. Existing Slack apps must add /pi-compact.

Eval (.workspace/compact-eval, Slack slash command through the bot and runtime with the faux model)

Case main this branch
C1 long DM, /pi-compact keep the question numbers no reply; 12 messages "Context compacted: about 69,957 → 20,076 tokens"; 1 model call; 5 messages
C2 long channel, top level no reply same, shown only to the caller; 1 model call; 12 → 5 messages
C3 short DM no reply "Nothing to compact yet"; no model call
C4 instructions reach the summary request no yes
C5 next message starts from the summary no yes
C6 stored entries 19 20 (summary added, nothing removed)

Verification

  • Failing tests first: compaction with instructions and reported sizes; nothing to compact.
  • Full gate.
  • Local daemon on a test Slack workspace with /pi-compact added to the app: a DM replied "Context compacted: about 24,528 → 13,469 tokens", and the next message still recalled a code given before the compaction.

mikan compacted only automatically, and /new, the only manual way to shrink a session, is limited to DMs because it discards shared context. /compact [instructions] asks pi-durable to compact the session through its runner, in DMs and channels, and reports the estimated context size before and after; nothing is deleted from the session history. Slack apps must register /pi-compact.
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying mikan with  Cloudflare Pages  Cloudflare Pages

Latest commit: 978222c
Status: ✅  Deploy successful!
Preview URL: https://604647c4.mikan-1wv.pages.dev
Branch Preview URL: https://feat-compact-command.mikan-1wv.pages.dev

View logs

@geminixiang
geminixiang merged commit 5d79b98 into main Oct 9, 2026
4 of 5 checks passed
@geminixiang
geminixiang deleted the feat/compact-command branch October 9, 2026 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0