The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(kanban): stop goal loop on worker/judge failures (#91264)
webtecnica242244bf6861
diff --git a/hermes_cli/cli_single_query.py b/hermes_cli/cli_single_query.pyindex bb0caa5b4b0..4a18e80ee8c 100644--- a/hermes_cli/cli_single_query.py+++ b/hermes_cli/cli_single_query.py@@ -80,13 +80,19 @@ def _run_kanban_goal_loop_q(cli: "HermesCLI", first_response: str, run_turn=Noneif not goal_text:return- def _quiet_turn(prompt: str) -> str:+ def _quiet_turn(prompt: str) -> dict:result = cli.agent.run_conversation(user_message=prompt, conversation_history=cli.conversation_history)_sync_cli_session_id_from_agent(cli)resp = result.get("final_response", "") if isinstance(result, dict) else str(result)if resp:print(resp)- return resp or ""+ # Carry failed/failure_reason so run_kanban_goal_loop can stop on a failed+ # worker turn instead of grinding out empty continuation turns (#91264).+ return {+ "response": resp or "",+ "failed": result.get("failed", False) if isinstance(result, dict) else False,+ "failure_reason": result.get("failure_reason") if isinstance(result, dict) else None,+ }def _task_status() -> "str | None":with _kbc.connect_closing() as c:diff --git a/hermes_cli/goals.py b/hermes_cli/goals.pyindex 47aa40f165e..90fa0b6f0c0 100644--- a/hermes_cli/goals.py+++ b/hermes_cli/goals.py@@ -1682,8 +1682,6 @@ def run_kanban_goal_loop(_log(f"kanban goal loop: task {task_id} status={status!r}; stopping")return _result("stopped", f"status={status}")- # The between-turns judge runs outside any agent turn: bind the per-task relay-affinity- # scope (same shape as the handoff gates) so the relay does not reject the call (#113669).from agent.portal_tags import get_affinity_scope, reset_affinity_scope, set_affinity_scopeaffinity_token = None if get_affinity_scope() else set_affinity_scope(f"kanban:{task_id}")try:@@ -1691,6 +1689,9 @@ def run_kanban_goal_loop(finally:if affinity_token is not None:reset_affinity_scope(affinity_token)+ if _transport_failed:+ _log(f"kanban goal loop: judge transport failed on turn {turns_used}; stopping")+ return _result("stopped", "judge transport failure")if verdict == "wait":verdict = "continue"_log(f"kanban goal loop: turn {turns_used}/{max_turns} verdict={verdict} reason={_truncate(reason, 120)}")@@ -1728,10 +1729,22 @@ def run_kanban_goal_loop(return _result("blocked_budget", "turn budget exhausted")try:- last_response = run_turn(prompt) or ""+ result = run_turn(prompt)+ if isinstance(result, dict):+ last_response = result.get("response", "") or ""+ failed = bool(result.get("failed", False))+ failure_reason = result.get("failure_reason") or "unknown"+ else:+ # backward compatibility: assume it's a string+ last_response = result or ""+ failed = False+ failure_reason = Noneexcept Exception as exc:_log(f"kanban goal loop: run_turn failed ({exc}); stopping")return _result("stopped", f"run_turn error: {type(exc).__name__}")+ if failed:+ _log(f"kanban goal loop: worker failed on turn {turns_used} (reason={failure_reason}); stopping")+ return _result("stopped", f"worker failed: {failure_reason}")turns_used += 1