You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(core): add microcompaction for idle context cleanup (#3006)
* feat(core): add microcompaction for idle context cleanup
Clear old tool result content from chat history when the user returns
after an idle period (default 60 min). Replaces functionResponse output
with a sentinel string for compactable tools (read_file, shell, grep,
glob, web_fetch, web_search, edit, write_file), keeping the N most
recent results intact (default 5). Runs before full compression so it
can shed tokens cheaply without an API call.
- Time-based trigger reuses lastApiCompletionTimestamp from thinking cleanup
- Per-part counting so keepRecent applies to individual tool results
even when batched in parallel
- Preserves tool error responses (only clears successful outputs)
- Configurable via settings.json (context.microcompaction) with env var
overrides for E2E testing
- Enabled by default
* refactor(config): unify idle cleanup settings under clearContextOnIdle
Consolidate thinking block cleanup and tool results microcompaction
config into a single `context.clearContextOnIdle` settings group:
{
"context": {
"clearContextOnIdle": {
"thinkingThresholdMinutes": 5,
"toolResultsThresholdMinutes": 60,
"toolResultsNumToKeep": 5
}
}
}
- Use -1 on either threshold to disable that cleanup (no enabled bool)
- Remove separate `microcompaction` and `gapThresholdMinutes` settings
- Thinking cleanup: 5 min default (unchanged)
- Tool results cleanup: 60 min default
- Preserve tool error responses (only clear successful outputs)
* feat(vscode-ide-companion): add clearContextOnIdle settings configuration
- Add gapThresholdMinutes settings for thinking blocks, tool results, and retention count
- Remove deprecated gapThresholdMinutes from root settings level
This reorganizes the context clearing settings into a dedicated clearContextOnIdle object with configurable thresholds for thinking blocks and tool results.
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
* fix(core): restrict microcompaction to user-initiated messages only
Move microcompactHistory() inside the UserQuery/Cron guard so model
latency during tool-call loops doesn't count as user idle time.
* docs: update settings docs for clearContextOnIdle config rename
Replace stale `context.gapThresholdMinutes` entry with the new
`context.clearContextOnIdle.*` settings group introduced in the
microcompaction feature.
* fix(core): address review comments on microcompaction PR
- Guard against NaN in toolResultsNumToKeep with Number.isFinite()
- Report effective keepRecent (after Math.max) in meta, not raw config
- Fix comment to mention cron messages alongside user messages
---------
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
|`context.fileName`| string or array of strings | The name of the context file(s). |`undefined`|
216
-
|`context.importFormat`| string | The format to use when importing memory. |`undefined`|
217
-
|`context.includeDirectories`| array | Additional directories to include in the workspace context. Specifies an array of additional absolute or relative paths to include in the workspace context. Missing directories will be skipped with a warning by default. Paths can use `~` to refer to the user's home directory. This setting can be combined with the `--include-directories` command-line flag. |`[]`|
218
-
|`context.loadFromIncludeDirectories`| boolean | Controls the behavior of the `/memory refresh` command. If set to `true`, `QWEN.md` files should be loaded from all directories that are added. If set to `false`, `QWEN.md` should only be loaded from the current directory. |`false`|
219
-
|`context.fileFiltering.respectGitIgnore`| boolean | Respect .gitignore files when searching. |`true`|
220
-
|`context.fileFiltering.respectQwenIgnore`| boolean | Respect .qwenignore files when searching. |`true`|
221
-
|`context.fileFiltering.enableRecursiveFileSearch`| boolean | Whether to enable searching recursively for filenames under the current tree when completing `@` prefixes in the prompt. |`true`|
222
-
|`context.fileFiltering.enableFuzzySearch`| boolean | When `true`, enables fuzzy search capabilities when searching for files. Set to `false` to improve performance on projects with a large number of files. |`true`|
223
-
|`context.gapThresholdMinutes`| number | Minutes of inactivity after which retained thinking blocks are cleared to free context tokens. Aligns with typical provider prompt-cache TTL. Set higher if your provider has a longer cache TTL. |`5`|
|`context.fileName`| string or array of strings | The name of the context file(s). |`undefined`|
216
+
|`context.importFormat`| string | The format to use when importing memory. |`undefined`|
217
+
|`context.includeDirectories`| array | Additional directories to include in the workspace context. Specifies an array of additional absolute or relative paths to include in the workspace context. Missing directories will be skipped with a warning by default. Paths can use `~` to refer to the user's home directory. This setting can be combined with the `--include-directories` command-line flag. |`[]`|
218
+
|`context.loadFromIncludeDirectories`| boolean | Controls the behavior of the `/memory refresh` command. If set to `true`, `QWEN.md` files should be loaded from all directories that are added. If set to `false`, `QWEN.md` should only be loaded from the current directory. |`false`|
219
+
|`context.fileFiltering.respectGitIgnore`| boolean | Respect .gitignore files when searching. |`true`|
220
+
|`context.fileFiltering.respectQwenIgnore`| boolean | Respect .qwenignore files when searching. |`true`|
221
+
|`context.fileFiltering.enableRecursiveFileSearch`| boolean | Whether to enable searching recursively for filenames under the current tree when completing `@` prefixes in the prompt. |`true`|
222
+
|`context.fileFiltering.enableFuzzySearch`| boolean | When `true`, enables fuzzy search capabilities when searching for files. Set to `false` to improve performance on projects with a large number of files. |`true`|
223
+
|`context.clearContextOnIdle.thinkingThresholdMinutes`| number | Minutes of inactivity before clearing old thinking blocks to free context tokens. Aligns with typical provider prompt-cache TTL. Use `-1` to disable. |`5`|
224
+
|`context.clearContextOnIdle.toolResultsThresholdMinutes`| number | Minutes of inactivity before clearing old tool result content. Use `-1` to disable. |`60`|
225
+
|`context.clearContextOnIdle.toolResultsNumToKeep`| number | Number of most-recent compactable tool results to preserve when clearing. Floor at 1. |`5`|
0 commit comments