BerriAI/litellm · error · ProxyException
context_window_size must be non-negative
Error message
context_window_size must be non-negative
What it means
Range guard on the auto-router classifier default-prompt endpoint: the context_window_size query parameter was negative. It feeds the classifier prompt's sizing, so only non-negative values are accepted.
Source
Thrown at litellm/proxy/management_endpoints/model_management_endpoints.py:2244
) -> AutoRouterClassifierDefaultPromptResponse:
"""
Get the default classifier system prompt, so the dashboard's prompt editor can prefill it.
The prompt's closing line depends on whether prior conversation turns are quoted to the
classifier, its tier bullets are named by the router's tier_labels, and its calibration examples
come from the router's classification rubric, so the caller passes all three to get the text that router
would actually send rather than a rubric it does not use.
Parameters:
- context_window_size: int - The router's classifier_context_window_size. Defaults to the
built-in default.
- tier_labels: str | None - The router's tier_labels as a JSON object of canonical tier name to
display name, e.g. `{"SIMPLE": "Cheap"}`. Omit or pass an empty object for the default names.
- classification_rubric: ClassificationRubric | None - The router's
classifier_llm_config.classification_rubric. Omit for the default.
"""
if context_window_size < 0:
raise ProxyException(
message="context_window_size must be non-negative",
type=ProxyErrorTypes.bad_request_error,
code=status.HTTP_400_BAD_REQUEST,
param="context_window_size",
)
labeled_tiers: Final = _labeled_tiers_from_query(tier_labels)
return AutoRouterClassifierDefaultPromptResponse(
system_prompt=(
classification_system_prompt(context_window_size, classification_rubric=classification_rubric)
if labeled_tiers is None
else classification_system_prompt(
context_window_size, labeled_tiers=labeled_tiers, classification_rubric=classification_rubric
)
)
)
View on GitHub (pinned to 77b7c6c40c)
Solutions
- Set context_window_size to a non-negative integer.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at litellm/proxy/management_endpoints/model_management_endpoints.py:2244 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/df11238923e5c21c.
Report an issue: GitHub.