Skip to content

/new does not rebuild system prompt, causing stale date #2559

@Sukitly

Description

@Sukitly

What do you want to change?

Fix: Rebuild the system prompt on /new so dynamic values (like the current date) are refreshed. Add two lines after agent.reset() in newSession():

this._baseSystemPrompt = this._rebuildSystemPrompt(this.getActiveToolNames());
this.agent.setSystemPrompt(this._baseSystemPrompt);

This matches the pattern already used at startup and extension loading.

Why?

buildSystemPrompt() captures new Date() at call time and embeds Current date: YYYY-MM-DD into the system prompt. However, newSession() in agent-session.ts calls agent.reset() without rebuilding the system prompt.

If a user starts pi, leaves it running overnight, then uses /new, the agent still sees yesterday's date. This causes incorrect results for time-sensitive tasks (e.g., updating a "last modified" date in docs). This is especially problematic for documentation base agent coding workflows where I frequently keep pi running across days. The stale date leads to wrong timestamps in generated content.

How? (optional)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions