Skip to content

The agent that grows with you

fix(goal): only announce a replaced goal when one was still live

kshitijk4poor209fbcc47be8
diff --git a/hermes_cli/goal_command.py b/hermes_cli/goal_command.py
index 98f8ae4e4bf..6fe3491583a 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 2ef73513ddf..2235cd405d9 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