qwen-code/docs/users/features
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
..
channels feat(channels): add Feishu (Lark) channel adapter (#4379) 2026-05-28 20:11:00 +08:00
_meta.ts refactor(core): remove GitService, migrate /restore to FileHistoryService (#4871) 2026-06-09 18:34:31 +08:00
approval-mode.md refactor(cli): rename "Default" approval mode to "Ask permissions" (#4625) (#4674) 2026-06-03 12:08:44 +08:00
arena.md feat(arena): add comparison summary for agent results (#3394) 2026-04-22 05:31:19 +08:00
auto-mode.md Harden auto mode self-modification checks (#4572) 2026-06-08 10:22:31 +08:00
code-review.md feat(cli): route foreground subagents through pill+dialog while running (#3768) 2026-05-06 14:08:12 +08:00
commands.md feat(cli): add /compress-fast command for no-LLM rule-based context compression (#4893) 2026-06-12 11:54:29 +08:00
dual-output.md feat(cli): add dual-output sidecar mode for TUI (#3352) 2026-04-18 02:14:53 +08:00
followup-suggestions.md fix: improve /model --fast description clarity and prevent accidental activation (#3077) 2026-04-10 12:09:46 +08:00
headless.md feat(cli): headless / non-interactive runaway-protection guardrails (#4103) (#4502) 2026-05-26 00:06:26 +08:00
hooks.md feat(hooks): add prompt hook type with LLM evaluation support (#3388) 2026-05-15 17:13:05 +08:00
language.md refactor(cli): revert dynamic slash command LLM translation (#4145) 2026-05-15 16:01:16 +08:00
lsp.md fix(lsp): expose status and startup diagnostics (#3649) 2026-05-17 01:42:28 +08:00
markdown-rendering.md feat(cli): support /copy N to copy Nth-last AI message (#4761) 2026-06-08 10:08:45 +08:00
mcp.md feat(perf): progressive MCP availability — MCP no longer blocks first input (#3994) 2026-05-13 22:17:16 +08:00
memory.md feat(memory): load .qwen/QWEN.local.md as project-local context (#4091) (#4394) 2026-05-25 11:22:55 +08:00
sandbox.md feat(cli): support tools.sandboxImage in settings (#3146) 2026-04-13 09:43:34 +08:00
scheduled-tasks.md feat(core): enable loop/cron tools by default (#4950) 2026-06-10 23:21:53 +08:00
skills.md feat(skills): support priority field in SKILL.md for sorting skill display order (#4155) 2026-05-21 14:49:22 +08:00
status-line.md fix(cli): statusline not re-rendering when switching from preset to command type (#4706) 2026-06-03 14:17:16 +08:00
structured-output.md docs: user + design docs for --json-schema structured output (#4051) 2026-05-17 23:10:34 +08:00
sub-agents.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
tips.md feat: add contextual tips system with post-response context awareness (#2904) 2026-04-13 17:40:27 +08:00
token-caching.md feat: update docs 2025-12-12 19:37:36 +08:00
tool-use-summaries.md feat(cli,core): LLM-generated summary labels for tool-call batches (#3538) 2026-04-27 16:54:10 +08:00
worktree.md feat(worktree): Phase D — startup --worktree flag + symlinkDirectories + PR refs (#4381) 2026-05-27 17:04:51 +08:00