From 22afa066f838da5fcf1f1a0087524dd4fb99f7c5 Mon Sep 17 00:00:00 2001 From: Nilesh Date: Mon, 13 Apr 2026 22:45:59 -0700 Subject: [PATCH] fix(cron): guard against non-dict result from run_conversation When run_conversation returns a non-dict value (e.g. an int under error conditions), the subsequent result.get("final_response", "") raises an opaque "'int' object has no attribute 'get'" AttributeError. Add a type guard that converts this into a clear RuntimeError, which is properly caught by the outer except Exception handler that marks the job as failed and delivers the error message. Fixes NousResearch/hermes-agent#9433 Co-Authored-By: Claude Opus 4.6 (1M context) --- cron/scheduler.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cron/scheduler.py b/cron/scheduler.py index 61d5537d..e7a22dfb 100644 --- a/cron/scheduler.py +++ b/cron/scheduler.py @@ -972,6 +972,12 @@ def run_job(job: dict) -> tuple[bool, str, str, Optional[str]]: f"— last activity: {_last_desc}" ) + # Guard against non-dict returns from run_conversation under error conditions + if not isinstance(result, dict): + raise RuntimeError( + f"agent.run_conversation returned {type(result).__name__} instead of dict: {result!r}" + ) + final_response = result.get("final_response", "") or "" # Strip leaked placeholder text that upstream may inject on empty completions. if final_response.strip() == "(No response generated)":