[Feat]: Tell the agent the current date (#7509)

This commit is contained in:
Rohit Malhotra
2025-03-27 01:23:12 -04:00
committed by GitHub
parent 8e9eb7d07d
commit 0df87bfacc
7 changed files with 21 additions and 2 deletions

View File

@@ -1,6 +1,7 @@
import asyncio
import os
import uuid
from datetime import datetime, timezone
from typing import Callable
import openhands
@@ -170,6 +171,7 @@ class Memory:
else '',
microagent_knowledge=microagent_knowledge,
content='Added workspace context',
date=self.runtime_info.date if self.runtime_info is not None else '',
)
return obs
return None
@@ -263,13 +265,17 @@ class Memory:
def set_runtime_info(self, runtime: Runtime) -> None:
"""Store runtime info (web hosts, ports, etc.)."""
# e.g. { '127.0.0.1': 8080 }
utc_now = datetime.now(timezone.utc)
date = str(utc_now.date())
if runtime.web_hosts or runtime.additional_agent_instructions:
self.runtime_info = RuntimeInfo(
available_hosts=runtime.web_hosts,
additional_agent_instructions=runtime.additional_agent_instructions,
date=date,
)
else:
self.runtime_info = None
self.runtime_info = RuntimeInfo(date=date)
def send_error_message(self, message_id: str, message: str):
"""Sends an error message if the callback function was provided."""