fix(display): enhance memory error detection for tool failures

- Implement logic to distinguish between "full" memory errors and actual failures in the `_detect_tool_failure` function.
- Add JSON parsing to identify specific error messages related to memory limits, improving error handling for memory-related tools.
This commit is contained in:
teknium1 2026-02-28 22:49:52 -08:00
parent 70dfec9638
commit a7c2b9e280

View file

@ -283,6 +283,15 @@ def _detect_tool_failure(tool_name: str, result: str | None) -> tuple[bool, str]
pass
return False, ""
# Memory-specific: distinguish "full" from real errors
if tool_name == "memory":
try:
data = json.loads(result)
if data.get("success") is False and "exceed the limit" in data.get("error", ""):
return True, " [full]"
except (json.JSONDecodeError, TypeError, AttributeError):
pass
# Generic heuristic for non-terminal tools
lower = result[:500].lower()
if '"error"' in lower or '"failed"' in lower or result.startswith("Error"):