Skip to content

fix(agents): default base image to UTC + ISO-Z file timestamps (#1795) - #1828

Merged
vybe merged 2 commits into
devfrom
feature/1795-agent-base-utc
Jul 28, 2026
Merged

vybe merged 2 commits into
devfrom
feature/1795-agent-base-utc

Conversation

@webmixgamer

Copy link
Copy Markdown
Contributor

Summary

  • The agent base image baked 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.
  • Agent-server file/credential/dashboard modified fields 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

  • A — docker/base-image/Dockerfile: ENV TZ=Etc/UTC (local == UTC; overridable at deploy via -e TZ=...).
  • B — agent_server/utils/helpers.py: new iso_z_from_mtime() → canonical ISO-Z UTC, independent of the container TZ.
    • Applied at all 6 file-metadata sites: routers/files.py (×4), routers/credentials.py, routers/dashboard.py; dropped the now-dead datetime imports.
  • tests/unit/test_1795_agent_timestamp_utc.py: helper correctness + TZ-independence + Dockerfile static guard.
  • Doc-sync: docs/memory/feature-flows/skills-on-agent-start.md snippet updated to match.

Test Plan

  • Unit assertions pass (helper output, TZ-independence, Dockerfile guard) — verified standalone (stdlib helper runs on 3.9).
  • /verify-local Docker stages green: base image builds, import agent_server succeeds inside the built image, and a real agent boots healthy from the rebuilt image.
  • /cso --diff clean (no new surface/auth/injection; Invariant Setup improvements #5 parity intact).
  • CI full unit + integration suite (local run was incomplete — no Python ≥3.10 on the dev box; environmental, not a defect).

Notes

  • Base-image change: existing agents adopt UTC on recreate, not restart (ENV is baked at build).
  • Frontend consumers (new Date()/parseUTC) render the zone-marked value correctly; backend proxies modified verbatim (no change needed).

Fixes #1795

🤖 Generated with Claude Code

webmixgamer and others added 2 commits July 27, 2026 17:20
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]>
@webmixgamer
webmixgamer requested a review from dolho July 27, 2026 17:02

@AndriiPasternak31 AndriiPasternak31 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions

Copy link
Copy Markdown

⚠️ Nightly unit-suite check skipped — merge conflict against dev.

Resolve by running git merge dev locally and pushing the result. The next nightly run will re-test once the conflict is gone.

@vybe
vybe merged commit 70adb69 into dev Jul 28, 2026
21 checks passed
pull Bot pushed a commit to bryanwills/trinity that referenced this pull request Jul 28, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants