(text: str, command: str = "")
| 1320 | |
| 1321 | |
| 1322 | def _contains_tool_failure_signal(text: str, command: str = "") -> bool: |
| 1323 | if ( |
| 1324 | _has_zero_xml_returncode(text) |
| 1325 | and _command_is_read_only_observation(command) |
| 1326 | and not _NONZERO_FAILURE_SUMMARY_RE.search(text) |
| 1327 | ): |
| 1328 | summary_stripped = _SUCCESSFUL_FAILURE_SUMMARY_RE.sub(" ", text) |
| 1329 | if not ( |
| 1330 | _has_verification_context(text, command) |
| 1331 | and _EXPLICIT_FAIL_STATUS_RE.search(summary_stripped) |
| 1332 | ): |
| 1333 | return False |
| 1334 | |
| 1335 | if ( |
| 1336 | _has_nonzero_xml_returncode(text) |
| 1337 | or _NONZERO_FAILURE_SUMMARY_RE.search(text) |
| 1338 | or _NONZERO_EXIT_STATUS_RE.search(text) |
| 1339 | ): |
| 1340 | return True |
| 1341 | summary_stripped = _SUCCESSFUL_FAILURE_SUMMARY_RE.sub(" ", text) |
| 1342 | if _has_verification_context(text, command) and _EXPLICIT_FAIL_STATUS_RE.search(summary_stripped): |
| 1343 | return True |
| 1344 | if not _contains_risk_marker(text, _HIGH_RISK_TOOL_MARKERS): |
| 1345 | return False |
| 1346 | lowered = text.lower() |
| 1347 | if "traceback" in lowered or "exception" in lowered or "error:" in lowered: |
| 1348 | return True |
| 1349 | failure_words = ("failed", "failure", "失败") |
| 1350 | summary_stripped = summary_stripped.lower() |
| 1351 | has_remaining_failure = any(word in summary_stripped for word in failure_words) |
| 1352 | if not has_remaining_failure and _SUCCESSFUL_FAILURE_SUMMARY_RE.search(text) and not any( |
| 1353 | marker in lowered |
| 1354 | for marker in ( |
| 1355 | "assertionerror", |
| 1356 | "syntaxerror", |
| 1357 | "typeerror", |
| 1358 | "valueerror", |
| 1359 | "invalid_request_error", |
| 1360 | "fatal", |
| 1361 | "panic", |
| 1362 | "400 bad request", |
| 1363 | "500 internal", |
| 1364 | "报错", |
| 1365 | "错误", |
| 1366 | "异常", |
| 1367 | ) |
| 1368 | ): |
| 1369 | return False |
| 1370 | return True |
| 1371 | |
| 1372 | |
| 1373 | def _contains_environment_recovery_signal(text: str, command: str = "") -> bool: |
no test coverage detected