feat: added runtime environment summary to system prompt

This commit is contained in:
Shukfan Law 2026-02-04 22:17:35 +08:00
parent 795f8105a0
commit 22156d3a40

View File

@ -2,6 +2,7 @@
import base64 import base64
import mimetypes import mimetypes
import platform
from pathlib import Path from pathlib import Path
from typing import Any from typing import Any
@ -74,6 +75,7 @@ Skills with available="false" need dependencies installed first - you can try in
from datetime import datetime from datetime import datetime
now = datetime.now().strftime("%Y-%m-%d %H:%M (%A)") now = datetime.now().strftime("%Y-%m-%d %H:%M (%A)")
workspace_path = str(self.workspace.expanduser().resolve()) workspace_path = str(self.workspace.expanduser().resolve())
runtime_summary = self._get_runtime_environment_summary()
return f"""# nanobot 🐈 return f"""# nanobot 🐈
@ -87,6 +89,9 @@ You are nanobot, a helpful AI assistant. You have access to tools that allow you
## Current Time ## Current Time
{now} {now}
## Runtime Environment
{runtime_summary}
## Workspace ## Workspace
Your workspace is at: {workspace_path} Your workspace is at: {workspace_path}
- Memory files: {workspace_path}/memory/MEMORY.md - Memory files: {workspace_path}/memory/MEMORY.md
@ -99,6 +104,19 @@ For normal conversation, just respond with text - do not call the message tool.
Always be helpful, accurate, and concise. When using tools, explain what you're doing. Always be helpful, accurate, and concise. When using tools, explain what you're doing.
When remembering something, write to {workspace_path}/memory/MEMORY.md""" When remembering something, write to {workspace_path}/memory/MEMORY.md"""
def _get_runtime_environment_summary(self) -> str:
system = platform.system()
system_map = {"Darwin": "MacOS", "Windows": "Windows", "Linux": "Linux"}
system_label = system_map.get(system, system)
release = platform.release()
machine = platform.machine()
python_version = platform.python_version()
node = platform.node()
return (
f"Runtime environment: OS {system_label} {release} ({machine}), "
f"Python {python_version}, Hostname {node}."
)
def _load_bootstrap_files(self) -> str: def _load_bootstrap_files(self) -> str:
"""Load all bootstrap files from workspace.""" """Load all bootstrap files from workspace."""