Skip to content

Commit 6c7ad75

Browse files
Recognize GPT‑5 context overflow and trigger condenser (Fixes #776) (#783)
Co-authored-by: openhands <[email protected]> Co-authored-by: Engel Nyst <[email protected]>
1 parent a7ea013 commit 6c7ad75

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

openhands-sdk/openhands/sdk/llm/exceptions/classifier.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"please reduce the length of",
1414
"the request exceeds the available context size",
1515
"context length exceeded",
16+
"input exceeds the context window",
1617
]
1718

1819

tests/sdk/llm/test_exception_classifier.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,19 @@ def test_is_context_window_exceeded_direct_type():
1919

2020
def test_is_context_window_exceeded_via_text():
2121
# BadRequest containing context-window-ish text should be detected
22-
e = BadRequestError(
22+
e1 = BadRequestError(
2323
"The request exceeds the available context size", MODEL, PROVIDER
2424
)
25-
assert is_context_window_exceeded(e) is True
25+
e2 = BadRequestError(
26+
(
27+
"Your input exceeds the context window of this model. "
28+
"Please adjust your input and try again."
29+
),
30+
MODEL,
31+
PROVIDER,
32+
)
33+
assert is_context_window_exceeded(e1) is True
34+
assert is_context_window_exceeded(e2) is True
2635

2736

2837
def test_is_context_window_exceeded_negative():

0 commit comments

Comments
 (0)