coerce_message_timestamp (gateway/message_timestamps.py)

hermes-agent · gateway/message_timestamps.py · python · MIT
chat

Utility to parse, format, and strip gateway message timestamps for consistent display.

# Source: https://github.com/NousResearch/hermes-agent | License: MIT | Copyright 2025 Nous Research
# Provided via justclaw.it.com; keep this notice with the code.
"""Helpers for rendering gateway message timestamps exactly once.

Gateway messages need timestamps in the LLM context for temporal awareness, but
persisted message content should stay clean so replay does not accumulate
``[timestamp] [timestamp] ...`` prefixes across turns.
"""

from __future__ import annotations

import errno
import re
import sys
import time
from datetime import datetime, timezone, UTC
from typing import Any, Optional, Tuple

from hermes_time import safe_strftime


# Leading timestamp prefix, either the current human format
# ``[Tue 2026-04-28 13:40:53 CEST]`` or the older ISO one
# ``[2026-04-13T17:02:06+020

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key