qwen-code/docs/users
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
..
configuration fix(openai): default splitToolMedia so tool-returned images reach strict backends (#4917) 2026-06-11 04:51:14 +08:00
extension chore(deps): upgrade ink 6.2.3 → 7.0.2 + bump Node engine to 22 (#3860) 2026-05-11 17:29:50 +08:00
features feat(cli): add /compress-fast command for no-LLM rule-based context compression (#4893) 2026-06-12 11:54:29 +08:00
ide-integration update documentation 2025-12-19 18:16:59 +08:00
reference feat(cli): virtual viewport for long conversations on ink 7 (#4146) 2026-06-02 13:57:17 +08:00
support feat(installer): verify release assets + switch public docs to standalone entrypoint (#3855) 2026-06-04 17:23:04 +08:00
_meta.ts feat(daemon): merge daemon-mode feature batch into main (#4490) 2026-06-12 00:34:49 +08:00
common-workflow.md docs: updated all links, click and open in vscode, new showcase video in overview 2025-12-17 11:10:31 +08:00
integration-github-action.md docs: updated all links, click and open in vscode, new showcase video in overview 2025-12-17 11:10:31 +08:00
integration-jetbrains.md docs(integration): use CDN URLs for images and fix formatting 2026-03-16 14:12:48 +08:00
integration-vscode.md fix: docs 2026-01-14 10:30:03 +08:00
integration-zed.md docs(integration): use CDN URLs for images and fix formatting 2026-03-16 14:12:48 +08:00
overview.md feat(installer): verify release assets + switch public docs to standalone entrypoint (#3855) 2026-06-04 17:23:04 +08:00
quickstart.md feat(installer): verify release assets + switch public docs to standalone entrypoint (#3855) 2026-06-04 17:23:04 +08:00
qwen-serve-deploy-local.md feat(daemon): merge daemon-mode feature batch into main (#4490) 2026-06-12 00:34:49 +08:00
qwen-serve.md feat(daemon): merge daemon-mode feature batch into main (#4490) 2026-06-12 00:34:49 +08:00