Skip to content

The agent that grows with you

fix(tools): normalize foreground terminal heartbeat

KoNit-K4d8024d0a1dc
diff --git a/tools/terminal_tool.py b/tools/terminal_tool.py
index 135c595f76e..d1020806666 100644
--- a/tools/terminal_tool.py
+++ b/tools/terminal_tool.py
@@ -1572,8 +1572,9 @@ def _handle_terminal(args, **kw):
)
# `notify` is the advertised interface (true → notify_on_complete,
# [...] → watch_patterns); the legacy args stay accepted, explicit
- # `notify` wins. Background-only modifiers on a foreground call fail
- # with the corrected call instead of being silently ignored.
+ # `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 = args.get("notify")
notify_on_complete = args.get("notify_on_complete", False)
watch_patterns = args.get("watch_patterns")
@@ -1582,12 +1583,13 @@ def _handle_terminal(args, **kw):
if not isinstance(heartbeat, int) or isinstance(heartbeat, bool) or heartbeat < 0:
return tool_error("heartbeat must be a whole number of seconds (0 disables; positive values are clamped to min 60).")
if not args.get("background", False):
- if notify or watch_patterns or notify_on_complete or heartbeat:
+ 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 "
"terminal(command=..., background=true, notify=...)."
)
+ heartbeat = 0
if args.get("pty", False):
return tool_error(
"pty requires background=true (a PTY session is interacted "