Skip to content

fix: skip oneshot memory prefetch - #50217

Open
hugoalvespereira wants to merge 2 commits into
NousResearch:mainfrom
hugoalvespereira:fix/oneshot-honcho-prefetch
Open

fix: skip oneshot memory prefetch#50217
hugoalvespereira wants to merge 2 commits into
NousResearch:mainfrom
hugoalvespereira:fix/oneshot-honcho-prefetch

Conversation

@hugoalvespereira

@hugoalvespereira hugoalvespereira commented Jun 21, 2026

Copy link
Copy Markdown

small oneshot memory cleanup.

hermes -z was still doing the normal chat thing where it syncs memory and then warms memory for the next turn.

but with oneshot there is no next turn, the process is about to exit. so this keeps the sync, skips only that prefetch, and also shuts the memory provider down before the CLI exits.

main thing I was seeing here was Honcho/hybrid mode having background memory work still alive at process exit.

tested with:

scripts/run_tests.sh tests/run_agent/test_memory_sync_interrupted.py tests/hermes_cli/test_tui_resume_flow.py

@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/cli CLI entry point, hermes_cli/, setup wizard tool/memory Memory tool and memory providers P2 Medium — degraded but workaround exists labels Jun 21, 2026
# Conflicts:
#	hermes_cli/oneshot.py
#	tests/hermes_cli/test_tui_resume_flow.py
@hugoalvespereira

Copy link
Copy Markdown
Author

Resolved the conflict by keeping the newer oneshot flow from main (run_conversation() returning the result tuple) and layering the original fix back on top.

So the intent stays the same: oneshot still syncs the completed turn, but it does not queue prefetch for a next turn that will never happen, and it now drains the memory shutdown path before the short-lived CLI process exits.

I also kept the newer exit-code tests from main and updated our test double to use run_conversation() instead of the older chat() path.

Verified with:

python -m pytest tests/run_agent/test_memory_sync_interrupted.py tests/hermes_cli/test_tui_resume_flow.py -q
# 71 passed in 1.34s

@hugoalvespereira

Copy link
Copy Markdown
Author

quick recheck since main moved a bunch again

tried this on current origin/main (55dbc3ffb). merge sim is clean, no conflicts.

same focused tests still pass:

scripts/run_tests.sh tests/run_agent/test_memory_sync_interrupted.py tests/hermes_cli/test_tui_resume_flow.py
# 71 passed, 0 failed

some upstream commits touch the same files, but not really the behavior this PR changes. I don't think this needs a rebase unless you'd rather have the branch fresh.

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for targeting the short-lived oneshot memory lifecycle. The current-head premise is valid: run_agent.py:3421 always queues next-turn prefetch, and hermes_cli/main.py:14731-14744 exits through run_oneshot() rather than the normal CLI cleanup path.

Problems

  • hermes_cli/oneshot.py:376 in this PR passes getattr(agent, "messages", []) to shutdown_memory_provider(). Current AIAgent persists its live transcript as _session_messages in run_agent.py:1693; shutdown_memory_provider() forwards the supplied list into MemoryManager.on_session_end() at run_agent.py:3325. Thus a normal agent takes the empty-list fallback and transcript-dependent end-of-session extraction loses its conversation input.

Suggested changes

  • Use the _session_messages list when available, with the no-argument shutdown fallback used by cli.py:1134-1147.
  • Adjust the focused test double to expose _session_messages and assert that exact list reaches shutdown.

Automated hermes-sweeper review.

Comment thread hermes_cli/oneshot.py
return (result.get("final_response") or "", result)
try:
result = agent.run_conversation(prompt)
return (result.get("final_response") or "", result)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AIAgent does not retain its conversation on messages; _persist_session() stores it as _session_messages (run_agent.py:1693). Passing this fallback empty list reaches MemoryManager.on_session_end() and drops the transcript for providers that perform end-of-session extraction. Please mirror the _session_messages/no-argument fallback used by CLI cleanup.

@teknium1 teknium1 added sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users area/memory Memory subsystem: store, providers, sync, background reviews labels Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/memory Memory subsystem: store, providers, sync, background reviews comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state tool/memory Memory tool and memory providers type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants