From 209fbcc47be899fbd61105efeea15ce080d01c24 Mon Sep 17 00:00:00 2001 From: kshitijk4poor <82637225+kshitijk4poor@users.noreply.github.com> Date: Sat, 3 Oct 2026 19:44:19 +0530 Subject: [PATCH] fix(goal): only announce a replaced goal when one was still live Gate quality finding (Medium): _set read mgr.state.goal regardless of status, so `/goal clear` (or a done goal) followed by `/goal ` printed "(replaced the previous goal) was: ..." about a goal that was already gone. Use mgr.has_goal() (active/paused) to decide what counts as replaced. --- hermes_cli/goal_command.py | 2 +- tests/hermes_cli/test_goal_dispatch.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/hermes_cli/goal_command.py b/hermes_cli/goal_command.py index 98f8ae4e4b..6fe3491583 100644 --- a/hermes_cli/goal_command.py +++ b/hermes_cli/goal_command.py @@ -147,7 +147,7 @@ def _set(mgr, arg, *, drafting, last_user_message, render, progress): else: headline, contract = goals.parse_contract(arg) contract = contract if not contract.is_empty() else None - previous = (mgr.state.goal or "").strip() if mgr.state is not None else "" + previous = mgr.state.goal if mgr.has_goal() else "" state = mgr.set(headline or arg, contract=contract) output = render("gateway.goal.set", "⊙ Goal set ({budget}-turn budget): {goal}", budget=state.max_turns, goal=state.goal) diff --git a/tests/hermes_cli/test_goal_dispatch.py b/tests/hermes_cli/test_goal_dispatch.py index 2ef73513dd..2235cd405d 100644 --- a/tests/hermes_cli/test_goal_dispatch.py +++ b/tests/hermes_cli/test_goal_dispatch.py @@ -145,3 +145,6 @@ def test_double_dash_sets_control_word_goal_and_announces_the_replace(): result = _dispatch(mgr, '-- pause the nightly cron') assert goals.load_goal(mgr.session_id).goal == 'pause the nightly cron' assert 'was: original objective' in result.output + mgr.clear() + fresh = goals.GoalManager(session_id=mgr.session_id) # gateway/TUI reload per command + assert 'replaced' not in _dispatch(fresh, 'fresh objective').output