Conversation
…turn system note The system prompt bakes in "Conversation started: <date>" and stays byte-stable for the life of a conversation (prompt-cache invariant), so a session running past midnight leaves the model with a stale idea of today's date. maybe_date_change_note() tracks the last announced date on the agent and, on a genuine rollover, emits a one-line note delivered through the existing gateway-notes / api_content sidecar channel — the same byte-stable per-turn user-message path used for auto-reset notes — so the system prompt and cache prefix are never touched. First call seeds quietly (fresh/restored agents announce only real rollovers), matching the source behavior.
Contributor
૮ >ﻌ< ა ci reviewran on 38929da
|
Related: #75425 is an open alternative for the long-lived-session date problem. This PR instead uses the per-turn api_content sidecar and leaves the prompt cache prefix untouched. |
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
Sessions that run past midnight now get a one-line date-change note on the next turn, so the model stops reasoning with a stale date. The system prompt bakes in
Conversation started: <date>and is deliberately byte-stable for the life of a conversation (prompt-cache invariant) — this port announces rollovers on the per-turn user-message channel instead of ever touching the prompt.Ported from MoonshotAI/kimi-code#2564 (their
date_changecontext-injection provider), adapted to Hermes' existing gateway-notes /api_contentsidecar mechanism in the turn prologue.Changes
agent/turn_context.py: newmaybe_date_change_note(agent, now=None)— tracks the last announced date onagent._last_known_date; first call seeds quietly (fresh/restored agents announce only genuine rollovers, matching the source's quiet-seed behavior); on rollover returns a[System note: ... it is now <date> (was <date>) ...]line. Wired intobuild_turn_contextalongside the gateway must-deliver notes, so it rides the existingapi_contentsidecar (persisted and replayed byte-for-byte — the cache prefix never diverges) and the multimodal text-part fallback for free.tests/agent/test_date_change_note.py: 6 tests (quiet seed, same-day silence, rollover announce, announce-once, multi-day gap, tracker update).Validation
Infographic