mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
Fix: Update context window exceeded detection (#7024)
Co-authored-by: Calvin Smith <calvin@all-hands.dev> Co-authored-by: Engel Nyst <enyst@users.noreply.github.com>
This commit is contained in:
parent
32ee6a5a64
commit
2eec4cea6f
@ -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 ContextWindowExceededError
|
||||
error_str = str(e).lower()
|
||||
if (
|
||||
'contextwindowexceedederror' in error_str
|
||||
or 'prompt is too long' in error_str
|
||||
or 'input length and `max_tokens` exceed context limit' in error_str
|
||||
or isinstance(e, ContextWindowExceededError)
|
||||
):
|
||||
if self.agent.config.enable_history_truncation:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user