Repository navigation
LCORE-4765: Resolve compaction context window from provider catalog metadata - #2993
Merged
tisnik merged 3 commits intoOct 23, 2026
Conversation
The compaction trigger took a model's context window only from the inference.context_windows map. A model missing from the map never compacted, and the per-model setting the provider catalog already validates, allowed_models[].metadata.context_window, was not used. The new utils.context_window.resolve_context_window returns, in order: metadata.context_window on the model's allowed_models entry (matched by name, then by provider_model_id), the inference.context_windows map, the model data bundled with genai-prices when it knows the provider and the model, and DEFAULT_CONTEXT_WINDOW (128000). The configured tiers come first, so a window an operator sets wins over the vendor maximum. The result is always an int, so conversation_compaction no longer has a branch for a model without a window: with compaction enabled, such a model now compacts against the 128000 default instead of never. get_context_window is removed from token_estimator. genai-prices is declared as a direct dependency; it was already installed through pydantic-ai-slim. The integration helper sets the window as catalog metadata. The e2e fixtures keep the map and the same windows; only a comment and a step docstring change. Unit tests cover every tier, the name and provider_model_id matching, the split of the model id at the first "/", and the default.
An allowed_models entry written as a mapping (name, provider_model_id, metadata), which is where metadata.context_window lives, made unified OGX synthesis fail with "TypeError: unhashable type: 'dict'" in _register_high_level_models. Plain string entries worked. Synthesis now reads both forms. The OGX provider's allowed_models lists the backend ids (provider_model_id), which is what OGX filters on, and each model is registered under its name with that provider_model_id. A parametrized synthesis test covers a string entry, a mapping entry and an aliased mapping entry.
…metadata The per-model context window now belongs on the model's allowed_models entry, as metadata.context_window. The top-level inference.context_windows map shipped in releases, so it is deprecated rather than removed: it keeps working as a fallback tier through the deprecation phase. The configuration schema describes the field as deprecated, and the service logs one DEPRECATED warning at startup when the map is not empty, with a link to the user documentation. The compaction user guide gains a "Context window" section, docs/migrations/v0.8.0.md explains how to move each entry and when to keep the map for now, and the generated configuration and OpenAPI documents carry the new descriptions. A unit test covers the startup warning: logged for a non-empty map, not logged for an empty or missing one.
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 56 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This was referenced Oct 23, 2026
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.
Description
Conversation compaction now resolves a model's context window in
src/utils/context_window.py, taking the first of:metadata.context_windowon the model'sinference.providers[].allowed_modelsentry, theinference.context_windowsmap, the windowgenai-priceslists for the provider and model, and 128,000 tokens (DEFAULT_CONTEXT_WINDOW). The map comes beforegenai-pricesso a configured window beats the vendor maximum.inference.context_windowsis deprecated, not removed or rejected: it still works and, when set, logs aDEPRECATEDwarning at startup. The project deprecates a configuration key for at least one minor release before removing it, and the map shipped in 0.6 and 0.7. Removing it is left to a follow-up once the deprecation has shipped.<provider id>/<model name>: Nkey tometadata.context_window: Non that model'sallowed_modelsentry. The newdocs/migrations/v0.8.0.mdand the "Context window" section of the compaction user doc say how, and when to keep the map for now: for a provider not yet declared underinference.providers(adding an entry changes the generated OGX configuration) and for legacy two-file configurations.src/utils/conversation_compaction.py) uses the new resolver, andget_context_windowis gone fromtoken_estimator.py. Every configuration in the repository that sets the map keeps the same windows.threshold_ratioof itsgenai-priceswindow, or of 128K whengenai-pricesdoes not know it.allowed_modelsentries (name/provider_model_id/metadata). Before, it failed withTypeError: unhashable type: 'dict', which blocked the migration target in unified mode.genai-prices>=0.1.12is now a direct dependency. It was already locked throughpydantic-ai-slimand pinned for Konflux, so nothing new is installed.get_catalog_context_windowis the switch point), the pydantic-ai compaction path (LCORE-4764), and removing the map.pyproject.tomlanduv.lock+4.Type of change
pyproject.toml+uv.lock]requirements.*.txtfor Konflux]Tools used to create PR
Identify any AI code assistants used in this PR (for transparency and review context)
Related Tickets & Documents
Checklist before requesting a review
Testing
uv run pytest tests/unit/utils/test_context_window.py tests/unit/utils/test_conversation_compaction.py tests/unit/utils/test_token_estimator.py tests/unit/test_lightspeed_stack.py tests/unit/test_ogx_synthesize.py: 182 passed.uv run pytest tests/integration/endpoints/test_compaction_*.py: 40 passed; the helper now sets the window asmetadata.context_windowon a vLLM provider entry.uv run pytest tests/unit: 3868 passed, 1 skipped. The branch adds 27 test cases and removes 5 in the touched files.uv run pytest tests/integration --ignore=tests/integration/container_lifecycle: 326 passed.uv run make format(no changes) and the linters: black, ruff, pydocstyle, pylint and pyright pass. mypy reports the same errors as on the base (1 insrc, 49 intests) and nothing new.tests/e2e/configuration/{server,library}-mode/lightspeed-stack-compaction{,-disabled}.yaml) withAppConfig.load_configurationon the base and on this branch, and resolve each window (get_context_windowon the base,resolve_context_windowhere): all five map keys give 2000 on both, and unlisted models (for examplevllm/unknown-model) go from no window to 128000. The documentation snippets, including the migration guide's before/after pair, resolve to the same windows. With an empty configuration,openai/gpt-4.1gets 1000000 fromgenai-pricesandvllm/granite-3.3-8b-instructgets the 128000 default.uv run python src/lightspeed_stack.py -c tests/e2e/configuration/server-mode/lightspeed-stack-compaction.yaml -dwithE2E_OGX_HOSTNAMEandFAISS_VECTOR_STORE_IDset: it exits 0, writesconfiguration.jsonto the current directory and logs theDEPRECATED: inference.context_windows ...warning.apply_high_level_inference) on avllmprovider whoseallowed_modelshas a dictionary entry: on the base it raisesTypeError: unhashable type: 'dict'; here the OGX allow-list gets theprovider_model_idand the model is registered under itsname.Not run: the e2e compaction feature and a live library-mode start with a structured
allowed_modelsentry; both need the full stack.