mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-07-09 17:19:02 +00:00
refactor(core): trim threshold doc comments; name the hard-edge term
Post-review cleanup (no behavior change): - Collapse the duplicated regime explanation shared between the DEFAULT_PCT and computeThresholds doc comments into one canonical block; point the constant's doc at computeThresholds. - Rename rawHard -> hardEdge and note it is the window-edge ceiling, so the two roles of the hard tier (window edge vs. auto + HARD_BUFFER) are legible. - Shorten the context.autoCompactThreshold description in settings.md to the concise schema wording (also un-widens the docs table).
This commit is contained in:
parent
b6a6ea5447
commit
a0753111dd
2 changed files with 31 additions and 42 deletions
|
|
@ -288,21 +288,21 @@ The `extra_body` field allows you to add custom parameters to the request body s
|
|||
|
||||
#### context
|
||||
|
||||
| Setting | Type | Description | Default |
|
||||
| ----------------------------------------------------------- | -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------- |
|
||||
| `context.fileName` | string or array of strings | The name of the context file(s). | `undefined` |
|
||||
| `context.autoCompactThreshold` | number | Target fraction of the context window at which auto-compaction triggers. Must be greater than 0 and at most 1. Default is `0.85` (85%). Acts as a ceiling on the trigger in the three-tier threshold ladder: on large context windows this proportional value is the effective trigger (e.g. ~85%), while on smaller windows the absolute term (window minus ~33K) is lower and takes over to keep room to summarize (on very small windows below ~33K the proportional value is used as a floor instead). Lower values pull compaction earlier on large windows. Replaces the old `model.chatCompression.contextPercentageThreshold`. | `undefined` (uses internal 0.85) |
|
||||
| `context.importFormat` | string | The format to use when importing memory. | `undefined` |
|
||||
| `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. | `[]` |
|
||||
| `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` |
|
||||
| `context.fileFiltering.respectGitIgnore` | boolean | Respect .gitignore files when searching. | `true` |
|
||||
| `context.fileFiltering.respectQwenIgnore` | boolean | Respect .qwenignore and configured custom ignore files when searching. | `true` |
|
||||
| `context.fileFiltering.customIgnoreFiles` | array | Project-root-relative ignore files to use instead of the default compatibility files (`.agentignore`, `.aiignore`) when `respectQwenIgnore` is enabled. `.qwenignore` is always included. | `[".agentignore", ".aiignore"]` |
|
||||
| `context.fileFiltering.enableRecursiveFileSearch` | boolean | Whether to enable searching recursively for filenames under the current tree when completing `@` prefixes in the prompt. | `true` |
|
||||
| `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` |
|
||||
| `context.clearContextOnIdle.toolResultsThresholdMinutes` | number | Minutes of inactivity before clearing old tool result content. Use `-1` to disable the idle trigger. | `60` |
|
||||
| `context.clearContextOnIdle.toolResultsNumToKeep` | integer | Integer number of most-recent compactable tool results to preserve when clearing. Values below 1 are floored to 1. | `5` |
|
||||
| `context.clearContextOnIdle.toolResultsTotalCharsThreshold` | number | Total compactable tool result output characters allowed in history before clearing oldest results. Use `-1` to disable the size trigger. This is a soft threshold: protected recent tool results may keep the total above it. | `500000` |
|
||||
| Setting | Type | Description | Default |
|
||||
| ----------------------------------------------------------- | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------- |
|
||||
| `context.fileName` | string or array of strings | The name of the context file(s). | `undefined` |
|
||||
| `context.autoCompactThreshold` | number | Target fraction of the context window at which auto-compaction triggers. Must be greater than 0 and at most 1. Default is `0.85` (85%). Acts as a ceiling on the trigger: on large windows it is the effective trigger (~85%), while on smaller windows compaction may fire earlier to leave room to summarize. Replaces the old `model.chatCompression.contextPercentageThreshold`. | `undefined` (uses internal 0.85) |
|
||||
| `context.importFormat` | string | The format to use when importing memory. | `undefined` |
|
||||
| `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. | `[]` |
|
||||
| `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` |
|
||||
| `context.fileFiltering.respectGitIgnore` | boolean | Respect .gitignore files when searching. | `true` |
|
||||
| `context.fileFiltering.respectQwenIgnore` | boolean | Respect .qwenignore and configured custom ignore files when searching. | `true` |
|
||||
| `context.fileFiltering.customIgnoreFiles` | array | Project-root-relative ignore files to use instead of the default compatibility files (`.agentignore`, `.aiignore`) when `respectQwenIgnore` is enabled. `.qwenignore` is always included. | `[".agentignore", ".aiignore"]` |
|
||||
| `context.fileFiltering.enableRecursiveFileSearch` | boolean | Whether to enable searching recursively for filenames under the current tree when completing `@` prefixes in the prompt. | `true` |
|
||||
| `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` |
|
||||
| `context.clearContextOnIdle.toolResultsThresholdMinutes` | number | Minutes of inactivity before clearing old tool result content. Use `-1` to disable the idle trigger. | `60` |
|
||||
| `context.clearContextOnIdle.toolResultsNumToKeep` | integer | Integer number of most-recent compactable tool results to preserve when clearing. Values below 1 are floored to 1. | `5` |
|
||||
| `context.clearContextOnIdle.toolResultsTotalCharsThreshold` | number | Total compactable tool result output characters allowed in history before clearing oldest results. Use `-1` to disable the size trigger. This is a soft threshold: protected recent tool results may keep the total above it. | `500000` |
|
||||
|
||||
#### Troubleshooting File Search Performance
|
||||
|
||||
|
|
|
|||
|
|
@ -50,14 +50,10 @@ const debugLogger = createDebugLogger('COMPRESSION');
|
|||
export const COMPACT_MAX_OUTPUT_TOKENS = 20_000;
|
||||
|
||||
/**
|
||||
* Default proportional auto-compaction threshold. Under the ceiling semantics
|
||||
* of computeThresholds it is the *preferred* trigger and an upper bound on how
|
||||
* high the trigger can sit: on large windows (> ~220K) it governs, so
|
||||
* compaction fires at ~85% of the window and never crowds the ceiling. On
|
||||
* smaller windows the absolute "room to compress" ceiling (effectiveWindow −
|
||||
* AUTOCOMPACT_BUFFER) is lower and takes over. It also stays the small-window
|
||||
* safety net — when the window is so small the ceiling degenerates (≤ 0), the
|
||||
* proportional value keeps the trigger usable.
|
||||
* Default proportional auto-compaction threshold — the preferred trigger and an
|
||||
* upper bound on how high it can sit. See computeThresholds for how it combines
|
||||
* with the absolute ceiling (it governs large windows; the ceiling governs
|
||||
* smaller ones).
|
||||
*/
|
||||
export const DEFAULT_PCT = 0.85;
|
||||
|
||||
|
|
@ -151,18 +147,12 @@ export interface CompactionThresholds {
|
|||
* warn = max(0, auto - WARN_BUFFER)
|
||||
* hard = min(window, max(effectiveWindow - HARD_BUFFER, auto + HARD_BUFFER))
|
||||
*
|
||||
* Consequences:
|
||||
* - Large windows (> ~220K): the proportional term is the lower of the two,
|
||||
* so auto sits at ~pct of the window — generous headroom, never crowding
|
||||
* the ceiling (a 1M window compacts at ~85%, not ~97%).
|
||||
* - Small/mid windows (≤ ~220K): the ceiling is lower and governs, leaving
|
||||
* room for the summary. This matches claude-code (autoCompact.ts), whose
|
||||
* default trigger is the absolute ceiling and whose percentage override is
|
||||
* likewise combined via Math.min.
|
||||
* - Degenerate windows (≤ SUMMARY_RESERVE + AUTOCOMPACT_BUFFER, ceiling ≤ 0):
|
||||
* the proportional value is the floor so the trigger stays usable.
|
||||
*
|
||||
* `pct` defaults to DEFAULT_PCT when not provided.
|
||||
* So large windows compact at ~pct (never crowding the ceiling), smaller
|
||||
* windows compact at the ceiling (leaving room for the summary), and a window
|
||||
* too small for even the ceiling (≤ SUMMARY_RESERVE + AUTOCOMPACT_BUFFER) falls
|
||||
* back to the proportional value as a floor. This mirrors claude-code
|
||||
* (autoCompact.ts), which combines its percentage override with the absolute
|
||||
* ceiling via Math.min. `pct` defaults to DEFAULT_PCT.
|
||||
*
|
||||
* Pure function — no I/O, no shared state — safe to call repeatedly.
|
||||
*/
|
||||
|
|
@ -194,13 +184,12 @@ export function computeThresholds(
|
|||
// the same way, relative to the auto threshold).
|
||||
const warn = Math.max(0, auto - WARN_BUFFER);
|
||||
|
||||
const rawHard = effectiveWindow - HARD_BUFFER;
|
||||
// Guarantee hard >= auto so compaction doesn't wait until the last moment.
|
||||
// The `auto + HARD_BUFFER` branch keeps hard above auto on degenerate small
|
||||
// windows, where auto falls back to the proportional floor and can exceed
|
||||
// effectiveWindow - HARD_BUFFER. Clamp to the window so hard never exceeds
|
||||
// the actual limit.
|
||||
const hard = Math.min(window, Math.max(rawHard, auto + HARD_BUFFER));
|
||||
// hard is the last-ditch force-compaction point: the window edge (hardEdge),
|
||||
// but never below auto + HARD_BUFFER so it stays a distinct tier above auto on
|
||||
// degenerate small windows (where auto is the proportional floor and can
|
||||
// exceed hardEdge). Clamp to the window so hard never exceeds the actual limit.
|
||||
const hardEdge = effectiveWindow - HARD_BUFFER;
|
||||
const hard = Math.min(window, Math.max(hardEdge, auto + HARD_BUFFER));
|
||||
|
||||
return { warn, auto, hard, effectiveWindow };
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue