From a7c2b9e280939bc93a533f760400cae459808a42 Mon Sep 17 00:00:00 2001 From: teknium1 Date: Sat, 28 Feb 2026 22:49:52 -0800 Subject: [PATCH] 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. --- agent/display.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/agent/display.py b/agent/display.py index 9ef8c5eb..6f65c5d3 100644 --- a/agent/display.py +++ b/agent/display.py @@ -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"):