Skip to content

feat(compression): config-driven per-model threshold - #25

Merged
Kyzcreig merged 1 commit into
mainfrom
feat/per-model-compression-threshold
Jun 9, 2026
Merged

Kyzcreig merged 1 commit into
mainfrom
feat/per-model-compression-threshold

Conversation

@Kyzcreig

@Kyzcreig Kyzcreig commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

What

Surfaces the already-wired per-model compression-threshold override as a config knob. Adds an optional compression.per_model_threshold map so a model's compression trigger fraction can be tuned in config.yaml without editing Python.

compression:
  threshold: 0.8                 # global default (unchanged)
  per_model_threshold:           # NEW — optional, fraction in (0,1]
    claude-opus-4-8: 0.85
    gpt-5.5: 0.7

Why

The per-model override path already existed (_compression_threshold_for_model in auxiliary_client.py, applied in agent_init.py) but was hardcoded — only arcee-trinity-thinking → 0.75. Threshold is a direct cost lever (higher = bigger/costlier requests, fewer summarization calls; lower = cheaper turns, more summarization passes), so it should be config-tunable per model.

Resolution order (first hit wins)

  1. compression.per_model_threshold[model] — config map (new)
  2. _compression_threshold_for_model(model) — built-in family default
  3. compression.threshold — global config
  4. 0.50 — hardcoded default

The absolute trigger stays model-aware regardless: threshold_tokens = context_length × threshold, re-derived on every /model switch in ContextCompressor.update_model.

Implementation

  • New _resolve_per_model_threshold(per_model, model) helper in agent/agent_init.py: exact-match then case-insensitive; accepts (0, 1] only; ignores out-of-range / non-numeric / non-dict / bad-model input (returns None + warns) so resolution falls through safely.
  • Wired into the existing threshold-resolution block; built-in default kept as fallback (config wins).

Tests

28 new tests in tests/agent/test_per_model_compression_threshold.py (exact/case-insensitive match, boundary values, out-of-range, non-numeric, numeric-string coercion, empty/non-dict map, invalid model, non-string keys). 45/45 pass with the existing arcee override suite; ruff clean.

Notes

  • No behavior change unless per_model_threshold is set.
  • Requires gateway restart to load (import-time).

Surface the existing per-model compression-threshold override as a config
knob. New optional compression.per_model_threshold map (model-id ->
fraction in (0,1]) takes precedence over the built-in
_compression_threshold_for_model default and the global
compression.threshold.

Resolution order (first hit wins):
  1. compression.per_model_threshold[model]  (config map, new)
  2. _compression_threshold_for_model(model) (built-in family default)
  3. compression.threshold                   (global config)
  4. 0.50                                     (hardcoded default)

New _resolve_per_model_threshold() helper: exact then case-insensitive
match, accepts (0,1] only, ignores out-of-range/non-numeric with a warning
so resolution falls through safely. The absolute trigger stays model-aware
(context_length * threshold, re-derived on every model switch).

28 new tests; ruff clean.
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

🔎 Lint report: feat/per-model-compression-threshold vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 9955 on HEAD, 9954 on base (🆕 +1)

🆕 New issues (1):

Rule Count
unresolved-import 1
First entries
tests/agent/test_per_model_compression_threshold.py:17: [unresolved-import] unresolved-import: Cannot resolve imported module `pytest`

✅ Fixed issues: none

Unchanged: 5158 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@Kyzcreig
Kyzcreig merged commit 54fec9b into main Jun 9, 2026
23 checks passed
@Kyzcreig
Kyzcreig deleted the feat/per-model-compression-threshold branch June 9, 2026 13:45
@Kyzcreig
Kyzcreig restored the feat/per-model-compression-threshold branch September 21, 2026 10:32
Kyzcreig pushed a commit that referenced this pull request Sep 28, 2026
ang-fleet-workers Bot added a commit that referenced this pull request Sep 28, 2026
ang-fleet-workers Bot added a commit that referenced this pull request Sep 28, 2026
ang-fleet-workers Bot pushed a commit that referenced this pull request Oct 4, 2026
Moves the floor `uses:` pin to debd27598fa6 (fleet-floor-workflows#26 merge
commit). #26 keys the floor concurrency group per-ref and cancels only on
pull_request; every other event (push:main backstop) gets a per-run group,
so a newer push no longer cancels or replaces it.

Diff old pin -> debd275 for the called workflow file: concurrency block +
a caller-paths comment only. Inputs and defaults unchanged; the scanner is
embedded in the workflow, so scanner bytes are identical. The other files
changed since the old pin (#22-#25: python-ci/js-ci inputs, steps-mode
actions, README, tests) are not called by this workflow.

Card t_ca5322d9.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant