From 2b425bdc50420c4f15dac33be1f25bf6e372a1ef Mon Sep 17 00:00:00 2001 From: Carl-Robert Linnupuu Date: Tue, 13 Jan 2026 15:33:59 +0000 Subject: [PATCH] fix: replace static dates in agent prompts --- .../ee/carlrobert/codegpt/agent/AgentSystemPrompts.kt | 8 +++++++- .../ee/carlrobert/codegpt/agent/tools/WebSearchTool.kt | 4 +++- src/main/resources/prompts/agent/anthropic.txt | 2 +- src/main/resources/prompts/agent/google.txt | 1 + src/main/resources/prompts/agent/openai.txt | 1 + 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/ee/carlrobert/codegpt/agent/AgentSystemPrompts.kt b/src/main/kotlin/ee/carlrobert/codegpt/agent/AgentSystemPrompts.kt index 7ddb7f6d..df8b387d 100644 --- a/src/main/kotlin/ee/carlrobert/codegpt/agent/AgentSystemPrompts.kt +++ b/src/main/kotlin/ee/carlrobert/codegpt/agent/AgentSystemPrompts.kt @@ -4,9 +4,12 @@ import ee.carlrobert.codegpt.settings.models.ModelRegistry import ee.carlrobert.codegpt.settings.models.ModelSelection import ee.carlrobert.codegpt.settings.service.ServiceType import ee.carlrobert.codegpt.util.file.FileUtil +import java.time.LocalDate +import java.time.format.DateTimeFormatter internal object AgentSystemPrompts { private const val WORKING_DIRECTORY_TOKEN = "{{WORKING_DIRECTORY}}" + private const val CURRENT_DATE_TOKEN = "{{CURRENT_DATE}}" private const val OPENAI_KEY = "openai" private const val GEMINI_KEY = "gemini" @@ -55,7 +58,10 @@ internal object AgentSystemPrompts { private fun renderPrompt(key: String, projectPath: String?): String { val workingDirectory = projectPath ?: "unknown" - return getPrompt(key).replace(WORKING_DIRECTORY_TOKEN, workingDirectory) + val currentDate = LocalDate.now().format(DateTimeFormatter.ISO_LOCAL_DATE) + return getPrompt(key) + .replace(WORKING_DIRECTORY_TOKEN, workingDirectory) + .replace(CURRENT_DATE_TOKEN, currentDate) } private fun getPrompt(key: String): String { diff --git a/src/main/kotlin/ee/carlrobert/codegpt/agent/tools/WebSearchTool.kt b/src/main/kotlin/ee/carlrobert/codegpt/agent/tools/WebSearchTool.kt index 1879cb0c..237967f6 100644 --- a/src/main/kotlin/ee/carlrobert/codegpt/agent/tools/WebSearchTool.kt +++ b/src/main/kotlin/ee/carlrobert/codegpt/agent/tools/WebSearchTool.kt @@ -10,6 +10,8 @@ import kotlinx.serialization.Serializable import org.jsoup.Jsoup import java.net.URLEncoder import java.nio.charset.StandardCharsets +import java.time.LocalDate +import java.time.format.DateTimeFormatter class WebSearchTool( private val userAgent: String = "Mozilla/5.0 (compatible; ProxyAI/1.0; +https://tryproxy.io)" @@ -46,7 +48,7 @@ Usage notes: - Web search is only available in the US IMPORTANT - Use the correct year in search queries: - - Today's date is 2025-12-04. You MUST use this year when searching for recent information, documentation, or current events. + - Today's date is ${LocalDate.now().format(DateTimeFormatter.ISO_LOCAL_DATE)}. You MUST use this year when searching for recent information, documentation, or current events. - Example: If today is 2025-07-15 and the user asks for "latest React docs", search for "React documentation 2025", NOT "React documentation 2024" """.trimIndent() ) { diff --git a/src/main/resources/prompts/agent/anthropic.txt b/src/main/resources/prompts/agent/anthropic.txt index 2e9dbbf3..937824f3 100644 --- a/src/main/resources/prompts/agent/anthropic.txt +++ b/src/main/resources/prompts/agent/anthropic.txt @@ -105,7 +105,7 @@ You can use the following tools without requiring user approval: Bash(curl:*), B Here is useful information about the environment you are running in: Working directory: {{WORKING_DIRECTORY}} -Today's date: 2025-12-04 +Today's date: {{CURRENT_DATE}} IMPORTANT: Assist with authorized security testing, defensive security, CTF challenges, and educational contexts. Refuse requests for destructive techniques, DoS attacks, mass targeting, supply chain compromise, or detection evasion for malicious purposes. Dual-use security tools (C2 frameworks, credential testing, exploit development) require clear authorization context: pentesting engagements, CTF competitions, security research, or defensive use cases. diff --git a/src/main/resources/prompts/agent/google.txt b/src/main/resources/prompts/agent/google.txt index 85a18d5d..168d1ade 100644 --- a/src/main/resources/prompts/agent/google.txt +++ b/src/main/resources/prompts/agent/google.txt @@ -1,6 +1,7 @@ You are a ProxyAI Agent, a JetBrains IDE assistant specializing in software engineering tasks. Your primary goal is to help users safely and efficiently, adhering strictly to the following instructions and utilizing your available tools. Working directory: {{WORKING_DIRECTORY}} +Today's date: {{CURRENT_DATE}} # Core Mandates diff --git a/src/main/resources/prompts/agent/openai.txt b/src/main/resources/prompts/agent/openai.txt index cbfe7899..d0cf6bfe 100644 --- a/src/main/resources/prompts/agent/openai.txt +++ b/src/main/resources/prompts/agent/openai.txt @@ -6,6 +6,7 @@ Your capabilities: - Emit tool calls to read, search, edit, and write files, plus run shell commands when needed. Working directory: {{WORKING_DIRECTORY}} +Today's date: {{CURRENT_DATE}} # How you work