feat(compression): make proactive context-compression threshold a live setting - #11564
Merged
diegosouzapw merged 5 commits intoSep 2, 2026
Conversation
ragnar-claude
force-pushed
the
feat/proactive-compression-threshold-knob
branch
from
August 26, 2026 05:57
f836006 to
af38cb0
Compare
…e setting
The proactive compression trigger ratio was a hardcoded COMPRESSION_THRESHOLD =
0.7 in chatCore. Operators could not move compression relative to a client's own
compaction point (e.g. Codex Desktop self-compacts at ~0.85 of its window, so
the 0.7 proxy threshold always preempts the client's compaction with the
proxy's lossier one — see #8932 for what that produced before 3.8.50).
New: key_value namespace 'compression', key 'proactiveConfig',
{"thresholdRatio": 0.7}. Clamped [0.1, 0.99], 30s TTL cache, ipFilter
persistence pattern (#6131), synchronous read stays in the hot path. Default
unchanged; missing/invalid rows fall back to 0.7.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
ragnar-claude
force-pushed
the
feat/proactive-compression-threshold-knob
branch
from
August 26, 2026 06:02
af38cb0 to
2a9c7ac
Compare
Owner
|
Diffstat muito grande/desalinhado com o escopo do título para validação segura no fluxo de lote atual (mesmo padrão já aplicado a #11390, #11461, #11392). Adiando para uma sessão dedicada de análise no ciclo v3.8.52 — sem prejuízo do trabalho, só precisa de atenção isolada em vez de ser boarded junto com dezenas de outras PRs pequenas. |
This was referenced Aug 26, 2026
…ad, validity bounds, fallback, TTL)
Locks in getProactiveCompressionRatio() (src/lib/db/compression.ts), the
key_value-backed replacement for chatCore's hardcoded 0.7:
- shipped default 0.7 when no compression/proactiveConfig row exists
- 30s TTL cache: a fresh DB write stays invisible until the TTL lapses
(clock mocked via node:test mock timers, Date API — the module keeps
its cache private with no reset hook)
- valid override read from key_value, boundary values 0.1/0.99 included
- out-of-range ratios fall back to the DEFAULT (a validity window, not
clamping to the nearest bound — matching the shipped comment)
- broken JSON / non-numeric thresholdRatio: 0.7, without throwing
Guard verified by mutation: switching the window to clamping fails the
out-of-range case.
…tive-compression-threshold-knob
…tive-compression-threshold-knob
patrykkopycinski
added a commit
to patrykkopycinski/OmniRoute
that referenced
this pull request
Sep 6, 2026
diegosouzapw#12151 landed with a never-called collectSSE helper in stream-passthrough-usage-estimation.test.ts; its three unused identifiers (collectSSE / stream / writable) fail 'npm run lint:json -- --max-warnings 0', so the 'No new ESLint warnings' job reds every PR merge-ref cut from the current tip (first seen on PR diegosouzapw#11564's post-sync run). createSSEStream and parseSSEUsage are actually used and stay; only the dead closure goes. File suite still passes 6/6. (cherry picked from commit 3b1520b) Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
muhamadgalihsaputra
pushed a commit
to niyatna/NiyatnaRoute
that referenced
this pull request
Sep 27, 2026
…e setting (diegosouzapw#11564) * feat(compression): make proactive context-compression threshold a live setting The proactive compression trigger ratio was a hardcoded COMPRESSION_THRESHOLD = 0.7 in chatCore. Operators could not move compression relative to a client's own compaction point (e.g. Codex Desktop self-compacts at ~0.85 of its window, so the 0.7 proxy threshold always preempts the client's compaction with the proxy's lossier one — see diegosouzapw#8932 for what that produced before 3.8.50). New: key_value namespace 'compression', key 'proactiveConfig', {"thresholdRatio": 0.7}. Clamped [0.1, 0.99], 30s TTL cache, ipFilter persistence pattern (diegosouzapw#6131), synchronous read stays in the hot path. Default unchanged; missing/invalid rows fall back to 0.7. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * test(compression): cover the live proactive-compression threshold (read, validity bounds, fallback, TTL) Locks in getProactiveCompressionRatio() (src/lib/db/compression.ts), the key_value-backed replacement for chatCore's hardcoded 0.7: - shipped default 0.7 when no compression/proactiveConfig row exists - 30s TTL cache: a fresh DB write stays invisible until the TTL lapses (clock mocked via node:test mock timers, Date API — the module keeps its cache private with no reset hook) - valid override read from key_value, boundary values 0.1/0.99 included - out-of-range ratios fall back to the DEFAULT (a validity window, not clamping to the nearest bound — matching the shipped comment) - broken JSON / non-numeric thresholdRatio: 0.7, without throwing Guard verified by mutation: switching the window to clamping fails the out-of-range case. --------- Co-authored-by: root-cli (Hermes ops) <info@livewellwith.us> Co-authored-by: Claude Opus 5 <noreply@anthropic.com> Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com> Co-authored-by: Diego Rodrigues de Sa e Souza <diegosouza.pw@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The proactive compression trigger ratio is a hardcoded
COMPRESSION_THRESHOLD = 0.7in chatCore. Operators cannot move compression relative to a client's own compaction point — e.g. Codex Desktop self-compacts at ~0.85 of its window, so the 0.7 proxy threshold always preempts the client's compaction with the proxy's lossier one (see #8932 for what that produced before 3.8.50).This PR makes the ratio a live setting:
key_valuenamespacecompression, keyproactiveConfig,{"thresholdRatio": 0.7}. Clamped [0.1, 0.99], 30s TTL cache, follows the ipFilter persistence pattern (#6131) — synchronous read stays in the sync hot path. Default unchanged; missing/invalid rows fall back to 0.7.Tested: compression suite green including the #8932 regression; verified live on a production deployment (385k-token Responses request with a custom_tool_call pair compressed 385,056 → 188,039 and accepted upstream, zero orphaned calls).