The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix: output-cap failure copy stops pointing at the removed model.max_tokens key
teknium1f1737e1f0a16
diff --git a/agent/turn_overflow.py b/agent/turn_overflow.pyindex e4b0066843e..41292cf0d67 100644--- a/agent/turn_overflow.py+++ b/agent/turn_overflow.py@@ -378,11 +378,13 @@ def _recover_context_length(st: _Recovery, _retry: TurnRetryState, error_msg: st# fits) and would death-loop on the same 400. Fail fast.if is_output_cap_error(error_msg):return st.fail_turn(- "max_tokens exceeds the provider's output cap for this model. "- "Lower model.max_tokens in config.yaml.",+ "The requested output length exceeds the provider's output cap for this model, "+ "and the error did not state the allowed limit.",notices=(- "β The provider rejected the request because max_tokens exceeds its output cap for this model.",- " π‘ Lower model.max_tokens in your config.yaml to at or below the model's max-output limit. "+ "β The provider rejected the request because the requested output length exceeds its "+ "output cap for this model, and the error did not state the allowed limit.",+ " π‘ Hermes has no user setting for the output cap β check the endpoint's default max output "+ "(completion) tokens for this model on the server or proxy. ""(This is an output-cap error, not a context overflow β compression cannot fix it.)",),log=(diff --git a/tests/agent/test_output_cap_parsing.py b/tests/agent/test_output_cap_parsing.pyindex 745e86a0caf..89e17e5a818 100644--- a/tests/agent/test_output_cap_parsing.py+++ b/tests/agent/test_output_cap_parsing.py@@ -208,3 +208,29 @@ class TestParseVllmTokenBasedOutputCap:cap = availableassert real_input + cap <= window, f"did not converge: cap={cap}"+++class TestParseAdvertisedCeilingWordings:+ """Azure and SGLang name the ceiling without any phrase the parser knew (#78405, #83521).+ Unrecognized, the 400 carried the bare ``max_tokens`` substring (or nothing at all) into+ the compression path and a fresh session died with "cannot be shrunk further"."""++ @pytest.mark.parametrize("msg, available", [+ # Azure OpenAI (verbatim from #78405): the advertised completion ceiling IS the budget.+ ("Error: max_tokens is too large: 65536. This model supports at most 32768 completion tokens.", 32768),+ # SGLang (verbatim from #83521): window - input; never mentions max_tokens.+ ("Requested token count exceeds the model's maximum context length of 131072 tokens. You requested "+ "a total of 132528 tokens: 66992 tokens from the input messages and 65536 tokens for the completion. "+ "Please reduce the number of tokens in the input messages or the completion to fit within the limit.",+ 64080),+ ])+ def test_ceiling_is_parsed_and_classified_as_output_cap(self, msg, available):+ assert parse_available_output_tokens_from_error(msg) == available+ assert is_output_cap_error(msg) is True++ def test_sglang_input_alone_over_window_routes_to_compression(self):+ # Same wording, but the input by itself exceeds the window: shrinking the output cannot help.+ msg = ("Requested token count exceeds the model's maximum context length of 100000 tokens. You requested "+ "a total of 150000 tokens: 120000 tokens from the input messages and 30000 tokens for the completion.")+ assert parse_available_output_tokens_from_error(msg) is None+ assert is_output_cap_error(msg) is False