From 088984a8d44ebce80195599380c92233e26c1bee Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Thu, 26 Feb 2026 20:22:17 +0900 Subject: [PATCH] fix: remove Current date from env context since OpenCode already provides it date is already injected by OpenCode's system.ts. omo-env now contains only Timezone and Locale, which are stable across requests and never break cache. --- src/agents/env-context.test.ts | 11 ++++++----- src/agents/env-context.ts | 9 --------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/agents/env-context.test.ts b/src/agents/env-context.test.ts index ea863167..718e76a9 100644 --- a/src/agents/env-context.test.ts +++ b/src/agents/env-context.test.ts @@ -4,7 +4,7 @@ import { describe, test, expect } from "bun:test" import { createEnvContext } from "./env-context" describe("createEnvContext", () => { - test("returns omo-env block with date, timezone, and locale", () => { + test("returns omo-env block with timezone and locale", () => { // #given - no setup needed // #when @@ -13,9 +13,9 @@ describe("createEnvContext", () => { // #then expect(result).toContain("") expect(result).toContain("") - expect(result).toContain("Current date:") expect(result).toContain("Timezone:") expect(result).toContain("Locale:") + expect(result).not.toContain("Current date:") }) test("does not include time with seconds precision to preserve token cache", () => { @@ -28,13 +28,14 @@ describe("createEnvContext", () => { expect(result).not.toMatch(/\d{1,2}:\d{2}:\d{2}/) }) - test("does not include Current time field", () => { - // #given - time field (even without seconds) changes every minute, degrading cache + test("does not include date or time fields since OpenCode already provides them", () => { + // #given - OpenCode's system.ts already injects date, platform, working directory // #when const result = createEnvContext() - // #then - time field entirely removed; date-level precision is sufficient + // #then - only timezone and locale remain; both are stable across requests + expect(result).not.toContain("Current date:") expect(result).not.toContain("Current time:") }) }) diff --git a/src/agents/env-context.ts b/src/agents/env-context.ts index 4dc7412a..c8e542b4 100644 --- a/src/agents/env-context.ts +++ b/src/agents/env-context.ts @@ -5,20 +5,11 @@ * See: https://github.com/code-yeongyu/oh-my-opencode/issues/379 */ export function createEnvContext(): string { - const now = new Date() const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone const locale = Intl.DateTimeFormat().resolvedOptions().locale - const dateStr = now.toLocaleDateString(locale, { - weekday: "short", - year: "numeric", - month: "short", - day: "numeric", - }) - return ` - Current date: ${dateStr} Timezone: ${timezone} Locale: ${locale} `