From 89458573a2326cb31349c114e3a251616caa2fa5 Mon Sep 17 00:00:00 2001 From: Boxuan Li Date: Mon, 1 Dec 2025 20:02:59 -0800 Subject: [PATCH] Add context window exception mapping for Together AI (#17284) --- litellm/litellm_core_utils/exception_mapping_utils.py | 1 + .../litellm_core_utils/test_exception_mapping_utils.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/litellm/litellm_core_utils/exception_mapping_utils.py b/litellm/litellm_core_utils/exception_mapping_utils.py index f8c786daef3..056522e2a64 100644 --- a/litellm/litellm_core_utils/exception_mapping_utils.py +++ b/litellm/litellm_core_utils/exception_mapping_utils.py @@ -77,6 +77,7 @@ class ExceptionCheckers: "model's maximum context limit", "is longer than the model's context length", "input tokens exceed the configured limit", + "`inputs` tokens + `max_new_tokens` must be", ] for substring in known_exception_substrings: if substring in _error_str_lowercase: diff --git a/tests/test_litellm/litellm_core_utils/test_exception_mapping_utils.py b/tests/test_litellm/litellm_core_utils/test_exception_mapping_utils.py index d7da7592870..d59e52d965e 100644 --- a/tests/test_litellm/litellm_core_utils/test_exception_mapping_utils.py +++ b/tests/test_litellm/litellm_core_utils/test_exception_mapping_utils.py @@ -36,6 +36,10 @@ context_window_test_cases = [ "Input tokens exceed the configured limit of 272000 tokens. Your messages resulted in 509178 tokens. Please reduce the length of the messages.", True, ), + ( + "`inputs` tokens + `max_new_tokens` must be <= 4096", + True, + ), # Test case insensitivity ("ERROR: THIS MODEL'S MAXIMUM CONTEXT LENGTH IS 1024.", True), # Negative cases (should return False)