qwen-code/docs
Zqc f00d145ab0
feat(cli): add /compress-fast command for no-LLM rule-based context compression (#4893)
* feat(cli): add /compress-fast command for no-LLM rule-based context compression

Adds /compress-fast, a new slash command that compresses context without
any LLM side-query. It combines two rule-based steps:

1. Force microcompaction — clears old tool results and media parts,
   keeping the most recent N (default 5, configurable via
   toolResultsNumToKeep). Uses a new { force: true } option on
   microcompactHistory() to skip the time-based trigger.

2. Strip thinking blocks — removes thought parts from all model turns,
   keeping text and tool_use parts intact.

Uses setHistory() for zero-latency history replacement (no session
rebuild, deferred tools survive). Writes a chat_compression checkpoint
to JSONL so --resume works identically to /compress.

Post-compression, tryCompressChatFast() surgically disarms affected
file paths from FileReadCache via markReadEvictedFromHistory(), falling
back to clear() only when paths can't be resolved.

Resolves #4264.

* fix(cli): address review comments for /compress-fast PR

- Add test coverage for tryCompressChatFast FileReadCache disarming
  (NOOP, clear, surgical disarm with inode miss, full success)
- Fix weak assertions in geminiChat compressFast tests:
  - NOOP test now strictly asserts CompressionStatus.NOOP
  - lastPromptTokenCount test guarantees COMPRESSED with larger history
- Register 'No compression needed.' i18n key in en/zh/zh-TW locales

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix(core): address remaining review comments for /compress-fast PR

- Fix token estimation: use same estimator (estimateContentTokens) on
  both sides of the NOOP gate, then delta-adjust API-authoritative
  lastPromptTokenCount instead of replacing it with char/4 heuristic
- Handle lastPromptTokenCount=0 fallback for fresh/continued sessions
- Extract duplicated FileReadCache disarm logic into shared
  disarmFileReadCacheAfterEviction() method with debug logs
- Remove redundant setLastPromptTokenCount call from tryCompressChatFast
- Update tests for delta-adjustment and zero-fallback behavior

* fix(cli,core): address second-round review feedback

- Add telemetry: emit logChatCompression event in compressFast() for usage tracking
- Add /compress-fast to docs/users/features/commands.md
- Use CompressionStatus.NOOP enum instead of token count comparison for NOOP detection
- Deduplicate disarm logic in microcompactIdleHistory to use shared disarmFileReadCacheAfterEviction method (resolves conflict with upstream #4840)

---------

Co-authored-by: 俊良 <zzj542558@alibaba-inc.com>
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-06-12 11:54:29 +08:00
..
design feat(daemon): merge daemon-mode feature batch into main (#4490) 2026-06-12 00:34:49 +08:00
developers feat(daemon): merge daemon-mode feature batch into main (#4490) 2026-06-12 00:34:49 +08:00
e2e-tests feat(worktree): Phase D — startup --worktree flag + symlinkDirectories + PR refs (#4381) 2026-05-27 17:04:51 +08:00
plans feat(core)!: redesign auto-compaction thresholds with three-tier ladder (#4345) 2026-05-25 21:11:08 +08:00
superpowers feat(daemon): merge daemon-mode feature batch into main (#4490) 2026-06-12 00:34:49 +08:00
users feat(cli): add /compress-fast command for no-LLM rule-based context compression (#4893) 2026-06-12 11:54:29 +08:00
verification/abort-controller-refactor fix(core): stop AbortSignal listener leak in long sessions (MaxListenersExceededWarning) (#4366) 2026-05-26 14:21:49 +08:00
_meta.ts feat: refactor docs 2025-12-05 10:51:57 +08:00
declarative-agents-port.md feat(core): declarative agent frontmatter v1 — permissionMode bridge + maxTurns wiring + color allowlist (CC 2.1.168 parity) (#4842) 2026-06-11 05:03:31 +08:00
index.md fix: lint issues 2025-12-19 15:52:11 +08:00