Repository navigation
fix(agent): inject today's date into the system prompt - #137
Merged
Merged
Conversation
… queries resolve correctly Closes #136. The system prompt was a static const export, so the model had no idea what 'today' actually was — it filled the blank with its training-time notion of 'now' and passed wrong date_from values to the time-aware tools whenever the user said 'this week' / 'last 30 days' / 'today'. Convert AGENT_SYSTEM_PROMPT into buildAgentSystemPrompt(now: Date) so the date is interpolated per request. Adds a 'Current context' section right after the persona block: Today's date is **YYYY-MM-DD** (UTC). When the user says 'today' / 'yesterday' / 'this week' / 'last 30 days' / 'last month', compute the date range from this anchor and pass it as date_from (and date_to when relevant) to the time-aware tools. Never invent a different 'now'. Rule 7 ('Respect the user's window') was already in the prompt but unreachable without an anchor; now it has one. chat/route.ts calls the builder with new Date() per turn — the route is already dynamic (no Cache Components / no 'use cache' anywhere near agent paths) so freshness is free.
4 of 12 tasks
gkhngyk
added a commit
that referenced
this pull request
Jun 22, 2026
The Site Audit recommendation prompt never told the model what 'today' is, so for source-suggesting signals (outbound-authority-links, citation-density, statistic-density) gemini-3 fell back to its training-data sense of 'now' and proposed stale (e.g. 2024) references. Inject today's date (derived from ctx.now) at the top of the prompt and tell the model to prefer the most recent, currently-authoritative sources and not present older material as current — plus an explicit 'never invent URLs or fabricate statistics/dates' guard. Mirrors the date injection the Agent already does (#137). Display/prompt-only change; signal scoring is untouched.
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #136.
What
AGENT_SYSTEM_PROMPTis now a builder —buildAgentSystemPrompt(now: Date)— and the chat route calls it per turn withnew Date(). The interpolated date lands in a new Current context section right after the persona block:Why
The previous static prompt left the model to guess 'now' from its training data.
claude-sonnet-4-6typically picked something in 2024–2025, so any window-based question (e.g. "what's today's best prompt?", "how did the trend look last week?") ended up running against a wrongdate_from. Rule 7 in the prompt explicitly asked the model to respect the user's window, but without a real anchor it couldn't.Test plan
get_visibility_trendtool call (expandable via the tool disclosure UI) —date_fromshould be ~7 days before today's actual date, not a 2024 / 2025 valueOut of scope