Repository navigation
fix(agents): default base image to UTC + ISO-Z file timestamps (#1795) - #1828
Conversation
ENV TZ=America/New_York made every agent run on US Eastern regardless of operator location — disagreeing with its own /etc/localtime (Etc/UTC), the backend, and the scheduler. Agent-server file/credential/dashboard "modified" fields were naive local strings that consumers treating naive ISO as UTC (Invariant #16) rendered hours in the past. - Dockerfile: ENV TZ=Etc/UTC (overridable at deploy via -e TZ=...) - new iso_z_from_mtime() -> canonical ISO-Z UTC, independent of container TZ - applied at all 6 file-metadata sites (files x4, credentials, dashboard) - test: helper correctness + TZ-independence + Dockerfile static guard Fixes #1795 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The initial #1795 change imported the shared iso_z_from_mtime helper into routers/files.py via a relative import. tests/unit/test_ent183_skill_packages loads files.py by path (no package context) to verify its protected-path logic, so the relative import broke that standalone load — the regression-diff CI job reported 1 new failure (test_skill_dirs_are_not_protected_paths) while the plain pytest jobs stayed green. Keep files.py dependency-free with a module-local _iso_z_from_mtime; credentials.py/dashboard.py (not standalone-loaded) keep the shared helper. - files.py: module-local _iso_z_from_mtime instead of `from ..utils.helpers` - test_1795: guard the standalone load + local-vs-shared helper drift - doc: match the local helper name Refs #1795 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
AndriiPasternak31
left a comment
There was a problem hiding this comment.
Validated via /validate-pr. Clean PR — approving.
Traceability — Fixes #1795 resolves to an open P2 type-bug theme-reliability issue, so the merge-time status promotion will fire. Security/packaging — no secrets, emails, or public IPs in the diff; no new top-level src/backend/*.py and no new os.getenv(), so neither the #1033 Dockerfile-COPY nor the #1056 compose-wiring gap applies. Docs — bug fix, so commit message is the bar; the skills-on-agent-start.md snippet sync is a nice extra. Tests — test_1795_agent_timestamp_utc.py covers helper correctness, TZ-independence, and a static Dockerfile guard, which is the part that actually stops this regressing.
The two-part diagnosis is right, and it matters that both halves shipped together: flipping ENV TZ alone would have left the naive datetime.fromtimestamp(...).isoformat() timestamps wrong for any operator who overrides TZ at deploy, and fixing only the timestamps would have left agents reasoning in Eastern.
Two non-blocking notes:
1. The helper is duplicated. iso_z_from_mtime is defined in agent_server/utils/helpers.py and re-declared as _iso_z_from_mtime in agent_server/routers/files.py. The rationale is documented — tests/unit/test_ent183_skill_packages.py loads files.py by path with no package context, so a relative import breaks the load — but that's a test loader dictating production structure, and it leaves two copies where only one is covered by the helper test. If they ever drift, files.py (4 of the 6 call sites) is the copy that drifts silently. Fixing the loader to import with package context would let both sites share the one helper.
2. Worth a release note. Agents move from America/New_York to UTC on recreate, not restart. Combined with the #1809 cold-start adoption predicate, an operator gets this the next time an agent cold-starts — so any agent skill or prompt doing local-time reasoning shifts 4–5h with no obvious trigger. Cheap to call out in the notes; expensive to debug in the field.
Neither blocks. 18/18 checks green, /verify-local Docker stages run by the author including a real agent boot from the rebuilt base image.
|
Resolve by running |
…tyai#1795) (Abilityai#1828) * fix(agents): default base image to UTC + ISO-Z file timestamps (Abilityai#1795) ENV TZ=America/New_York made every agent run on US Eastern regardless of operator location — disagreeing with its own /etc/localtime (Etc/UTC), the backend, and the scheduler. Agent-server file/credential/dashboard "modified" fields were naive local strings that consumers treating naive ISO as UTC (Invariant #16) rendered hours in the past. - Dockerfile: ENV TZ=Etc/UTC (overridable at deploy via -e TZ=...) - new iso_z_from_mtime() -> canonical ISO-Z UTC, independent of container TZ - applied at all 6 file-metadata sites (files x4, credentials, dashboard) - test: helper correctness + TZ-independence + Dockerfile static guard Fixes Abilityai#1795 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * fix(agents): keep files.py standalone-importable (Abilityai#1795 regression-diff) The initial Abilityai#1795 change imported the shared iso_z_from_mtime helper into routers/files.py via a relative import. tests/unit/test_ent183_skill_packages loads files.py by path (no package context) to verify its protected-path logic, so the relative import broke that standalone load — the regression-diff CI job reported 1 new failure (test_skill_dirs_are_not_protected_paths) while the plain pytest jobs stayed green. Keep files.py dependency-free with a module-local _iso_z_from_mtime; credentials.py/dashboard.py (not standalone-loaded) keep the shared helper. - files.py: module-local _iso_z_from_mtime instead of `from ..utils.helpers` - test_1795: guard the standalone load + local-vs-shared helper drift - doc: match the local helper name Refs Abilityai#1795 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Summary
ENV TZ=America/New_York, so every agent container ran on US Eastern regardless of operator location — disagreeing with its own/etc/localtime(Etc/UTC), the backend, and the scheduler.modifiedfields were emitted as naive local strings; consumers treating naive ISO as UTC (Invariant #16) rendered a just-written file "hours ago" (e.g. 4h for a UTC viewer, 7h for UTC+3).Changes
docker/base-image/Dockerfile:ENV TZ=Etc/UTC(local == UTC; overridable at deploy via-e TZ=...).agent_server/utils/helpers.py: newiso_z_from_mtime()→ canonical ISO-Z UTC, independent of the container TZ.routers/files.py(×4),routers/credentials.py,routers/dashboard.py; dropped the now-deaddatetimeimports.tests/unit/test_1795_agent_timestamp_utc.py: helper correctness + TZ-independence + Dockerfile static guard.docs/memory/feature-flows/skills-on-agent-start.mdsnippet updated to match.Test Plan
/verify-localDocker stages green: base image builds,import agent_serversucceeds inside the built image, and a real agent boots healthy from the rebuilt image./cso --diffclean (no new surface/auth/injection; Invariant Setup improvements #5 parity intact).incomplete— no Python ≥3.10 on the dev box; environmental, not a defect).Notes
ENVis baked at build).new Date()/parseUTC) render the zone-marked value correctly; backend proxiesmodifiedverbatim (no change needed).Fixes #1795
🤖 Generated with Claude Code