Repository navigation
fix: use shared auto-compact threshold constants - #1193
will-lamerton merged 4 commits into
Conversation
will-lamerton
left a comment
There was a problem hiding this comment.
Thanks for picking this up. The auto-compact.ts change is correct, and the tests are still honest because message-compression.spec.ts pins the literal 50/95 values.
One thing before merge: a third copy of the same clamp survives. source/config/index.ts:
// Validate and clamp threshold to valid range (50-95)
function validateThreshold(threshold: unknown): number {
const num = typeof threshold === 'number' ? threshold : 60;
return Math.max(50, Math.min(95, Math.round(num)));
}That is the nanocoder.tune.threshold config path, so the drift #1137 describes still exists: change the constants and agents.config.json clamps differently from /context-max. Please import COMPRESSION_CONSTANTS there too and drop the stale range from the comment.
Optional: exporting a small clampThreshold(value) from message-compression.ts and using it in both call sites would make the single source of truth structural rather than by convention.
Also please run pnpm changeset --empty to clear the changeset bot comment, since this is behaviour-neutral.
|
Hey @will-lamerton, thanks for catching that. I’ve pushed the update in 0d03189. Whenever you have a moment, I’d appreciate another look. |
Export clampThreshold/isThresholdInRange from message-compression so the 50-95 bounds are enforced in one place rather than copied. The remaining literal copies were the settings panel validator and /compact --threshold, both of which would have rejected values the config and session paths accept once the constants change. Also tidies the empty changeset and sorts an import in write-file.tsx that biome check flags on main.
will-lamerton
left a comment
There was a problem hiding this comment.
Thanks for the follow-up - the config path is fixed as asked.
I pushed two commits on top: a merge of main to clear the conflict in source/config/index.ts (it was just an adjacent import line), and the structural version of the optional suggestion. clampThreshold/isThresholdInRange now live in message-compression.ts and every entry point calls them.
That last part mattered more than it looked - two more literal copies of the 50/95 bounds survived beyond the one I flagged: the settings panel validator in settings-auto-compact.tsx and --threshold in compact-handler.ts. Both would have rejected values the config and session paths accept once the constants move, which is the same bug #1137 describes. Added clamp coverage to message-compression.spec.ts too.
One unrelated thing rolled in: biome check fails on write-file.tsx on current main (unsorted import), so that one-line reorder is in here to get CI green.
Full suite passes.
Summary
COMPRESSION_CONSTANTSas the single source of truth for auto-compact threshold clamping.Closes #1137
Validation
pnpm test:all: blocked by intermittent Corepack/pnpm signing-key verification.