mirror of
https://github.com/headroomlabs-ai/headroom.git
synced 2026-12-03 18:39:57 +08:00
feat/https-compose-caddy
1
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
3544cf5b88 |
fix(proxy): keep cold-turn reasoning drops sticky so the next warm turn reuses the cached prefix (#4592)
## Description With `HEADROOM_THINKING_COMPACT=1`, a cold turn drops old reasoning outright and caches that prefix, but the next warm turn recomputes from the client's full history and Kompresses those same turns instead, so the forwarded prefix no longer matches what was cached and every turn after a cold one misses. Closes #4548 ## Type of Change - [x] Bug fix (non-breaking change that fixes an issue) ## Changes Made - `compact_reasoning_openai_chat` gains `drop_first_turns`: the first N assistant turns (excluding kept last turns) take the drop path even when warm; stats report `dropped_upto`. - `PrefixCacheTracker.reasoning_drop_upto` stores the per-session sticky floor; a cold turn raises it, never lowers it. - OpenAI chat handler passes the floor in and records it after a cold turn; sticky drop runs even without a Kompress model. - New `tests/test_thinking_compact_sticky_drop.py` (fails on `main`, passes with fix). ## Testing - [x] Unit tests added and passing ``` $ python -m pytest tests/test_thinking_compact_sticky_drop.py tests/test_thinking_compactor_version_gate.py tests/test_cold_prefix.py -q 23 passed in 3.31s $ ruff check <changed files> -> All checks passed! # without the fix: 4 failed (new test file) ``` ## Real Behavior Proof - Environment: Windows 11, Python 3.12, local checkout rebased on upstream/main - Exact command / steps: ran the compactor on a 3-turn history with drop=True (cold), then on the 4-turn follow-up with drop=False and drop_first_turns from the cold stats - Observed result: the first two assistant messages in the warm output are byte-identical to the cold output; the newer turn is Kompressed, the active turn kept - Not tested: a live Kimi/GLM upstream cache-hit measurement through the proxy ## Runtime Rollout Safety - Rollout-managed feature(s): none; only affects the opt-in HEADROOM_THINKING_COMPACT path - Minimum rollout channel: n/a - Stable/default behavior changed: no (feature off by default) - Kill switch / disable path: unset HEADROOM_THINKING_COMPACT - Unsafe override required: no - Qualification impact: none - Rollback path: revert this commit ## Review Readiness - [x] I have performed a self-review - [x] This PR is ready for human review 🤖 Generated with [Claude Code](https://claude.com/claude-code) ### Maintainer current-main requalification Exact head `5f7f8be6fabe7e5a0ab33b3c12995d730e071d72`, upstream main `2d3ee51846435ef5b320eea4806af14e602b0d8c`. Re-reviewed contributor head |