fix: case-insensitive model family matching + compressor init logging

Two fixes for local model context detection:

1. Hardcoded DEFAULT_CONTEXT_LENGTHS matching was case-sensitive.
   'qwen' didn't match 'Qwen3.5-9B-Q4_K_M.gguf' because of the
   capital Q. Now uses model.lower() for comparison.

2. Added compressor initialization logging showing the detected
   context_length, threshold, model, provider, and base_url.
   This makes turn-1 compression bugs diagnosable from logs —
   previously there was no log of what context length was detected.
This commit is contained in:
Teknium 2026-03-21 10:47:44 -07:00
parent 29520df44f
commit 292d12bed4
No known key found for this signature in database
2 changed files with 10 additions and 1 deletions

View file

@ -855,10 +855,11 @@ def get_model_context_length(
# Only check `default_model in model` (is the key a substring of the input).
# The reverse (`model in default_model`) causes shorter names like
# "claude-sonnet-4" to incorrectly match "claude-sonnet-4-6" and return 1M.
model_lower = model.lower()
for default_model, length in sorted(
DEFAULT_CONTEXT_LENGTHS.items(), key=lambda x: len(x[0]), reverse=True
):
if default_model in model:
if default_model in model_lower:
return length
# 9. Query local server as last resort