fix: inject current date into WebSearchTool description

Make WebSearchTool.Description() dynamic so the LLM sees today's date
exactly at the point where it constructs search queries. Previously, the
static description caused the model to default to its training-cutoff
year for time-relative queries (e.g. "yesterday's AI news").

Fixes #754
This commit is contained in:
mqyang56 2026-02-26 10:12:33 +08:00
parent 094d65916d
commit 771169e32f

View file

@ -449,7 +449,7 @@ func (t *WebSearchTool) Name() string {
}
func (t *WebSearchTool) Description() string {
return "Search the web for current information. Returns titles, URLs, and snippets from search results."
return fmt.Sprintf("Search the web for current information. Returns titles, URLs, and snippets from search results. Today's date is %s. When constructing queries about recent events, use this date as reference.", time.Now().Format("2006-01-02"))
}
func (t *WebSearchTool) Parameters() map[string]any {