The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(terminal): foreground heartbeat is dropped, not refused; notify intent still is
Tekniumcb6ffe6cdd17
diff --git a/tests/tools/test_process_heartbeat.py b/tests/tools/test_process_heartbeat.pyindex 2faef8d5821..bbed60791af 100644--- a/tests/tools/test_process_heartbeat.py+++ b/tests/tools/test_process_heartbeat.py@@ -132,7 +132,10 @@ def test_first_heartbeat_carries_output_produced_before_arming(tmp_path, monkeypassert "first" in first_beat["output"], first_beat-def test_terminal_dispatch_heartbeat_implies_notify_and_refuses_foreground(monkeypatch):+def test_terminal_dispatch_heartbeat_implies_notify_and_foreground_runs_without_it(monkeypatch):+ """A foreground call carrying an explicit positive heartbeat (the shape models copy from a+ background call) runs once with the heartbeat dropped: refusing it only produced+ identical-call retry loops. Notification intent (`notify=true`) stays refused."""from tools import terminal_tool as ttcaptured = {}@@ -143,8 +146,14 @@ def test_terminal_dispatch_heartbeat_implies_notify_and_refuses_foreground(monkemonkeypatch.setattr(tt, "terminal_tool", fake_terminal_tool)dispatch = tt._handle_terminal- fg = json.loads(dispatch({"command": "sleep 1", "heartbeat": 120}))- assert fg.get("error") and "background" in fg["error"]+ fg = json.loads(dispatch({"command": "sleep 1", "background": False, "notify": False, "heartbeat": 120}))+ assert not fg.get("error")+ assert captured["background"] is False and captured["heartbeat"] == 0+ assert captured["notify_on_complete"] is False++ captured.clear()+ fg_notify = json.loads(dispatch({"command": "sleep 1", "notify": True}))+ assert fg_notify.get("error") and "background" in fg_notify["error"] and not capturedbg = json.loads(dispatch({"command": "sleep 1", "background": True, "heartbeat": 120}))assert "error" not in bg or not bg["error"]diff --git a/tools/terminal_tool.py b/tools/terminal_tool.pyindex d1020806666..c8670537c92 100644--- a/tools/terminal_tool.py+++ b/tools/terminal_tool.py@@ -1543,7 +1543,7 @@ TERMINAL_SCHEMA = {"type": "integer","minimum": 0,"default": 0,- "description": "0 disables. With background=true: also notify every N seconds (positive values are clamped to min 60) with the output produced since the last notice; a tick with no new output is skipped. For bounded jobs you must react to mid-run (merge trains, full suites, deploys) — never for servers or watchers; implies notify=true."+ "description": "0 disables. With background=true: also notify every N seconds (positive values are clamped to min 60) with the output produced since the last notice; a tick with no new output is skipped. For bounded jobs you must react to mid-run (merge trains, full suites, deploys) — never for servers or watchers; implies notify=true. Ignored on foreground commands.",},"persist_on_release": {"type": "boolean",@@ -1572,9 +1572,13 @@ def _handle_terminal(args, **kw):)# `notify` is the advertised interface (true → notify_on_complete,# [...] → watch_patterns); the legacy args stay accepted, explicit- # `notify` wins. Tool schemas mechanically materialize false background- # defaults and a heartbeat for ordinary foreground calls, so discard those- # non-operative fields instead of making the model retry the same command.+ # `notify` wins. Notification INTENT on a foreground call is refused with+ # the corrected call. A foreground `heartbeat` carries no intent: it has+ # no execution meaning without a tracked process, and providers that+ # materialize every schema property (or models copying a background call+ # shape) send `heartbeat=60` on ordinary commands — refusing it produced+ # identical-call retry loops (46 subagent sessions, 4 refusals each, 38 of+ # which never ran a single command), so it is normalized away instead.notify = args.get("notify")notify_on_complete = args.get("notify_on_complete", False)watch_patterns = args.get("watch_patterns")@@ -1585,8 +1589,8 @@ def _handle_terminal(args, **kw):if not args.get("background", False):if notify or watch_patterns or notify_on_complete:return tool_error(- "notify/heartbeat only apply to background commands (foreground "- "results return directly). Either drop them, or run as "+ "notify only applies to background commands (foreground "+ "results return directly). Either drop it, or run as ""terminal(command=..., background=true, notify=...).")heartbeat = 0