[Feat]: Add timestamp info to CmdOutputObservation (#7514)

Co-authored-by: Xingyao Wang <xingyao@all-hands.dev>
Co-authored-by: Engel Nyst <enyst@users.noreply.github.com>
This commit is contained in:
Rohit Malhotra 2025-05-04 23:08:37 -04:00 committed by GitHub
parent 421b8e948d
commit a18e0dbbb6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -9,6 +9,7 @@ from pydantic import BaseModel
from openhands.core.logger import openhands_logger as logger
from openhands.core.schema import ObservationType
from openhands.events.observation.observation import Observation
from datetime import datetime, timezone
CMD_OUTPUT_PS1_BEGIN = '\n###PS1JSON###\n'
CMD_OUTPUT_PS1_END = '\n###PS1END###'
@ -161,6 +162,9 @@ class CmdOutputObservation(Observation):
ret += f'\n[Python interpreter: {self.metadata.py_interpreter_path}]'
if self.metadata.exit_code != -1:
ret += f'\n[Command finished with exit code {self.metadata.exit_code}]'
utc_now = datetime.now(timezone.utc)
ret += f'\n[Timestamp (UTC): {utc_now.strftime('%a %b %d %H:%M:%S %Z %Y')}]' # Formatted time, e.g Mon Mar 25 22:01:53 UTC 2025
return ret