π OpenHands: AI-Driven Development
Fix: Update context window exceeded detection (#7024)
Calvin Smith2eec4cea6f06
diff --git a/openhands/controller/agent_controller.py b/openhands/controller/agent_controller.pyindex dbe9151e77..406c4fa4fa 100644--- a/openhands/controller/agent_controller.py+++ b/openhands/controller/agent_controller.py@@ -697,10 +697,13 @@ class AgentController:except (ContextWindowExceededError, BadRequestError, OpenAIError) as e:# FIXME: this is a hack until a litellm fix is confirmed# Check if this is a nested context window error+ # We have to rely on string-matching because LiteLLM doesn't consistently+ # wrap the failure in a ContextWindowExceededErrorerror_str = str(e).lower()if ('contextwindowexceedederror' in error_stror 'prompt is too long' in error_str+ or 'input length and `max_tokens` exceed context limit' in error_stror isinstance(e, ContextWindowExceededError)):if self.agent.config.enable_history_truncation: