Skip to content

JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.

Python

fix: 系统时间获取有误

cycong_169a8b6adf1ec
diff --git a/jiuwenclaw/agentserver/deep_agent/rails/runtime_prompt_rail.py b/jiuwenclaw/agentserver/deep_agent/rails/runtime_prompt_rail.py
index 0f01ba3e4b..0b2923ac05 100644
--- a/jiuwenclaw/agentserver/deep_agent/rails/runtime_prompt_rail.py
+++ b/jiuwenclaw/agentserver/deep_agent/rails/runtime_prompt_rail.py
@@ -88,11 +88,12 @@ class RuntimePromptRail(DeepAgentRail):
now = datetime.now(tz=self._tz)
now_str = now.strftime("%Y-%m-%d %H:%M:%S")
current_year = now.strftime("%Y")
+ weekday_cn = _CN_WEEKDAYS[now.weekday()]
if self._language == "cn":
time_content = (
f"# 当前日期与时间\n\n"
- f"- 当前时间:{now_str}\n"
+ f"- 当前时间:{now_str}({weekday_cn})\n"
f"- 当前年份:{current_year}\n"
"- 当用户询问“最新、当前、今年、本年、实时、近期”等信息并需要搜索时,"
"搜索 query 必须优先使用当前年份或日期"
@@ -100,7 +101,7 @@ class RuntimePromptRail(DeepAgentRail):
else:
time_content = (
f"# Current Date & Time\n\n"
- f"- Current time: {now_str}\n"
+ f"- Current time: {now_str} ({now.strftime('%A')})\n"
f"- Current year: {current_year}\n"
"- When the user asks for latest/current/this-year/recent information and search is needed, "
"search queries must prefer the current year or date."
diff --git a/jiuwenclaw/agentserver/interface.py b/jiuwenclaw/agentserver/interface.py
index ad0bc4eec3..a64b764702 100644
--- a/jiuwenclaw/agentserver/interface.py
+++ b/jiuwenclaw/agentserver/interface.py
@@ -16,6 +16,7 @@ import logging
import time
from typing import Any, AsyncIterator, Tuple
+from datetime import datetime, timedelta, timezone
from dotenv import load_dotenv
from jiuwenclaw.agentserver.agent_adapters import (
@@ -85,9 +86,15 @@ def build_user_prompt(content: str, files: dict, channel: str, language: str) ->
},
ensure_ascii=False,
)
+
+ now = datetime.now(timezone(timedelta(hours=8)))
+ now_str = now.strftime("%Y-%m-%d %H:%M:%S")
+
return prompt + json.dumps(
{
"source": channel,
+ "timezone": "Asia/Shanghai",
+ "timestamp": now_str,
"preferred_response_language": language,
"content": content,
"files_updated_by_user": json.dumps(files, ensure_ascii=False),