hermes - 💡(How to fix) Fix scripts/run_tests.sh leaks HERMES_CRON_SESSION into pytest under cron [5 pull requests]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Fix Action

Fixed

Code Example

# Simulate the cron environment leaking into pytest
HERMES_CRON_SESSION=1 venv/bin/python -m pytest -o addopts= -n 0 \
  tests/acp/test_approval_isolation.py::TestAcpExecAskGate::test_interactive_env_var_routes_to_callback \
  -vv --tb=short

---

E       assert False is True
FAILED tests/acp/test_approval_isolation.py::TestAcpExecAskGate::test_interactive_env_var_routes_to_callback

---

env -u HERMES_CRON_SESSION venv/bin/python -m pytest -o addopts= -n 0 \
  tests/acp/test_approval_isolation.py::TestAcpExecAskGate::test_interactive_env_var_routes_to_callback \
  -q
# 1 passed in 2.27s
RAW_BUFFERClick to expand / collapse

Bug Description

The canonical test runner claims to scrub behavioral HERMES_* variables, but it does not unset HERMES_CRON_SESSION. When the test runner is invoked from a scheduled Hermes cron job, that environment variable leaks into the pytest process and changes approval behavior from the normal non-interactive auto-approve path to cron-deny behavior.

This makes otherwise passing approval tests fail only under cron/scheduled bug-hunt runs, and can hide real regressions behind environment contamination.

Reproduction

From current main at f2afa68a4:

# Simulate the cron environment leaking into pytest
HERMES_CRON_SESSION=1 venv/bin/python -m pytest -o addopts= -n 0 \
  tests/acp/test_approval_isolation.py::TestAcpExecAskGate::test_interactive_env_var_routes_to_callback \
  -vv --tb=short

Observed failure:

E       assert False is True
FAILED tests/acp/test_approval_isolation.py::TestAcpExecAskGate::test_interactive_env_var_routes_to_callback

Control run passes when the variable is removed:

env -u HERMES_CRON_SESSION venv/bin/python -m pytest -o addopts= -n 0 \
  tests/acp/test_approval_isolation.py::TestAcpExecAskGate::test_interactive_env_var_routes_to_callback \
  -q
# 1 passed in 2.27s

Expected Behavior

scripts/run_tests.sh should fully hermeticize the test environment it documents. Running it from a Hermes cron job should not make tests observe cron-only approval mode.

Actual Behavior

scripts/run_tests.sh unsets many behavioral variables (HERMES_INTERACTIVE, HERMES_GATEWAY_SESSION, HERMES_EXEC_ASK, etc.) but not HERMES_CRON_SESSION, so cron approval mode leaks into tests.

Relevant file:

  • scripts/run_tests.sh, lines 65-73: behavioral var scrub list omits HERMES_CRON_SESSION.
  • tools/approval.py, lines 865-879: HERMES_CRON_SESSION changes dangerous-command approval behavior.

Suggested Fix

Add HERMES_CRON_SESSION to the scrub list in scripts/run_tests.sh. It may also be worth adding a small regression test or documenting the complete set of scheduler-injected variables.

Environment

  • Repo: NousResearch/hermes-agent
  • Branch: main
  • Commit tested: f2afa68a4
  • Runner context: Hermes scheduled cron job on WSL/Linux
  • Python: venv/bin/python 3.11.15

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - 💡(How to fix) Fix scripts/run_tests.sh leaks HERMES_CRON_SESSION into pytest under cron [5 pull requests]