Problem
PR #1550 (suppress pending_approval retries in cron/subagent contexts) has CI failures on test slices 2/8 and 8/8.
Root cause: _is_unattended_context() returns True whenever there's no interactive CLI, no gateway, and no cron session. In the CI test environment (non-interactive, non-gateway, non-cron), this evaluates to True, causing check_all_command_guards and check_execute_code_guard to return blocked instead of pending_approval. Existing tests that expect pending_approval behavior break.
Proposed Fix
Make _is_unattended_context() require a positive signal of an unattended context (HERMES_CRON_SESSION or HERMES_SUBAGENT), instead of the catch-all "nobody's home" default. This preserves the fix for actual cron/subagent sessions while not affecting tests or interactive sessions that haven't set HERMES_INTERACTIVE.
def _is_unattended_context() -> bool:
"""True when in a cron or subagent context where no human can approve."""
if env_var_enabled("HERMES_CRON_SESSION"):
return True
if env_var_enabled("HERMES_SUBAGENT"):
return True
return False
Scope
- ~5-line change to
_is_unattended_context() in tools/approval.py
- Update test to match new behavior
- Fits ≤200-line cap
Problem
PR #1550 (suppress pending_approval retries in cron/subagent contexts) has CI failures on test slices 2/8 and 8/8.
Root cause:
_is_unattended_context()returnsTruewhenever there's no interactive CLI, no gateway, and no cron session. In the CI test environment (non-interactive, non-gateway, non-cron), this evaluates toTrue, causingcheck_all_command_guardsandcheck_execute_code_guardto returnblockedinstead ofpending_approval. Existing tests that expectpending_approvalbehavior break.Proposed Fix
Make
_is_unattended_context()require a positive signal of an unattended context (HERMES_CRON_SESSION or HERMES_SUBAGENT), instead of the catch-all "nobody's home" default. This preserves the fix for actual cron/subagent sessions while not affecting tests or interactive sessions that haven't set HERMES_INTERACTIVE.Scope
_is_unattended_context()intools/approval.py