feat: append UTC time alongside local time in shared Current time lines (#32423)

Merged via squash.

Prepared head SHA: 9e8ec13933
Co-authored-by: jriff <50276+jriff@users.noreply.github.com>
Co-authored-by: altaywtf <9790196+altaywtf@users.noreply.github.com>
Reviewed-by: @altaywtf
This commit is contained in:
Jacob Riff
2026-03-05 14:26:34 -08:00
committed by GitHub
parent 49acb07f9f
commit aad372e15f
6 changed files with 15 additions and 10 deletions

View File

@@ -140,6 +140,7 @@ Docs: https://docs.openclaw.ai
- Agents/failover cooldown classification: stop treating generic `cooling down` text as provider `rate_limit` so healthy models no longer show false global cooldown/rate-limit warnings while explicit `model_cooldown` markers still trigger failover. (#32972) thanks @stakeswky.
- Agents/failover service-unavailable handling: stop treating bare proxy/CDN `service unavailable` errors as provider overload while keeping them retryable via the timeout/failover path, so transient outages no longer show false rate-limit warnings or block fallback. (#36646) thanks @jnMetaCode.
- Agents/current-time UTC anchor: append a machine-readable UTC suffix alongside local `Current time:` lines in shared cron-style prompt contexts so agents can compare UTC-stamped workspace timestamps without doing timezone math. (#32423) thanks @jriff.
## 2026.3.2

View File

@@ -25,7 +25,8 @@ export function resolveCronStyleNow(cfg: TimeConfigLike, nowMs: number): CronSty
const userTimeFormat = resolveUserTimeFormat(cfg.agents?.defaults?.timeFormat);
const formattedTime =
formatUserTime(new Date(nowMs), userTimezone, userTimeFormat) ?? new Date(nowMs).toISOString();
const timeLine = `Current time: ${formattedTime} (${userTimezone})`;
const utcTime = new Date(nowMs).toISOString().replace("T", " ").slice(0, 16) + " UTC";
const timeLine = `Current time: ${formattedTime} (${userTimezone}) / ${utcTime}`;
return { userTimezone, formattedTime, timeLine };
}

View File

@@ -20,8 +20,9 @@ describe("resolveMemoryFlushPromptForRun", () => {
});
expect(prompt).toContain("memory/2026-02-16.md");
expect(prompt).toContain("Current time:");
expect(prompt).toContain("(America/New_York)");
expect(prompt).toContain(
"Current time: Monday, February 16th, 2026 — 10:00 AM (America/New_York) / 2026-02-16 15:00 UTC",
);
});
it("does not append a duplicate current time line", () => {

View File

@@ -203,7 +203,7 @@ Never modify memory/YYYY-MM-DD.md destructively.
`;
fs.writeFileSync(path.join(tmpDir, "AGENTS.md"), content);
const cfg = {
agents: { defaults: { userTimezone: "America/New_York" } },
agents: { defaults: { userTimezone: "America/New_York", timeFormat: "12" } },
} as OpenClawConfig;
// 2026-03-03 14:00 UTC = 2026-03-03 09:00 EST
const nowMs = Date.UTC(2026, 2, 3, 14, 0, 0);
@@ -211,8 +211,9 @@ Never modify memory/YYYY-MM-DD.md destructively.
expect(result).not.toBeNull();
expect(result).toContain("memory/2026-03-03.md");
expect(result).not.toContain("memory/YYYY-MM-DD.md");
expect(result).toContain("Current time:");
expect(result).toContain("America/New_York");
expect(result).toContain(
"Current time: Tuesday, March 3rd, 2026 — 9:00 AM (America/New_York) / 2026-03-03 14:00 UTC",
);
});
it("appends current time line even when no YYYY-MM-DD placeholder is present", async () => {

View File

@@ -11,13 +11,14 @@ describe("buildBareSessionResetPrompt", () => {
it("appends current time line so agents know the date", () => {
const cfg = {
agents: { defaults: { userTimezone: "America/New_York" } },
agents: { defaults: { userTimezone: "America/New_York", timeFormat: "12" } },
} as OpenClawConfig;
// 2026-03-03 14:00 UTC = 2026-03-03 09:00 EST
const nowMs = Date.UTC(2026, 2, 3, 14, 0, 0);
const prompt = buildBareSessionResetPrompt(cfg, nowMs);
expect(prompt).toContain("Current time:");
expect(prompt).toContain("America/New_York");
expect(prompt).toContain(
"Current time: Tuesday, March 3rd, 2026 — 9:00 AM (America/New_York) / 2026-03-03 14:00 UTC",
);
});
it("does not append a duplicate current time line", () => {

View File

@@ -354,7 +354,7 @@ describe("runCronIsolatedAgentTurn", () => {
const lines = call?.prompt?.split("\n") ?? [];
expect(lines[0]).toContain("[cron:job-1");
expect(lines[0]).toContain("do it");
expect(lines[1]).toMatch(/^Current time: .+ \(.+\)$/);
expect(lines[1]).toMatch(/^Current time: .+ \(.+\) \/ \d{4}-\d{2}-\d{2} \d{2}:\d{2} UTC$/);
});
});