You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Prevents a wedged external memory provider from stalling every turn during prefetch. MemoryManager.prefetch_all() now runs non-builtin provider prefetch calls behind a short fail-fast timeout and skips the provider while the original stuck call is still hung.
🐛 Bug fix (non-breaking change that fixes an issue)
✨ New feature (non-breaking change that adds functionality)
🔒 Security fix
📝 Documentation update
✅ Tests (adding or improving test coverage)
♻️ Refactor (no behavior change)
🎯 New skill (bundled or hub)
Changes Made
Add an external-memory prefetch timeout knob to agent/memory_manager.py with a 5s default and HERMES_EXTERNAL_MEMORY_PREFETCH_TIMEOUT override.
Run external provider prefetch() calls in a daemon thread, returning without blocking when they exceed the timeout.
Track still-hung prefetch calls per provider and skip repeated turns until the original stuck call returns.
Add a regression test in tests/agent/test_memory_provider.py that simulates a hung external provider and proves the second turn fails fast instead of re-blocking.
How to Test
Run /Users/leongong/Desktop/LeonProjects/worktrees/hermes-agent/.base/.venv/bin/python -m pytest tests/agent/test_memory_provider.py.
Run /Users/leongong/Desktop/LeonProjects/worktrees/hermes-agent/.base/.venv/bin/python -m py_compile agent/memory_manager.py.
Related: #50800 (competing open PR, 2026-06-22) bounds each external provider's prefetch() with an 8s one-shot-executor timeout — same function (prefetch_all) and same core mechanism (fail-fast timeout on external prefetch). This PR is a superset: it adds per-provider stuck-thread tracking to skip repeated turns while a call is still hung. Fixes #61800. A maintainer should pick the canonical approach across #50800/this one.
Thanks for addressing the pre-turn stall. The premise is confirmed on current main: agent/turn_context.py:563 calls MemoryManager.prefetch_all() before the tool loop, and agent/memory_manager.py:507 invokes provider prefetch() synchronously.
Problems
The new HERMES_EXTERNAL_MEMORY_PREFETCH_TIMEOUT override is a non-secret behavioral timeout. AGENTS.md:102-106 requires such settings to be configured through config.yaml, not a new user-facing HERMES_* environment variable.
The new regression test verifies the repeated-skip state, but after releasing the blocked call it does not issue another prefetch to verify that _stuck_prefetch_threads is cleared and the provider recovers.
Suggested changes
Preserve the fail-fast implementation but use the existing config path (or retain a fixed default without a user-facing env override).
Add a post-release recovery assertion to the timeout regression test.
Merged via #62290 (commit 8d1c96f) — your stuck-prefetch fail-fast commit landed on main with authorship preserved via rebase-merge (adapted to a bounded internal guard instead of a HERMES_* env var, per our config policy). Fixes #61800. Thanks @LeonSGP43!
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
area/memoryMemory subsystem: store, providers, sync, background reviewscomp/agentCore agent runtime: loop, agent_init, prompt builder, context-compression, responses endpointP2Medium — degraded but workaround existssweeper:blast-containedSweeper blast radius: contained — one narrow path / opt-in / few userssweeper:risk-compatibilitySweeper risk: may break existing users, config, migrations, defaults, or upgradessweeper:risk-session-stateSweeper risk: may lose/corrupt/mis-associate session or context statetool/memoryMemory tool and memory providerstype/bugSomething isn't working
3 participants
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.
What does this PR do?
Prevents a wedged external memory provider from stalling every turn during prefetch.
MemoryManager.prefetch_all()now runs non-builtin provider prefetch calls behind a short fail-fast timeout and skips the provider while the original stuck call is still hung.Related Issue
Fixes #61800
Type of Change
Changes Made
agent/memory_manager.pywith a 5s default andHERMES_EXTERNAL_MEMORY_PREFETCH_TIMEOUToverride.prefetch()calls in a daemon thread, returning without blocking when they exceed the timeout.tests/agent/test_memory_provider.pythat simulates a hung external provider and proves the second turn fails fast instead of re-blocking.How to Test
/Users/leongong/Desktop/LeonProjects/worktrees/hermes-agent/.base/.venv/bin/python -m pytest tests/agent/test_memory_provider.py./Users/leongong/Desktop/LeonProjects/worktrees/hermes-agent/.base/.venv/bin/python -m py_compile agent/memory_manager.py.git diff --checkis clean.Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AScreenshots / Logs
prefetch()adding a fixed 120s delay per turn when the external HY Memory sidecar hangs.