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:
parent
5ca1b96988
commit
b603d9c6ba
@ -18,7 +18,7 @@ describe("injectTimestamp", () => {
|
|||||||
timezone: "America/New_York",
|
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", () => {
|
it("uses channel envelope format with DOW prefix", () => {
|
||||||
@ -28,7 +28,7 @@ describe("injectTimestamp", () => {
|
|||||||
const result = injectTimestamp("hello", { timezone: "America/New_York" });
|
const result = injectTimestamp("hello", { timezone: "America/New_York" });
|
||||||
|
|
||||||
// DOW prefix + formatZonedTimestamp format
|
// DOW prefix + formatZonedTimestamp format
|
||||||
expect(result).toBe(`[Current Date: Wed ${expected}] hello`);
|
expect(result).toBe(`[Wed ${expected}] hello`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("always uses 24-hour format", () => {
|
it("always uses 24-hour format", () => {
|
||||||
@ -43,14 +43,14 @@ describe("injectTimestamp", () => {
|
|||||||
const result = injectTimestamp("hello", { timezone: "America/Chicago" });
|
const result = injectTimestamp("hello", { timezone: "America/Chicago" });
|
||||||
|
|
||||||
// 8:30 PM EST = 7:30 PM CST = 19:30
|
// 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", () => {
|
it("defaults to UTC when no timezone specified", () => {
|
||||||
const result = injectTimestamp("hello", {});
|
const result = injectTimestamp("hello", {});
|
||||||
|
|
||||||
// 2026-01-29T01:30:00Z
|
// 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", () => {
|
it("returns empty/whitespace messages unchanged", () => {
|
||||||
@ -66,7 +66,7 @@ describe("injectTimestamp", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("does NOT double-stamp messages already injected by us", () => {
|
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" });
|
const result = injectTimestamp(alreadyStamped, { timezone: "America/New_York" });
|
||||||
|
|
||||||
expect(result).toBe(alreadyStamped);
|
expect(result).toBe(alreadyStamped);
|
||||||
@ -85,7 +85,7 @@ describe("injectTimestamp", () => {
|
|||||||
|
|
||||||
const result = injectTimestamp("hello", { timezone: "America/New_York" });
|
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)", () => {
|
it("handles date boundaries (just before midnight)", () => {
|
||||||
@ -93,19 +93,19 @@ describe("injectTimestamp", () => {
|
|||||||
|
|
||||||
const result = injectTimestamp("hello", { timezone: "America/New_York" });
|
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)", () => {
|
it("handles DST correctly (same UTC hour, different local time)", () => {
|
||||||
// EST (winter): UTC-5 → 2026-01-15T05:00Z = midnight Jan 15
|
// EST (winter): UTC-5 → 2026-01-15T05:00Z = midnight Jan 15
|
||||||
vi.setSystemTime(new Date("2026-01-15T05:00:00.000Z"));
|
vi.setSystemTime(new Date("2026-01-15T05:00:00.000Z"));
|
||||||
const winter = injectTimestamp("winter", { timezone: "America/New_York" });
|
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
|
// EDT (summer): UTC-4 → 2026-07-15T04:00Z = midnight Jul 15
|
||||||
vi.setSystemTime(new Date("2026-07-15T04:00:00.000Z"));
|
vi.setSystemTime(new Date("2026-07-15T04:00:00.000Z"));
|
||||||
const summer = injectTimestamp("summer", { timezone: "America/New_York" });
|
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", () => {
|
it("accepts a custom now date", () => {
|
||||||
@ -116,7 +116,7 @@ describe("injectTimestamp", () => {
|
|||||||
now: customDate,
|
now: customDate,
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(result).toMatch(/^\[Current Date: Fri 2025-07-04 12:00 EDT\]/);
|
expect(result).toMatch(/^\[Fri 2025-07-04 12:00 EDT\]/);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -53,14 +53,13 @@ export function injectTimestamp(message: string, opts?: TimestampInjectionOption
|
|||||||
const formatted = formatZonedTimestamp(now, timezone);
|
const formatted = formatZonedTimestamp(now, timezone);
|
||||||
if (!formatted) return message;
|
if (!formatted) return message;
|
||||||
|
|
||||||
// "Current Date:" label is unambiguous even for tiny models (1.7B+).
|
// 3-letter DOW: small models (8B) can't reliably derive day-of-week from
|
||||||
// 3-letter DOW included because small models can't derive it from a date.
|
// a date, and may treat a bare "Wed" as a typo. Costs ~1 token.
|
||||||
// Total cost: ~18 tokens — saves thousands when it prevents hallucination.
|
|
||||||
const dow = new Intl.DateTimeFormat("en-US", { timeZone: timezone, weekday: "short" }).format(
|
const dow = new Intl.DateTimeFormat("en-US", { timeZone: timezone, weekday: "short" }).format(
|
||||||
now,
|
now,
|
||||||
);
|
);
|
||||||
|
|
||||||
return `[Current Date: ${dow} ${formatted}] ${message}`;
|
return `[${dow} ${formatted}] ${message}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -163,7 +163,7 @@ describe("gateway agent handler", () => {
|
|||||||
await vi.waitFor(() => expect(mocks.agentCommand).toHaveBeenCalled());
|
await vi.waitFor(() => expect(mocks.agentCommand).toHaveBeenCalled());
|
||||||
|
|
||||||
const callArgs = mocks.agentCommand.mock.calls[0][0];
|
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 = {};
|
mocks.loadConfigReturn = {};
|
||||||
vi.useRealTimers();
|
vi.useRealTimers();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user