fix(heartbeat): inject shared current time context into phase 1

This commit is contained in:
Xubin Ren
2026-03-16 10:52:26 +08:00
committed by Xubin Ren
parent 0dda2b23e6
commit 5d1528a5f3
4 changed files with 17 additions and 25 deletions
+3 -5
View File
@@ -3,11 +3,11 @@
import base64
import mimetypes
import platform
import time
from datetime import datetime
from pathlib import Path
from typing import Any
from nanobot.utils.helpers import current_time_str
from nanobot.agent.memory import MemoryStore
from nanobot.agent.skills import SkillsLoader
from nanobot.utils.helpers import build_assistant_message, detect_image_mime
@@ -99,9 +99,7 @@ Reply directly with text for conversations. Only use the 'message' tool to send
@staticmethod
def _build_runtime_context(channel: str | None, chat_id: str | None) -> str:
"""Build untrusted runtime metadata block for injection before the user message."""
now = datetime.now().strftime("%Y-%m-%d %H:%M (%A)")
tz = time.strftime("%Z") or "UTC"
lines = [f"Current Time: {now} ({tz})"]
lines = [f"Current Time: {current_time_str()}"]
if channel and chat_id:
lines += [f"Channel: {channel}", f"Chat ID: {chat_id}"]
return ContextBuilder._RUNTIME_CONTEXT_TAG + "\n" + "\n".join(lines)