fix(compression): respect user-configured threshold below 0.50 on small-ctx models - #66249
fix(compression): respect user-configured threshold below 0.50 on small-ctx models#66249AlexFucuson9 wants to merge 2 commits into
Conversation
The Codex/OpenAI backend rejects prompt_cache_key > 64 chars with HTTP 400 BadRequestError. When _content_cache_key falls back to session_id (no static instructions+tools to hash), the key can be arbitrarily long (e.g. paperclip:company:<uuid>:agent:<uuid> at 97 chars). The 400 is masked by the fallback chain, making the primary provider look unused. Fix: after computing cache_key, hash it to pck_<sha256[:24]> when it exceeds 64 chars. hashlib is already imported. The xAI extra_body path also benefits since it reads the same cache_key variable. Closes NousResearch#66045
…ll-ctx models The small-context threshold floor (_SMALL_CTX_THRESHOLD_PERCENT = 0.75) raises any model under 512K context to at least 75% threshold. This is a safety net to prevent thrashing on 128K-262K models at the default 50% trigger. But when a user explicitly sets threshold: 0.3 (30%) to stay within TPM rate limits (e.g. 100K TPM on a 160K-ctx reasoning model), the floor overrides their config to 75% (120K tokens). Compression never fires, context grows to 55K+, and every API call exceeds the 100K TPM budget — cascading 429 errors. Fix: only apply the 75% floor when the configured threshold is at or above the default (0.50). A value below 0.50 signals deliberate user configuration — respect it. Closes NousResearch#66177
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: Approved (comment only — token read-only)
Clean, well-scoped fix. The logic change is correct — applying the compression threshold floor only when the configured value looks like the default (>= 0.50) preserves intentional user configuration. Documentation clearly explains the rationale.
Reviewed by Hermes Agent
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: Approved (LGTM)
Overview
Respects user-configured threshold below 0.50 on small-ctx models for compression. +18/0.
Security
- No hardcoded secrets or credentials
Code Quality
- Clean threshold handling
Looks Good
- Minimal feature fix
Reviewed by Hermes Agent
|
Thanks for identifying the configured-threshold case. The compression premise is still present on current main: Problems
Suggested changes
Automated hermes-sweeper review. |
Problem
The small-context threshold floor (
_SMALL_CTX_THRESHOLD_PERCENT = 0.75) forces any model under 512K context to compress at ≥75% of the window. This overrides explicit user configuration likethreshold: 0.3(30%).For a 160K-ctx model with 100K TPM rate limits:
threshold: 0.3→ expects compression at 48K tokensFix
Only apply the 75% floor when the configured threshold is at or above the default (0.50). A value below 0.50 signals deliberate user configuration — respect it.
The floor still protects default-config users (0.50 → raised to 75% on small-ctx models) while allowing power users to compress earlier for rate-limit compliance.
1 file, 12 lines added, 1 line changed.
Closes #66177