Skip to content

The agent that grows with you

test(tools): platform-aware TZ assertion, Windows live-child contract, docs

teknium1adb4323e7509
diff --git a/tests/tools/test_code_execution.py b/tests/tools/test_code_execution.py
index da8b97e227a..7ccb2b48b79 100644
--- a/tests/tools/test_code_execution.py
+++ b/tests/tools/test_code_execution.py
@@ -593,7 +593,12 @@ class TestEnvVarFiltering(unittest.TestCase):
try:
os.environ["HERMES_TIMEZONE"] = "America/New_York"
child_env = self._get_child_env()
- self.assertEqual(child_env.get("TZ"), "America/New_York")
+ if sys.platform == "win32":
+ # The MSVC runtime only parses POSIX-form TZ; an IANA name yields a wrong
+ # offset (#112233), so Windows children keep the OS zone instead.
+ self.assertNotIn("TZ", child_env)
+ else:
+ self.assertEqual(child_env.get("TZ"), "America/New_York")
finally:
os.environ.clear()
os.environ.update(env_backup)
diff --git a/tests/tools/test_code_execution_windows_env.py b/tests/tools/test_code_execution_windows_env.py
index 1468e328624..5b07e14717c 100644
--- a/tests/tools/test_code_execution_windows_env.py
+++ b/tests/tools/test_code_execution_windows_env.py
@@ -24,6 +24,7 @@ import os
import subprocess
import sys
import textwrap
+import time
import pytest
@@ -680,3 +681,26 @@ def test_posix_child_receives_configured_timezone(monkeypatch):
monkeypatch.setattr("hermes_time.get_timezone_name", lambda: "America/Los_Angeles")
assert _configured_timezone_child_env()["TZ"] == "America/Los_Angeles"
+
+
+def test_windows_live_child_offset_matches_os_zone_when_timezone_is_configured(monkeypatch):
+ """The user-visible contract of #112233: with ``timezone:`` configured, a real Windows child
+ must report the OS zone's UTC offset — an IANA name in ``TZ`` made the MSVC runtime derive
+ ``time.timezone == 0`` (+01:00 instead of -07:00) while ``time.tzname`` still read correctly."""
+ import datetime
+ import json
+
+ monkeypatch.setattr("hermes_time.get_timezone_name", lambda: "America/Los_Angeles")
+ child_env = _configured_timezone_child_env()
+ result = subprocess.run(
+ [sys.executable, "-c",
+ "import json, time, datetime; print(json.dumps([time.timezone, "
+ "datetime.datetime.now().astimezone().utcoffset().total_seconds()]))"],
+ env=child_env, capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=30,
+ )
+ assert result.returncode == 0, result.stderr
+ child_timezone, child_offset = json.loads(result.stdout.strip())
+ # The test process itself has no TZ override, so its view IS the OS zone.
+ assert child_offset == datetime.datetime.now().astimezone().utcoffset().total_seconds()
+ assert child_timezone == time.timezone
diff --git a/website/docs/reference/environment-variables.md b/website/docs/reference/environment-variables.md
index 1ff80077632..45807b3bfdb 100644
--- a/website/docs/reference/environment-variables.md
+++ b/website/docs/reference/environment-variables.md
@@ -144,7 +144,7 @@ For native Anthropic auth, Hermes prefers Claude Code's own credential files whe
| `HERMES_NOUS_TIMEOUT_SECONDS` | HTTP timeout for Nous credential / token flows |
| `HERMES_DUMP_REQUESTS` | Dump API request payloads to log files (`true`/`false`) |
| `HERMES_PREFILL_MESSAGES_FILE` | Path to a JSON file of ephemeral prefill messages injected at API-call time |
-| `HERMES_TIMEZONE` | IANA timezone override (for example `America/New_York`) |
+| `HERMES_TIMEZONE` | IANA timezone override (for example `America/New_York`). On Linux/macOS it is also exported as `TZ` to `execute_code` children; on Windows those children keep the OS zone instead, because the Windows C runtime only understands POSIX-form `TZ` strings and mis-parses an IANA name into a wrong offset |
## Tool APIs
diff --git a/website/docs/user-guide/configuration.md b/website/docs/user-guide/configuration.md
index a94e2d2eb9b..f54ec48b5e3 100644
--- a/website/docs/user-guide/configuration.md
+++ b/website/docs/user-guide/configuration.md
@@ -2609,6 +2609,8 @@ Supported values: any IANA timezone identifier (e.g. `America/New_York`, `Europe
`hermes doctor` (and the startup config check) reports a value the runtime cannot load — a typo such as `Asia/Tokio` would otherwise silently put the agent clock and every cron schedule on server-local time. `HERMES_TIMEZONE` overrides this key when set.
+The agent clock, cron schedules and time-aware tools follow this zone on every OS. Code run through `execute_code` also inherits it as `TZ` on Linux and macOS; on Windows those children keep the OS-configured zone instead (the Windows C runtime only parses POSIX-form `TZ` strings, and an IANA name there produces a wrong UTC offset), so set the Windows zone itself when child scripts must render local time in this zone.
+
## Discord
Configure Discord-specific behavior for the messaging gateway: