fix: preserve exploration tool history and cap context budget
This commit is contained in:
1 parent
ee256ad7ce
commit
621f30e437
17 files changed
+211
-23
No files matched your search
@@ -81,6 +81,11 @@ _AUTH_MARKERS = ("unauthorized", "forbidden", "api key", "credential")
|
||||
# "deadline exceeded"/"deadline_exceeded" cover google-genai SDK timeouts that
|
||||
# surface without an HTTP status code attached.
|
||||
_TIMEOUT_MARKERS = ("timed out", "timeout", "deadline exceeded", "deadline_exceeded")
|
||||
_TOOL_HISTORY_ERRORS = (
|
||||
"no tool call found for function call output",
|
||||
"no tool output found for function call",
|
||||
"tool_call_id not found",
|
||||
)
|
||||
|
||||
|
||||
def classify_failure(error: BaseException) -> Failure:
|
||||
@@ -91,6 +96,12 @@ def classify_failure(error: BaseException) -> Failure:
|
||||
code = extract_status_code(error)
|
||||
message = str(error).lower()
|
||||
|
||||
# Compatible Responses endpoints can report input validation inside an
|
||||
# HTTP 200 stream as APIError without a status code. Retrying the same
|
||||
# broken call/output history cannot repair it, even on a fallback model.
|
||||
if any(marker in message for marker in _TOOL_HISTORY_ERRORS):
|
||||
return Failure(FailureCategory.BAD_REQUEST, False, False)
|
||||
|
||||
if code == 429 or any(marker in message for marker in _RATE_LIMIT_MARKERS):
|
||||
return Failure(FailureCategory.RATE_LIMIT, True, True)
|
||||
if code in {500, 502, 503, 504} or any(marker in message for marker in _UNAVAILABLE_MARKERS):
|
||||
|
||||
Reference in new issue
Block a user