fix(agent): exempt parseable vLLM/LM Studio output-cap errors from compression-disabled guard

Salvage of #63862. is_output_cap_error() returns False for vLLM/LM Studio
error messages that contain 'prompt contains ... input tokens' (treated as
input-overflow signal). But parse_available_output_tokens_from_error() CAN
extract a valid available_tokens from those same messages. The
compression-disabled guard only checked is_output_cap_error(), so vLLM/LM
Studio users with compression off still got a terminal failure instead of
the max-tokens retry.

Fix: also exempt when parse_available_output_tokens_from_error() returns a
value — that function determines whether the retry path can actually handle
the error, so it's the right predicate for the exemption.

Added test: verify vLLM-format error with compression_disabled=False still
triggers the max-tokens retry path.

Co-authored-by: dmabry <dmabry@users.noreply.github.com>
This commit is contained in:
kshitijk4poor 2026-07-14 03:50:15 +05:30 committed by kshitij
parent af4006000f
commit 2ccfdb2db4
3 changed files with 55 additions and 1 deletions

View file

@ -3071,7 +3071,10 @@ def run_conversation(
FailoverReason.payload_too_large,
FailoverReason.context_overflow,
}
_is_output_cap_error = is_output_cap_error(error_msg)
_is_output_cap_error = (
is_output_cap_error(error_msg)
or parse_available_output_tokens_from_error(error_msg) is not None
)
if (
classified.reason in _overflow_reasons
and not getattr(agent, "compression_enabled", True)