Skip to content

feat(gateway): hot-reload memory_char_limit and user_char_limit - #39454

Open
Gabreil-Lu wants to merge 1 commit into
NousResearch:mainfrom
Gabreil-Lu:feat/memory-char-limit-hot-reload
Open

feat(gateway): hot-reload memory_char_limit and user_char_limit#39454
Gabreil-Lu wants to merge 1 commit into
NousResearch:mainfrom
Gabreil-Lu:feat/memory-char-limit-hot-reload

Conversation

@Gabreil-Lu

Copy link
Copy Markdown

What does this PR do?

Adds memory.memory_char_limit and memory.user_char_limit to the gateway's cache-busting config keys, so edits to either cap in config.yaml take effect on the next message — no gateway restart required.

Why

Sister keys (model.context_length, compression.*, memory.provider) are already picked up transparently. memory_char_limit / user_char_limit were the only memory-related config values still requiring a restart, which is inconsistent and surprising — operators hit it the first time they tried to bump the cap and saw no effect until they restarted the gateway.

The fix is two entries in _CACHE_BUSTING_CONFIG_KEYS (the same mechanism used for the other hot-reloadable keys).

Related Issue

No specific issue filed; this was discovered while investigating why an in-place cap bump did not take effect.

Type of Change

  • ✨ New feature (non-breaking change that adds functionality)

Changes Made

  • gateway/run.py — add 2 entries to _CACHE_BUSTING_CONFIG_KEYS with an inline comment explaining why
  • tests/gateway/test_agent_cache.py — 2 new tests:
    • test_reads_memory_char_limit_subkeys — caps are extracted from config
    • test_memory_char_limit_change_busts_signature — changing the cap changes the signature (so cache is invalidated)
  • website/docs/user-guide/configuration.md — extend the hot-reload tip to mention the new keys

How to Test

  1. Start a gateway with the default cap: memory: { memory_char_limit: 2200, user_char_limit: 1375 } in ~/.hermes/config.yaml
  2. Send a message, observe the system prompt memory header
  3. Edit ~/.hermes/config.yaml to memory_char_limit: 5000 (no restart)
  4. Send another message
  5. The system prompt memory header should now show "5000 chars" capacity

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits
  • I searched for existing PRs — not a duplicate
  • My PR contains only changes related to this fix/feature
  • I've run the relevant tests (manual + targeted unit tests; full pytest run blocked locally on Windows by pytest-timeout SIGALRM limitation on this venv, not by the patch)
  • I've added tests for my changes
  • Tested on: Windows 11

Documentation & Housekeeping

  • I've updated relevant documentation
  • I've considered cross-platform impact (the change is a constant-tuple edit, OS-agnostic)

Previously, edits to memory.memory_char_limit and memory.user_char_limit
in config.yaml only took effect after a full gateway restart, even
though sister keys (model.context_length, compression.*, memory.provider)
are already picked up transparently on the next message via the
agent-config signature.

Add the two keys to _CACHE_BUSTING_CONFIG_KEYS so the cached AIAgent is
rebuilt when either cap changes. Tests pin the behavior:
- test_reads_memory_char_limit_subkeys
- test_memory_char_limit_change_busts_signature

User-facing docs note the new behavior in the hot-reload tip.
@alt-glitch alt-glitch added type/feature New feature or request comp/gateway Gateway runner, session dispatch, delivery tool/memory Memory tool and memory providers P3 Low — cosmetic, nice to have labels Jun 5, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the focused cache-invalidation fix. Current main still omits both limits from GatewayRunner._CACHE_BUSTING_CONFIG_KEYS (gateway/run.py:15743), while AIAgent supplies them to MemoryStore only during construction (agent/agent_init.py:1371-1375). The PR's signature-key addition therefore matches the existing rebuild path at gateway/run.py:18158-18336, and its documentation change matches the current hot-reload tip at website/docs/user-guide/configuration.md:762-765.

Automated hermes-sweeper review.

@teknium1 teknium1 added sweeper:risk-caching Sweeper risk: may break/degrade prompt caching or cache-key stability (invariant) sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-caching Sweeper risk: may break/degrade prompt caching or cache-key stability (invariant) tool/memory Memory tool and memory providers type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants