From cf012a05d895b4f2c19f75b27f799d222421be82 Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Sat, 18 Apr 2026 03:53:21 -0700 Subject: [PATCH] docs(terminal): warn against stacking watch_patterns + notify_on_complete on end-of-run markers (#12113) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Stacking both features on the same event produces duplicate, delayed notifications — delivery is async and continues firing after the process exits, so matches on end-of-run markers (SUMMARY, DONE, PASS) arrive after the agent has already polled/waited and moved on. Updates both the terminal tool JSON schema description and the terminal_tool() function docstring to make the split explicit: - watch_patterns: mid-process signals only (errors, readiness markers, intermediate steps you want to react to before the process exits) - notify_on_complete: end-of-run completion signal No behavioural change. --- tools/terminal_tool.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/terminal_tool.py b/tools/terminal_tool.py index 69832cc1..1182207b 100644 --- a/tools/terminal_tool.py +++ b/tools/terminal_tool.py @@ -1126,7 +1126,7 @@ def terminal_tool( workdir: Working directory for this command (optional, uses session cwd if not set) pty: If True, use pseudo-terminal for interactive CLI tools (local backend only) notify_on_complete: If True and background=True, auto-notify the agent when the process exits - watch_patterns: List of strings to watch for in background output; triggers notification on match + watch_patterns: List of strings to watch for in background output; fires a notification on first match per pattern. Use ONLY for mid-process signals (errors, readiness markers) that appear before exit. For end-of-run markers use notify_on_complete instead — stacking both produces duplicate, delayed notifications. Returns: str: JSON string with output, exit_code, and error fields @@ -1724,7 +1724,7 @@ TERMINAL_SCHEMA = { "watch_patterns": { "type": "array", "items": {"type": "string"}, - "description": "List of strings to watch for in background process output. When any pattern matches a line of output, you'll be notified with the matching text — like notify_on_complete but triggers mid-process on specific output. Use for monitoring logs, watching for errors, or waiting for specific events (e.g. [\"ERROR\", \"FAIL\", \"listening on port\"])." + "description": "Strings to watch for in background process output. Fires a notification the first time each pattern matches a line of output. **Use ONLY for mid-process signals** you want to react to before the process exits — errors, readiness markers, intermediate step markers (e.g. [\"ERROR\", \"Traceback\", \"listening on port\"]). Do NOT use for end-of-run markers (summary headers, 'DONE', 'PASS' printed right before exit) — use `notify_on_complete` for that instead. Stacking end-of-run patterns on top of `notify_on_complete` produces duplicate, delayed notifications that arrive after you've already moved on, since delivery is asynchronous and continues after the process exits." } }, "required": ["command"]