Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions tests/tools/test_process_heartbeat.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,34 @@ def test_heartbeat_carries_only_new_output_and_stops_at_exit(tmp_path, monkeypat
timeout=2.5)


def test_schema_minimum_heartbeat_is_disabled_for_foreground(monkeypatch):
from tools import terminal_tool as tt

captured = {}

def fake_terminal_tool(**kwargs):
captured.update(kwargs)
return json.dumps({"output": "Background process started", "session_id": "proc_x", "exit_code": 0})

monkeypatch.setattr(tt, "terminal_tool", fake_terminal_tool)
heartbeat_schema = tt.TERMINAL_SCHEMA["parameters"]["properties"]["heartbeat"]
generated = {
"command": "pwd",
"background": False,
"timeout": 20,
"pty": False,
"notify": False,
"heartbeat": heartbeat_schema["minimum"],
}

result = json.loads(tt._handle_terminal(generated))

assert not result.get("error")
assert captured["background"] is False
assert captured["heartbeat"] == 0
assert captured["notify_on_complete"] is False


def test_terminal_dispatch_heartbeat_implies_notify_and_refuses_foreground(monkeypatch):
from tools import terminal_tool as tt

Expand Down
5 changes: 3 additions & 2 deletions tools/terminal_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -1386,8 +1386,9 @@ def check_terminal_requirements() -> bool:
},
"heartbeat": {
"type": "integer",
"minimum": 60,
"description": "With background=true: also notify every N seconds (min 60) with the output since the last notice. For long jobs you must react to mid-run (merge trains, full suites); implies notify=true."
"minimum": 0,
"default": 0,
"description": "0 disables. With background=true: also notify every N seconds with the output since the last notice (positive values are clamped to min 60). For long jobs you must react to mid-run (merge trains, full suites); implies notify=true."
Comment on lines +1389 to +1391
}
# Legacy aliases (unadvertised, still accepted): notify_on_complete
# (bool) and watch_patterns (list). notify=true|[...] maps onto
Expand Down