Skip to content

The agent that grows with you

fix(tools): honor false interrupt debug values

Xuxyyy84893f8342d2
diff --git a/tests/tools/test_interrupt_debug_env.py b/tests/tools/test_interrupt_debug_env.py
new file mode 100644
index 00000000000..becdf7d2714
--- /dev/null
+++ b/tests/tools/test_interrupt_debug_env.py
@@ -0,0 +1,44 @@
+"""Interrupt debug logging follows the documented environment flag semantics."""
+
+from __future__ import annotations
+
+import os
+import subprocess
+import sys
+from pathlib import Path
+
+import pytest
+
+
+_REPO_ROOT = Path(__file__).resolve().parents[2]
+_PROBE = (
+ "from tools import interrupt; "
+ "from tools.environments import base; "
+ "print(interrupt._DEBUG_INTERRUPT, base._DEBUG_INTERRUPT)"
+)
+
+
+ ("value", "expected"),
+ [
+ ("1", "True True"),
+ ("true", "True True"),
+ ("0", "False False"),
+ ("false", "False False"),
+ ("off", "False False"),
+ ],
+)
+def test_interrupt_debug_flag_uses_shared_truthy_values(value, expected):
+ env = os.environ.copy()
+ env["HERMES_DEBUG_INTERRUPT"] = value
+
+ result = subprocess.run(
+ [sys.executable, "-c", _PROBE],
+ cwd=_REPO_ROOT,
+ env=env,
+ capture_output=True,
+ text=True,
+ check=True,
+ )
+
+ assert result.stdout.strip() == expected
diff --git a/tools/environments/base.py b/tools/environments/base.py
index f9cbac4cb33..b212ca7c13d 100644
--- a/tools/environments/base.py
+++ b/tools/environments/base.py
@@ -28,12 +28,13 @@ from tools.environments.base_session_env import (
_wrap_command_script,
)
from tools.environments.base_wait import _WaitTrace
+from utils import env_var_enabled
logger = logging.getLogger(__name__)
# Opt-in debug tracing for the interrupt/activity/poll machinery
# (HERMES_DEBUG_INTERRUPT=1). Off by default to avoid flooding gateway logs.
-_DEBUG_INTERRUPT = bool(os.getenv("HERMES_DEBUG_INTERRUPT"))
+_DEBUG_INTERRUPT = env_var_enabled("HERMES_DEBUG_INTERRUPT")
# Extra seconds the ``run_bounded_sync`` backstop waits past the inner ``_wait_for_process``
# deadline: the inner loop returns partial output + 124; the outer bound only fires when that
diff --git a/tools/interrupt.py b/tools/interrupt.py
index fc5850dff4e..4a4624604f5 100644
--- a/tools/interrupt.py
+++ b/tools/interrupt.py
@@ -5,14 +5,15 @@ is_interrupted(), which checks the CURRENT thread."""
import contextvars
import logging
-import os
import threading
from collections.abc import Callable
+from utils import env_var_enabled
+
logger = logging.getLogger(__name__)
# Opt-in debug tracing — pairs with HERMES_DEBUG_INTERRUPT in tools/environments/base.py.
-_DEBUG_INTERRUPT = bool(os.getenv("HERMES_DEBUG_INTERRUPT"))
+_DEBUG_INTERRUPT = env_var_enabled("HERMES_DEBUG_INTERRUPT")
if _DEBUG_INTERRUPT:
# AIAgent's quiet_mode forces the `tools` logger to ERROR on CLI startup;
# force ours back to INFO so the trace is visible in agent.log.