Add current date to query rewrite and chat answer prompts - #3068
Open
John CSA (jluocsa) wants to merge 8 commits into
Open
Add current date to query rewrite and chat answer prompts#3068John CSA (jluocsa) wants to merge 8 commits into
John CSA (jluocsa) wants to merge 8 commits into
Conversation
Collaborator
|
I love this change, thank you for making it - I've been meaning to add the date for a while. I'll verify it locally as well and run some evals too, since it changes the prompt. |
Collaborator
|
John CSA (@jluocsa) I think the pytest snapshots haven't been updated? See the failing CI. |
Pamela Fox (pamelafox)
requested changes
Jun 2, 2026
Pamela Fox (pamelafox)
left a comment
Collaborator
There was a problem hiding this comment.
Please update snapshot tests
… snapshots cover it
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.
Purpose
Fixes #2952.
The LLM has no inherent knowledge of the current date, so it cannot reason about
relative time references such as "today", "last week", "this month", or "current"
in either query rewriting or answer generation. This PR injects the current date
into both the query rewrite prompt and the chat answer prompt so the model can
resolve relative time references into concrete terms.
Changes:
Approach.get_current_date()which returns today's date formatted as e.g.February 3, 2026.current_datevariable into:run_until_final_call),chatreadretrieveread.py(run_search_approach),approach.py.chat_answer.system.jinja2andquery_rewrite.system.jinja2to render adate instruction only when
current_dateis provided ({% if current_date %}),so existing behavior is unchanged when the variable is absent.
tests/test_chatapproach.pycovering presence/absence of thedate in the rendered prompts and the date format.
Does this introduce a breaking change?
The prompt additions are guarded by
{% if current_date %}, so prompts renderidentically when the variable is not supplied.
Does this require changes to learn.microsoft.com docs?
Type of change
Code quality checklist
python -m pytest).python -m pytest --covto verify 100% coverage of added linesty checkto check for type errorsruffandblackmanually on my code.