revert: drop "Current Date:" label, keep [Wed YYYY-MM-DD HH:MM TZ]

Small model testing showed the label did not meaningfully help:
- Sub-3B models fail regardless of format
- 8B models untested with label specifically
- Frontier models never needed it

The bracket convention [Wed 2026-01-28 22:30 EST] matches existing
channel envelope format and is widely present in training data.
Saves ~2-3 tokens per message vs the labeled version.
This commit is contained in:
Conroy Whitney
2026-01-28 22:40:48 -05:00
committed by Tak Hoffman
parent b6c8c1e89d
commit 8a5b139a9f
3 changed files with 14 additions and 15 deletions

View File

@@ -18,7 +18,7 @@ describe("injectTimestamp", () => {
timezone: "America/New_York",
});
expect(result).toMatch(/^\[Current Date: Wed 2026-01-28 20:30 EST\] Is it the weekend\?$/);
expect(result).toMatch(/^\[Wed 2026-01-28 20:30 EST\] Is it the weekend\?$/);
});
it("uses channel envelope format with DOW prefix", () => {
@@ -28,7 +28,7 @@ describe("injectTimestamp", () => {
const result = injectTimestamp("hello", { timezone: "America/New_York" });
// DOW prefix + formatZonedTimestamp format
expect(result).toBe(`[Current Date: Wed ${expected}] hello`);
expect(result).toBe(`[Wed ${expected}] hello`);
});
it("always uses 24-hour format", () => {
@@ -43,14 +43,14 @@ describe("injectTimestamp", () => {
const result = injectTimestamp("hello", { timezone: "America/Chicago" });
// 8:30 PM EST = 7:30 PM CST = 19:30
expect(result).toMatch(/^\[Current Date: Wed 2026-01-28 19:30 CST\]/);
expect(result).toMatch(/^\[Wed 2026-01-28 19:30 CST\]/);
});
it("defaults to UTC when no timezone specified", () => {
const result = injectTimestamp("hello", {});
// 2026-01-29T01:30:00Z
expect(result).toMatch(/^\[Current Date: Thu 2026-01-29 01:30/);
expect(result).toMatch(/^\[Thu 2026-01-29 01:30/);
});
it("returns empty/whitespace messages unchanged", () => {
@@ -66,7 +66,7 @@ describe("injectTimestamp", () => {
});
it("does NOT double-stamp messages already injected by us", () => {
const alreadyStamped = "[Current Date: Wed 2026-01-28 20:30 EST] hello there";
const alreadyStamped = "[Wed 2026-01-28 20:30 EST] hello there";
const result = injectTimestamp(alreadyStamped, { timezone: "America/New_York" });
expect(result).toBe(alreadyStamped);
@@ -85,7 +85,7 @@ describe("injectTimestamp", () => {
const result = injectTimestamp("hello", { timezone: "America/New_York" });
expect(result).toMatch(/^\[Current Date: Sun 2026-02-01 00:00 EST\]/);
expect(result).toMatch(/^\[Sun 2026-02-01 00:00 EST\]/);
});
it("handles date boundaries (just before midnight)", () => {
@@ -93,19 +93,19 @@ describe("injectTimestamp", () => {
const result = injectTimestamp("hello", { timezone: "America/New_York" });
expect(result).toMatch(/^\[Current Date: Sat 2026-01-31 23:59 EST\]/);
expect(result).toMatch(/^\[Sat 2026-01-31 23:59 EST\]/);
});
it("handles DST correctly (same UTC hour, different local time)", () => {
// EST (winter): UTC-5 → 2026-01-15T05:00Z = midnight Jan 15
vi.setSystemTime(new Date("2026-01-15T05:00:00.000Z"));
const winter = injectTimestamp("winter", { timezone: "America/New_York" });
expect(winter).toMatch(/^\[Current Date: Thu 2026-01-15 00:00 EST\]/);
expect(winter).toMatch(/^\[Thu 2026-01-15 00:00 EST\]/);
// EDT (summer): UTC-4 → 2026-07-15T04:00Z = midnight Jul 15
vi.setSystemTime(new Date("2026-07-15T04:00:00.000Z"));
const summer = injectTimestamp("summer", { timezone: "America/New_York" });
expect(summer).toMatch(/^\[Current Date: Wed 2026-07-15 00:00 EDT\]/);
expect(summer).toMatch(/^\[Wed 2026-07-15 00:00 EDT\]/);
});
it("accepts a custom now date", () => {
@@ -116,7 +116,7 @@ describe("injectTimestamp", () => {
now: customDate,
});
expect(result).toMatch(/^\[Current Date: Fri 2025-07-04 12:00 EDT\]/);
expect(result).toMatch(/^\[Fri 2025-07-04 12:00 EDT\]/);
});
});

View File

@@ -53,14 +53,13 @@ export function injectTimestamp(message: string, opts?: TimestampInjectionOption
const formatted = formatZonedTimestamp(now, timezone);
if (!formatted) return message;
// "Current Date:" label is unambiguous even for tiny models (1.7B+).
// 3-letter DOW included because small models can't derive it from a date.
// Total cost: ~18 tokens — saves thousands when it prevents hallucination.
// 3-letter DOW: small models (8B) can't reliably derive day-of-week from
// a date, and may treat a bare "Wed" as a typo. Costs ~1 token.
const dow = new Intl.DateTimeFormat("en-US", { timeZone: timezone, weekday: "short" }).format(
now,
);
return `[Current Date: ${dow} ${formatted}] ${message}`;
return `[${dow} ${formatted}] ${message}`;
}
/**

View File

@@ -163,7 +163,7 @@ describe("gateway agent handler", () => {
await vi.waitFor(() => expect(mocks.agentCommand).toHaveBeenCalled());
const callArgs = mocks.agentCommand.mock.calls[0][0];
expect(callArgs.message).toBe("[Current Date: Wed 2026-01-28 20:30 EST] Is it the weekend?");
expect(callArgs.message).toBe("[Wed 2026-01-28 20:30 EST] Is it the weekend?");
mocks.loadConfigReturn = {};
vi.useRealTimers();