Skip to content

Commit cb24b0b

Browse files
committed
Merge branch 'feature/analytics-agent-current-date' into 'develop'
fix: inject current date/time into analytics agent system prompt See merge request genaiic-reusable-assets/engagement-artifacts/genaiic-idp-accelerator!614
2 parents a1edf22 + 5a8b4d0 commit cb24b0b

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

  • lib/idp_common_pkg/idp_common/agents/analytics

lib/idp_common_pkg/idp_common/agents/analytics/agent.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import logging
99
import os
10+
from datetime import datetime, timezone
1011
from typing import Any, Dict
1112

1213
import boto3
@@ -55,13 +56,19 @@ def create_analytics_agent(
5556
# Load database overview once during agent creation for embedding in system prompt
5657
database_overview = _get_database_overview()
5758

59+
# Current date and time to inform the agent in case it needs relative-time queries
60+
# This string looks like "3:14 PM (UTC) on April 9, 2026"
61+
current_date_string = datetime.now(timezone.utc).strftime(
62+
"%-I:%M %p (UTC) on %B %-d, %Y"
63+
)
64+
5865
# Define the system prompt for the analytics agent
5966
system_prompt = f""" # nosec B608 - AI agent prompt template, not SQL execution
6067
You are an AI agent that converts natural language questions into Athena queries, executes those queries, and writes python code to convert the query results into json representing either a plot, a table, or a string.
6168
6269
# Task
6370
Your task is to:
64-
1. Understand the user's question
71+
1. Understand the user's question (if necessary referring to the date and time when the question was asked, which is {current_date_string})
6572
2. **EFFICIENT APPROACH**: Review the database overview below to see available tables and their purposes
6673
3. Apply the Question-to-Table mapping rules below to select the correct tables for your query
6774
4. Use get_table_info(['table1', 'table2']) to get detailed schemas ONLY for the tables you need

0 commit comments

Comments
 (0)