feat: inject current date/time into system prompt dynamically

The model now knows today's date and time. _build_system_prompt()
generates a fresh prompt with "Today is Saturday, March 28, 2026.
The current time is 02:28 PM." on every agent.run() call.

Fixes: model was hallucinating "January 29, 2025" for date queries.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jon Saad-Falcon
2026-03-28 14:29:54 -07:00
co-authored by Claude Opus 4.6
parent 77a1c596b7
commit 7fd685f53a
+18 -3
View File
@@ -31,12 +31,23 @@ def _tc_args(tc: dict) -> str:
return tc["arguments"]
DEEP_RESEARCH_SYSTEM_PROMPT = """\
def _build_system_prompt() -> str:
"""Build the system prompt with the current date injected."""
from datetime import datetime
now = datetime.now()
date_str = now.strftime("%A, %B %d, %Y")
time_str = now.strftime("%I:%M %p")
return f"""\
/no_think
You are Jarvis, a personal AI assistant with access to the user's private \
knowledge base — emails, text messages, meeting notes, documents, and notes. \
You are helpful, conversational, and smart about when to use your tools.
**Today is {date_str}. The current time is {time_str}.** \
Use this for any time-related queries ("today", "this week", "recently", etc.).
## How to Respond
Read the query and decide which response type fits best:
@@ -134,6 +145,10 @@ abbreviations, related terms.
- If nothing found, say so honestly and suggest alternatives."""
# Backward-compatible constant (static snapshot, prefer _build_system_prompt())
DEEP_RESEARCH_SYSTEM_PROMPT = _build_system_prompt()
@AgentRegistry.register("deep_research")
class DeepResearchAgent(ToolUsingAgent):
"""Multi-hop research agent with native function calling and citations."""
@@ -199,9 +214,9 @@ class DeepResearchAgent(ToolUsingAgent):
) -> AgentResult:
self._emit_turn_start(input)
# Build system prompt and initial messages
# Build system prompt with current date/time injected
messages = self._build_messages(
input, context, system_prompt=DEEP_RESEARCH_SYSTEM_PROMPT
input, context, system_prompt=_build_system_prompt()
)
# Prepare OpenAI-format tool definitions for native function calling