mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-30 01:08:33 +00:00
* fix(router): retry a context window error on a deployment serving another model A model group can admit a prompt on a deployment whose cost-map window is wider than what the provider account allows. The upstream answers 400 ContextWindowExceededError and the router raised it at once, even though a sibling deployment in the same group could serve the prompt, unless context_window_fallbacks was set. Without a retry policy, the router now retries that error on a healthy sibling that serves a different model (base_model, else model), skipping every deployment that serves the refused model, and stops when none is left. A context window error the router raised itself before any call is still not retried, context_window_fallbacks still take over, and an explicit retry policy keeps its behavior. The stream retry path does the same. * fix(router): keep the context window retry inside the deployments the router would pick Count the deployments left to try with the same pick filters the router uses (order, pinning, tags, pre-call checks), resolve the refused model from wildcard copies, only let a matching context_window_fallbacks chain skip the retry, and hand the original context window error to the caller and fallbacks when the retries fail for another reason. * fix(router): answer a context window error when the request num_retries cannot be read A request num_retries the retry loop cannot compare raised the loop's TypeError as a 500 once a context window error became retryable. Hand the context window error on instead, as the request got before. * fix(router): keep a guardrail block raised on a context window retry A guardrail that blocks the retry now ends the call with its own error instead of the saved context window error, so no fallback runs past it. The two-deployment retry test now expects the context window error to reach the second deployment, which serves another model. * fix(router): retry a context window error in the group only with pre-call checks and raise the refusal The in-group retry after a context window error now runs only when enable_pre_call_checks is on, and never on a call by deployment id. Every deployment serving the refused model stays out of later picks in the call, a failed retry raises the refused attempt's own error, a stream keeps retrying past each refusing model, the siblings come from the group a pre-routing hook picked, and a context window error that first shows up on a later retry is kept. Router.should_retry_this_error raises a context window error as on main * fix(router): read one model under two names as one model and retry a copy that declares a bigger window A context window retry now compares the served model by its last path segment with Bedrock region profiles read as their base model, so us. and global. profiles of one model are skipped together. A copy of the refused model is still retried when both pre-call windows are known and the copy's is bigger * fix(router): keep a cooled-down deployment's window for the context window retry A deployment that cools down on its 400 drops out of the pre-call facts, so its window read as unknown and every copy of the same model was skipped, the copy declaring a bigger window included. The window now comes from the deployment's record when the facts no longer carry it. The refusal also skips its candidate pass when pre-call checks are off, since no retry can follow it there. * style(router): format the context window callback filter test with rustfmt * fix(router): keep refused deployments when a stream retry takes over A stream that a retry opened and that breaks before content now carries the deployments the request already refused, and the provider's window refusal, into the retry or fallback that takes it over * test(router): mark the stream refusal take-over test with rstest --------- Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com> |
||
|---|---|---|
| .. | ||
| __init__.py | ||
| conftest.py | ||
| construction_precall_helpers.py | ||
| endpoints_helpers.py | ||
| fallbacks_helpers.py | ||
| gaps_l11100_helpers.py | ||
| registry_helpers.py | ||
| retries_health_helpers.py | ||
| rust_parity_pending.txt | ||
| scripted_host.py | ||
| selection_helpers.py | ||
| streaming_helpers.py | ||
| test_callback_filters_step.py | ||
| test_callback_filters_v2_dispatch.py | ||
| test_construction_precall_characterization.py | ||
| test_construction_precall_characterization_precall.py | ||
| test_deprecated_members.py | ||
| test_endpoints.py | ||
| test_endpoints_characterization_batch.py | ||
| test_endpoints_characterization_generic.py | ||
| test_endpoints_characterization_inference.py | ||
| test_fallbacks.py | ||
| test_fallbacks_characterization.py | ||
| test_fallbacks_characterization_outcomes.py | ||
| test_fallbacks_characterization_refusal.py | ||
| test_fallbacks_walk_parity.py | ||
| test_gaps_adapter_timeout.py | ||
| test_gaps_fuzz_access.py | ||
| test_gaps_l0001.py | ||
| test_gaps_l2800.py | ||
| test_gaps_l2800_streaming.py | ||
| test_gaps_l5600.py | ||
| test_gaps_l5600_anthropic.py | ||
| test_gaps_l8400_precall.py | ||
| test_gaps_l8400_pricing.py | ||
| test_gaps_l8400_retries.py | ||
| test_gaps_l11100_registry.py | ||
| test_gaps_l11100_strategy.py | ||
| test_gaps_l14000.py | ||
| test_gaps_l14000_selection.py | ||
| test_gaps_pick_input_and_compaction.py | ||
| test_gaps_request_overrides.py | ||
| test_gaps_router_core_crate.py | ||
| test_gaps_router_core_crate_picks.py | ||
| test_health_registry_views.py | ||
| test_host_settings_changes_characterization.py | ||
| test_legacy_members.py | ||
| test_parity_cooldown_service_model.py | ||
| test_parity_decisions_routing.py | ||
| test_parity_failure_logging.py | ||
| test_parity_malformed_after_rate_limit.py | ||
| test_parity_pick_count_and_fallback_log.py | ||
| test_parity_provider_scoped_fallbacks.py | ||
| test_parity_regress5.py | ||
| test_parity_regress5_errors.py | ||
| test_parity_regress5_settings.py | ||
| test_parity_regress5_streams.py | ||
| test_parity_response_headers.py | ||
| test_parity_rulings_2026_11.py | ||
| test_registry_changesets.py | ||
| test_registry_characterization_construction.py | ||
| test_registry_characterization_lookups.py | ||
| test_registry_characterization_model_info.py | ||
| test_registry_characterization_writes.py | ||
| test_request_scoped_outcomes.py | ||
| test_retries_cooldowns.py | ||
| test_retries_health_characterization_cooldowns.py | ||
| test_retries_health_characterization_failure_exits.py | ||
| test_retries_health_characterization_retries.py | ||
| test_selection.py | ||
| test_selection_characterization_groups.py | ||
| test_selection_characterization_prerouting.py | ||
| test_selection_characterization_session_repin.py | ||
| test_selection_characterization_strategies.py | ||
| test_selection_characterization_traffic.py | ||
| test_streaming_characterization_anthropic.py | ||
| test_streaming_characterization_chat.py | ||
| test_streaming_characterization_outcomes.py | ||
| test_streaming_characterization_responses.py | ||
| test_usage_and_failure_counting_parity.py | ||