From de66bdbcbfeb040306ae90f3d6f78a696adef0ac Mon Sep 17 00:00:00 2001 From: Rachel Sequeira Date: Mon, 27 Apr 2026 23:51:00 +0530 Subject: [PATCH 1/3] fixed for attribute errors --- hud/agents/base.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hud/agents/base.py b/hud/agents/base.py index e6c25b46..dc5659b2 100644 --- a/hud/agents/base.py +++ b/hud/agents/base.py @@ -968,4 +968,9 @@ def find_content(result: MCPToolResult) -> str | None: return value except json.JSONDecodeError: pass + if not isinstance(json_content,dict): + continue + for key, value in json_content.items(): + if key in accept_keys: + return value return "" From 32eaef02b43ab9ed62247062a0458b82f6cf5dae Mon Sep 17 00:00:00 2001 From: Rachel Sequeira Date: Mon, 27 Apr 2026 23:58:58 +0530 Subject: [PATCH 2/3] made changes for attribute error --- hud/agents/base.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/hud/agents/base.py b/hud/agents/base.py index dc5659b2..89f656e3 100644 --- a/hud/agents/base.py +++ b/hud/agents/base.py @@ -937,11 +937,13 @@ def find_reward(result: MCPToolResult) -> float: if isinstance(content, types.TextContent): try: json_content = json.loads(content.text) - for key, value in json_content.items(): - if key in accept_keys: - return value except json.JSONDecodeError: - pass + continue + if not isinstance(json_content, dict): + continue + for key, value in json_content.items(): + if key in accept_keys: + return value logger.error("Couldn't parse reward from result: %s", str(result.structuredContent)) return 0.0 @@ -963,12 +965,9 @@ def find_content(result: MCPToolResult) -> str | None: if isinstance(content, types.TextContent): try: json_content = json.loads(content.text) - for key, value in json_content.items(): - if key in accept_keys: - return value except json.JSONDecodeError: - pass - if not isinstance(json_content,dict): + continue + if not isinstance(json_content, dict): continue for key, value in json_content.items(): if key in accept_keys: From 84213217c19270c8228c64f96f5f88656b7375d4 Mon Sep 17 00:00:00 2001 From: Rachel Sequeira Date: Tue, 28 Apr 2026 00:02:48 +0530 Subject: [PATCH 3/3] fixed attribute error --- hud/shared/exceptions.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/hud/shared/exceptions.py b/hud/shared/exceptions.py index 186e7ca8..04d1f538 100644 --- a/hud/shared/exceptions.py +++ b/hud/shared/exceptions.py @@ -266,19 +266,19 @@ def from_httpx_error(cls, error: httpx.HTTPStatusError, context: str = "") -> Se # Try to get detailed error info from JSON if available response_json = None + message = f"Request failed with status {status_code}" try: - response_json = response.json() + parsed = response.json() + except Exception: + parsed = None + if isinstance(parsed, dict): + response_json = parsed detail = response_json.get("detail") if detail: message = f"Request failed: {detail}" - else: - # If no detail field but we have JSON, include a summary - message = f"Request failed with status {status_code}" - if len(response_json) <= 5: # If it's a small object, include it in the message - message += f" - JSON response: {response_json}" - except Exception: - # Fallback to simple message if JSON parsing fails - message = f"Request failed with status {status_code}" + elif len(response_json) <= 5: + # Small object — include it in the message + message += f" - JSON response: {response_json}" # Add context if provided if context: