Terminal safety filter false positives on quoted keywords
NousResearch/hermes-agent · cluster 20064 · environments
Data as of
Nothing open on GitHub. Fix merged in #25784. Check it covers your case.
The short answer
- Known?
- Yes. 8 related items grouped here, 1 issue already closed.
- Fix event
- A fix was merged to main in PR #25784. Check it covers your case. No release data is tracked.
- Tracker
- The maintainers' tracker marks this
unresolved. That is separate from the fix event. - Still open
- Nothing open on GitHub.
Multiple bug reports and fix attempts addressing false positives in the terminal safety filter when background-wrapper keywords like nohup, disown, and setsid appear inside quoted strings. The fixes focus on stripping or ignoring quoted content before applying the regex scan.
Open issues0
Open PRs0
Fixes on record
-
#25784 fix(terminal): prevent safety filter false positives on quoted background-wrap (#25616)
files:
tools/terminal_tool.pyShow the diff
-
tools/terminal_tool.py@@ -1544,9 +1544,29 @@ def _command_requires_pipe_stdin(command: str) -> bool: ) -_SHELL_LEVEL_BACKGROUND_RE = re.compile(r"\b(?:nohup|disown|setsid)\b", re.IGNORECASE) +_SHELL_LEVEL_BACKGROUND_RE = re.compile( + r"(?:^|[;&|]\s*|&&\s*|\|\|\s*|\$\(\s*)(?:nohup|disown|setsid)\b", re.IGNORECASE | re.MULTILINE +) _INLINE_BACKGROUND_AMP_RE = re.compile(r"\s&\s") _TRAILING_BACKGROUND_AMP_RE = re.compile(r"\s&\s*(?:#.*)?$") + + +def _strip_quotes(command: str) -> str: + """Remove single- and double-quoted content so regex checks don't match inside strings. + + This prevents false positives when keywords like 'nohup' or 'setsid' appear + in commit messages, Python -c code, echo arguments, or PR body text. + Also strips backtick-quoted content and heredoc-style inline text. + """ + # Remove single-quoted strings (no escaping inside single quotes in shell) + result = re.sub(r"'[^']*'", "''", command) + # Remove double-quoted strings (handle escaped quotes) + result = re.sub(r'"(?:[^"\\]|\\.)*"', '""', result) + # Remove backtick-quoted strings + result = re.sub(r"`[^`]*`", "``", result) + return result + + _LONG_LIVED_FOREGROUND_PATTERNS = ( re.compile(r"\b(?:npm|pnpm|yarn|bun)\s+(?:run\s+)?(?:dev|start|serve|watch)\b", re.IGNORECASE), re.compile(r"\bdocker\s+compose\s+up\b", re.IGNORECASE), @@ -1579,21 +1599,25 @@ def _foreground_background_guidance(command: str) -> str | None: if _looks_like_help_or_version_command(command): return None - if _SHELL_LEVEL_BACKGROUND_RE.search(command): + # Strip quoted content so keywords inside strings/arguments don't trigger + # false positives (e.g., git commit -m "... setsid ...", python3 -c "os.setsid"). + unquoted = _strip_quotes(command) + + if _SHELL_LEVEL_BACKGROUND_RE.search(unquoted): return ( "Foreground command uses shell-level background wrappers (nohup/disown/setsid). " "Use terminal(background=true) so Hermes can track the process, then run " "readiness checks and tests in separate commands." ) - if _INLINE_BACKGROUND_AMP_RE.search(command) or _TRAILING_BACKGROUND_AMP_RE.search(command): + if _INLINE_BACKGROUND_AMP_RE.search(unquoted) or _TRAILING_BACKGROUND_AMP_RE.search(unquoted): return ( "Foreground command uses '&' backgrounding. Use terminal(background=true) for long-lived " "processes, then run health checks and tests in follow-up terminal calls." ) for pattern in _LONG_LIVED_FOREGROUND_PATTERNS: - if pattern.search(command): + if pattern.search(unquoted): return ( "This foreground command appears to start a long-lived server/watch process. " "Run it with background=true, verify readiness (health endpoint/log signal), "
-
6 PRs closed without merging
From the close comments: done elsewhere 3 · duplicate 2 · merged via another change 1
-
#20066 fix(terminal): prevent safety filter false positives on keywords inside quoted strings · duplicate →
#20064 -
#20079 fix(terminal): prevent safety filter false positives on keywords inside quoted strings · duplicate →
#20066,#20064 -
#20099 fix: reduce false positives in terminal safety filter for nohup/disown/setsid · done elsewhere →
364ddd4,#20064,#20066 - #20101 fix(terminal): strip quoted strings before safety-filter regex scan (#20064) · done elsewhere
-
#20146 fix(terminal): stop false-positive on quoted nohup/disown/setsid (#20064) · done elsewhere →
364ddd4,#20064
Show 1 more
-
#25616 fix(terminal): prevent safety filter false positives on quoted background-wrapper keywords (salvage #20066) · merged via another change →
#25784
Closed issues · 1
- Closed#20064bug(terminal): safety filter false-positives on background wrapper keywords inside quoted strings
How this cluster was grouped
-
Link evidence (
structural links throughout): every member is connected by structural evidence: shared changed files, or a closing/superseded reference. -
Pairwise link density
0.25: the share of item pairs that carry a link, counting a structural link in full and a relevance-only link at 0.36.1.00means every pair is linked.
Pick up a Lab task
Check whether a fix covers the open issues here, with your own agent. Bring back evidence for maintainers.
Open the LabAt a glance
- Subsystem
- environments
- Merged PRs
- #25784
- Closed issues
- 1
- Attempts
- 6 PRs closed without merging
- Fix link checked
- 14 May 2026