Skip to content

buildTimeSection only injects timezone, not the formatted date — agent uses wrong year #17633

@nicholaspapadam-wq

Description

@nicholaspapadam-wq

Description

buildTimeSection() in system-prompt.ts only outputs the user's timezone in the system prompt, but does not include the formatted date/time string (userTime). This causes the LLM to fall back to its training data cutoff year when referencing dates (e.g., writing 2025-02-15 instead of 2026-02-15 for memory file paths).

Current behavior

The system prompt includes:

## Current Date & Time
Time zone: America/New_York

The agent has no reliable way to know the current date and guesses wrong.

Expected behavior

## Current Date & Time
Now: Saturday, February 15th, 2026 — 7:47 PM
Time zone: America/New_York

Root cause

buildTimeSection() receives only { userTimezone } but the caller (buildAgentSystemPrompt) already has access to userTime via params — it's computed by formatUserTime() in buildSystemPromptParams() and passed through, but never used.

// current code
function buildTimeSection(params) {
    if (!params.userTimezone) return [];
    return [
        "## Current Date & Time",
        `Time zone: ${params.userTimezone}`,
        ""
    ];
}

// call site
...buildTimeSection({ userTimezone }),  // userTime not passed

Suggested fix

function buildTimeSection(params) {
    if (!params.userTimezone) return [];
    const lines = ["## Current Date & Time"];
    if (params.userTime) lines.push(`Now: ${params.userTime}`);
    lines.push(`Time zone: ${params.userTimezone}`, "");
    return lines;
}

// call site
const userTime = params.userTime?.trim();
...buildTimeSection({ userTimezone, userTime }),

Impact

  • Memory flush creates files with wrong year (e.g., memory/2025-02-15.md instead of memory/2026-02-15.md)
  • Any date-sensitive agent behavior is unreliable
  • Affects all sessions (interactive, cron, sub-agents)

Version

[email protected]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions