You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by "Nyvo-io (via GitHub)" <gi...@apache.org> on 2026/10/07 09:40:44 UTC
[PR] fix(runtime): enable default proactive compaction [maka]
Nyvo-io opened a new pull request, #5980:
URL: https://github.com/apache/maka/pull/5980
## Summary
- resolve proactive compaction capacity at read time as `0.65 * min(contextWindow, inputLimit)` when no explicit threshold is configured
- preserve explicit positive thresholds and support `0` / `off` as an explicit opt-out
- accept percentage thresholds in provider model settings and add the same behavior to the add-model flow
- allow the explicit opt-out value through model override and catalog codecs
## Validation
- `npm --workspace @maka/core run build`
- `npm --workspace @maka/storage run build`
- `npm --workspace @maka/runtime run build`
- `npm --workspace @maka/runtime-host run build`
- `npm --workspace @maka/mcp run build`
- `npm --workspace @maka/computer-use run build`
- targeted runtime/core/desktop tests: all passing
- `git diff --check`
The full desktop typecheck remains blocked by pre-existing `@maka/ui` API mismatches (`autoScroll`, `menuAnchorRef`, `settledText`, and `trailingAction`); no errors remain in the changed desktop files.
Closes #5574
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] fix(runtime): enable default proactive compaction [maka]
Posted by "Nyvo-io (via GitHub)" <gi...@apache.org>.
Nyvo-io commented on PR #5980:
URL: https://github.com/apache/maka/pull/5980#issuecomment-6206032497
Understood. Thanks for clarifying the intended opt-in design and acknowledging the change in guidance. I am closing this PR because the default-on direction has been withdrawn. I will retain the branch for reference.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] fix(runtime): enable default proactive compaction [maka]
Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han commented on code in PR #5980:
URL: https://github.com/apache/maka/pull/5980#discussion_r4206180473
##########
apps/desktop/src/main/__tests__/context-window-input.test.ts:
##########
@@ -19,7 +19,10 @@
import assert from 'node:assert/strict';
import { test } from 'node:test';
-import { parseContextWindowInput } from '../../renderer/features/connection-settings/index.js';
+import {
+ parseCompactionThresholdInput,
+ parseContextWindowInput,
+} from '../../renderer/features/connection-settings/context-window-input.js';
Review Comment:
**P2 (CI failure).** This deep import fails the renderer architecture gate: "feature imports must use index, testing, or stories". `parseCompactionThresholdInput` is already re-exported from `connection-settings/index.ts`, so import both functions from `../../renderer/features/connection-settings/index.js` as before.
##########
packages/core/src/model-thinking.ts:
##########
@@ -241,7 +242,11 @@ function normalizeModelOverride(entry: unknown): ModelOverride | undefined {
'maxOutputTokens',
] as const) {
const value = entry[field];
- if (typeof value === 'number' && Number.isSafeInteger(value) && value > 0)
+ if (
+ typeof value === 'number' &&
+ Number.isSafeInteger(value) &&
+ (value > 0 || (field === 'compactionThreshold' && value === 0))
Review Comment:
**P2.** Once `0` survives sanitization, it reaches `buildChatModelChoices` (`chat-model-choice.ts:59`) as `declaredContextWindow: 0`. The composer then computes `declared ?? metered ?? metadata` (`composer.tsx:2681`), and `??` keeps 0, so a model set to "off" loses its usage percentage instead of falling back to the metered or metadata window. Map `0` to undefined there and add a test.
##########
packages/core/src/runtime-policy/model-catalog-entry-codec.ts:
##########
@@ -77,7 +77,7 @@ export function decodeModelCatalogEntry(value: unknown): ModelCatalogEntry {
compactionThreshold: integerValue(
item.compactionThreshold,
'compaction threshold',
- 1,
+ 0,
Review Comment:
**P2 (protocol epoch; maintainer call whether codec-range widening needs a bump).** This decoder runs on the runtime-host wire (`packages/runtime-host/src/protocol/runtime-policy.ts:718`), as does `normalizeModelOverrides` (`:640`). A peer still at epoch 205 rejects a catalog entry carrying `compactionThreshold: 0` (min 1) or drops the override. That is a non-backward-compatible change, and `protocol-epoch-check.mjs` misses it because it only watches the protocol dir. Please bump `RUNTIME_HOST_COMPATIBILITY_EPOCH` to 211 (206-210 are claimed).
##########
packages/runtime/src/context-budget-policy.ts:
##########
@@ -58,17 +60,23 @@ export function buildDefaultContextBudgetPolicy(
}
/**
- * The Maka window for the selected model: the context window the user declared,
- * resolved by core's single owner of that rule (`declaredContextWindow`), or
- * undefined when nothing is declared — and then no proactive compaction runs.
+ * The proactive compaction target for the selected model. An explicit positive
+ * declaration wins, zero disables the default, and an absent declaration uses
+ * a bounded fraction of the effective model input window.
*/
export function resolveDeclaredContextWindow(
connection: RuntimeExecutionConnection,
modelId: string | undefined,
): number | undefined {
const selectedModelId = modelId ?? connection.defaultModel;
if (selectedModelId === undefined) return undefined;
- return declaredContextWindow(connection, selectedModelId);
+ const declared = declaredContextWindow(connection, selectedModelId);
+ if (declared === 0) return undefined;
+ if (declared !== undefined) return declared;
+ const capacity = resolveSelectedModelContextWindow(connection, selectedModelId);
+ return capacity === undefined
+ ? undefined
+ : Math.max(1, Math.floor(capacity * DEFAULT_COMPACTION_THRESHOLD_RATIO));
Review Comment:
**P2.** This default becomes `midTurnState.capacity` for every model with a known window. Two consequences:
1. `context_window_overrun` (`ai-sdk-turn.ts:~1866`) and `context_window_suggestion` (`~2034`) now report it as `declaredContextWindow`, and the copy in all three locales tells the user to raise "your declared window", which they never declared.
2. The #4634 reported-window note now fires only after an explicit `off`, where its "Nothing is declared" copy is misleading.
Also consider small windows: at 8K-32K, 65% minus the reply reserve can sit below the fixed system prompt + tool schemas, so compaction may fold on almost every step. A floor or fixed-headroom rule for the default would avoid that. Tests for both would help.
##########
apps/desktop/src/renderer/settings/provider-connection-detail.tsx:
##########
@@ -718,13 +732,17 @@ function ConnectionDetailInner(props: ConnectionDetailProps) {
numericInputs={numericInputs}
onNumericInput={(field, input) => {
setEditingRow((current) => ({ ...(typeof current === 'object' && current ? current : {}), model: editingModelId, numericInputs: { ...numericInputs, [field]: input } }));
- const value = parseContextWindowInput(input);
+ const value =
+ field === 'compactionThreshold'
+ ? parseCompactionThresholdInput(input, compactionContextWindow)
Review Comment:
**P2.** The percentage is converted to tokens here, against the window at typing time. If the user then changes contextWindow or inputLimit in the same edit, the draft keeps the stale token count while the field still shows `65%`. The add-model dialog recomputes on submit; this path should too, either on save or when the effective window changes.
##########
apps/desktop/src/renderer/features/connection-settings/settings-provider-copy.ts:
##########
@@ -152,7 +152,7 @@ const enCapabilitiesCopy = {
modelLimitsConflict: 'The input limit cannot exceed the context window.',
contextWindowHelp: 'Model capacity offered by this provider. Leave empty to use known information.',
compactionThreshold: 'Compaction threshold',
- compactionThresholdHelp: 'Compact at this token count. Leave empty to disable proactive compaction.',
+ compactionThresholdHelp: 'Compact at this token count. Leave empty for the default; enter a percentage of the effective context window, or off to disable.',
Review Comment:
**P3.** "Leave empty for the default" doesn't say what the default is. Stating "65% of the effective context window" in all three locales would help. Users who left this empty under the old "disable" copy are now opted in, so the PR or release notes should point them at `off`.
##########
apps/desktop/src/renderer/features/connection-settings/context-window-input.ts:
##########
@@ -29,3 +29,20 @@ export function parseContextWindowInput(input: string): number | null {
const value = Number(match[1] + fraction.padEnd(places, '0').slice(0, places));
return Number.isSafeInteger(value) && value > 0 ? value : null;
}
+
+/** Parse a compaction target as tokens, a percentage of the effective window, or `off`. */
+export function parseCompactionThresholdInput(
+ input: string,
+ effectiveContextWindow: number | undefined,
+): number | null {
+ const normalized = input.trim().toLowerCase();
+ if (normalized === 'off' || normalized === '0') return 0;
+ if (normalized.endsWith('%')) {
+ if (effectiveContextWindow === undefined) return null;
+ const percentage = Number(normalized.slice(0, -1));
Review Comment:
**P3.** A bare `Number()` accepts `0x41%` (65%), `1e1%` and `65.%`. `0.0001%` resolves to a 1-token threshold. Also `0%`, `00` and `0k` are rejected while `0` means off (line 39). A strict decimal regex, plus treating `0%` consistently, would make this predictable. Please add these edge cases to the test.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] fix(runtime): enable default proactive compaction [maka]
Posted by "Nyvo-io (via GitHub)" <gi...@apache.org>.
Nyvo-io commented on code in PR #5980:
URL: https://github.com/apache/maka/pull/5980#discussion_r4274655064
##########
apps/desktop/src/main/__tests__/context-window-input.test.ts:
##########
@@ -19,7 +19,10 @@
import assert from 'node:assert/strict';
import { test } from 'node:test';
-import { parseContextWindowInput } from '../../renderer/features/connection-settings/index.js';
+import {
+ parseCompactionThresholdInput,
+ parseContextWindowInput,
+} from '../../renderer/features/connection-settings/context-window-input.js';
Review Comment:
Fixed in 9ec9c30d4: restored both imports through the feature index. The strict renderer architecture check against current main now passes; the settings/parser suites pass as well.
##########
packages/core/src/runtime-policy/model-catalog-entry-codec.ts:
##########
@@ -77,7 +77,7 @@ export function decodeModelCatalogEntry(value: unknown): ModelCatalogEntry {
compactionThreshold: integerValue(
item.compactionThreshold,
'compaction threshold',
- 1,
+ 0,
Review Comment:
Confirmed that zero widens the wire contract. Rebased onto main (epoch 222) and bumped to 223, with a compatibility comment and zero round-trip coverage for overrides and catalog entries. The epoch guard verifies 222 -> 223; handshake/policy suites pass. The earlier suggestion of 211 is no longer current.
##########
packages/core/src/model-thinking.ts:
##########
@@ -241,7 +242,11 @@ function normalizeModelOverride(entry: unknown): ModelOverride | undefined {
'maxOutputTokens',
] as const) {
const value = entry[field];
- if (typeof value === 'number' && Number.isSafeInteger(value) && value > 0)
+ if (
+ typeof value === 'number' &&
+ Number.isSafeInteger(value) &&
+ (value > 0 || (field === 'compactionThreshold' && value === 0))
Review Comment:
Reproduced with a failing chat-model-choice regression. Fixed at the projection owner: only positive thresholds become declaredContextWindow, so the zero opt-out preserves metadata/meter fallback. The core suite passes.
##########
packages/runtime/src/context-budget-policy.ts:
##########
@@ -58,17 +60,23 @@ export function buildDefaultContextBudgetPolicy(
}
/**
- * The Maka window for the selected model: the context window the user declared,
- * resolved by core's single owner of that rule (`declaredContextWindow`), or
- * undefined when nothing is declared — and then no proactive compaction runs.
+ * The proactive compaction target for the selected model. An explicit positive
+ * declaration wins, zero disables the default, and an absent declaration uses
+ * a bounded fraction of the effective model input window.
*/
export function resolveDeclaredContextWindow(
connection: RuntimeExecutionConnection,
modelId: string | undefined,
): number | undefined {
const selectedModelId = modelId ?? connection.defaultModel;
if (selectedModelId === undefined) return undefined;
- return declaredContextWindow(connection, selectedModelId);
+ const declared = declaredContextWindow(connection, selectedModelId);
+ if (declared === 0) return undefined;
+ if (declared !== undefined) return declared;
+ const capacity = resolveSelectedModelContextWindow(connection, selectedModelId);
+ return capacity === undefined
+ ? undefined
+ : Math.max(1, Math.floor(capacity * DEFAULT_COMPACTION_THRESHOLD_RATIO));
Review Comment:
Fixed the misleading notes in all three locales: they now describe the effective compaction threshold, not a user-declared model window. The inactive-proactive-compaction note no longer says that no declaration disables the default. Added default overrun/overflow-suggestion integration coverage, explicit-off reported-window coverage, and localized copy tests. I have not added a small-window floor: that would change the agreed 65% policy without a measured fixed-input budget or reproducer. The existing reserve is measured from the last reply (capped at 8K), and existing per-step/failure guards are unchanged. Leaving this thread open for the remaining policy discussion.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] fix(runtime): enable default proactive compaction [maka]
Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han commented on PR #5980:
URL: https://github.com/apache/maka/pull/5980#issuecomment-6203906802
> **Automated notice:** Posted by an automated agent at @Astro-Han's request.
Thank you @Nyvo-io for the careful work here. You implemented exactly the scope I suggested in #5574, and the follow-up fixes were solid.
That direction was my mistake, and I have retracted it on the issue. Proactive compaction is opt-in by design (#4653): model metadata is a hint, not a threshold. The failure in the report, a model degrading below the window its provider advertises, is a provider-side gap that we don't want to cover with a default fraction applied to every connection.
So I recommend closing this PR rather than reworking it. Sorry for the wasted effort, which came from my guidance and not from your implementation.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] fix(runtime): enable default proactive compaction [maka]
Posted by "Nyvo-io (via GitHub)" <gi...@apache.org>.
Nyvo-io commented on code in PR #5980:
URL: https://github.com/apache/maka/pull/5980#discussion_r4274657668
##########
apps/desktop/src/renderer/features/connection-settings/context-window-input.ts:
##########
@@ -29,3 +29,20 @@ export function parseContextWindowInput(input: string): number | null {
const value = Number(match[1] + fraction.padEnd(places, '0').slice(0, places));
return Number.isSafeInteger(value) && value > 0 ? value : null;
}
+
+/** Parse a compaction target as tokens, a percentage of the effective window, or `off`. */
+export function parseCompactionThresholdInput(
+ input: string,
+ effectiveContextWindow: number | undefined,
+): number | null {
+ const normalized = input.trim().toLowerCase();
+ if (normalized === 'off' || normalized === '0') return 0;
+ if (normalized.endsWith('%')) {
+ if (effectiveContextWindow === undefined) return null;
+ const percentage = Number(normalized.slice(0, -1));
Review Comment:
Reproduced the hexadecimal coercion, then replaced percentage coercion with strict decimal syntax. Hex, exponents, trailing decimal points and out-of-range percentages are rejected; 0%, 00, 0k, 0.0M and off consistently disable without requiring capacity metadata. Added edge-case regressions. Positive percentages still round to integer tokens, matching explicit positive token thresholds; no new minimum-threshold policy is introduced.
##########
apps/desktop/src/renderer/settings/provider-connection-detail.tsx:
##########
@@ -718,13 +732,17 @@ function ConnectionDetailInner(props: ConnectionDetailProps) {
numericInputs={numericInputs}
onNumericInput={(field, input) => {
setEditingRow((current) => ({ ...(typeof current === 'object' && current ? current : {}), model: editingModelId, numericInputs: { ...numericInputs, [field]: input } }));
- const value = parseContextWindowInput(input);
+ const value =
+ field === 'compactionThreshold'
+ ? parseCompactionThresholdInput(input, compactionContextWindow)
Review Comment:
Reproduced through the real settings dialog and bridge: typing 65% at 100K, then changing the window to 200K, previously saved 65K. The detail dialog now reparses at submit against the final effective window and passes the value atomically into the existing save/CAS path. The regression now saves 130K; the full Desktop typecheck and settings suite pass.
##########
apps/desktop/src/renderer/features/connection-settings/settings-provider-copy.ts:
##########
@@ -152,7 +152,7 @@ const enCapabilitiesCopy = {
modelLimitsConflict: 'The input limit cannot exceed the context window.',
contextWindowHelp: 'Model capacity offered by this provider. Leave empty to use known information.',
compactionThreshold: 'Compaction threshold',
- compactionThresholdHelp: 'Compact at this token count. Leave empty to disable proactive compaction.',
+ compactionThresholdHelp: 'Compact at this token count. Leave empty for the default; enter a percentage of the effective context window, or off to disable.',
Review Comment:
Updated all three locale help strings to state the 65% effective-window default, off/0 opt-out, and conversion of percentages to absolute tokens at save time. Added a changelog upgrade note explaining the empty-field semantic change and preservation of explicit/migrated values.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] fix(runtime): enable default proactive compaction [maka]
Posted by "Nyvo-io (via GitHub)" <gi...@apache.org>.
Nyvo-io closed pull request #5980: fix(runtime): enable default proactive compaction
URL: https://github.com/apache/maka/pull/5980
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org