feat(gateway): inject current timestamp into user messages#5487
Open
willy-scr wants to merge 4 commits into
Open
feat(gateway): inject current timestamp into user messages#5487willy-scr wants to merge 4 commits into
willy-scr wants to merge 4 commits into
Conversation
3132311 to
6d334bc
Compare
Prepend a human-readable timestamp to every user message before passing it to the agent. The agent can then answer time-aware questions (e.g. "what day is it?") without spending a tool call on `date`. Format: [Current time: Monday, April 06, 2026 07:36 AM] Uses locale-aware strftime with en_US fallback for consistent English day/month names.
…s no display field
fe5e30d to
0cbcfab
Compare
This was referenced Apr 29, 2026
|
Closing this as superseded by #17459/#17476. The need is real, but we do not want a separate gateway-only timestamp-prefix mechanism. The chosen direction is one core ephemeral runtime/user-message context path for current time + timezone, with time-sensitive tools also returning explicit advisory metadata when relevant (#17474). If there are useful tests or gateway adapter details here, please port them into the consolidated implementation rather than keeping this as a parallel feature flag. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Injects a human-readable timestamp at the top of every user message before it reaches the agent, so the agent always knows the current date and time without needing to invoke a tool call.
Format:
[Current time: Monday, April 06, 2026 07:36 AM]Why
Agents running long conversations often lose track of time. The only built-in mechanism is the
Conversation started:header, which becomes stale after minutes or hours of back-and-forth. Currently the agent must spend adatetool call just to answer "what time is it?" or "what day is today?" — wasting tokens and latency.This is especially important for:
What Changed
Core Injection (
gateway/run.py)Inside
_run_agent(), right beforeagent.run_conversation():display.gateway_timestampconfig (default:true)datetime.now()en_US.UTF-8for consistent day/month names (with graceful fallback)Monday, April 06, %Y %I:%M %p[Current time: ...]\n\nto the messageConfig Toggle (
hermes_cli/config.py)display.gateway_timestamp: truetoDEFAULT_CONFIGconfig.yaml— survives restartsSlash Command (
hermes_cli/commands.py+gateway/run.py)/timestamps(alias/ts) command — toggles injection on/offconfig.yamlDesign Decisions
datetime.now()instead of injecting into system prompten_US.UTF-8with try/except fallback_run_agent(gateway path)trueTesting
Manual testing on self-hosted instance:
_run_agentpath)en_USlocale (falls back to server default)/timestampstoggle works — ON/OFF states persist across messages and restartsdisplay.gateway_timestamp: falsecorrectly disables injection