feat: Add OpenViking auto-commit feature for early memory searchability - #8235
feat: Add OpenViking auto-commit feature for early memory searchability#8235happy5318 wants to merge 2 commits into
Conversation
1. CLI: Trigger commit on /new /reset commands\n2. Gateway: Add 2-minute idle auto-commit watcher\n3. Session: Add memory_committed flag to avoid duplicate commits\n\nFully backward compatible, no impact on non-OpenViking users.
ZaynJarvis
left a comment
There was a problem hiding this comment.
Review: Auto-Commit Feature (Idle Commit Watcher)
Verdict: Request Changes — blocking issues before this can merge
The goal (committing sessions early for searchability) is good, but the implementation has several problems that need addressing.
Blocking Issues
1. Synchronous requests inside an async coroutine (critical)
_idle_commit_watcher() calls requests.post() directly inside an async def function. This blocks the asyncio event loop for up to 10 seconds per session per cycle, freezing all gateway activity. This must use httpx.AsyncClient with await client.post() instead:
# Replace this:
import requests
_resp = requests.post(f"{_endpoint}/api/v1/sessions/{entry.session_id}/commit", ...)
# With this:
async with httpx.AsyncClient() as client:
_resp = await client.post(f"{_endpoint}/api/v1/sessions/{entry.session_id}/commit", ...)2. Hardcoded endpoint
The watcher hardcodes http://127.0.0.1:1933. The endpoint should come from os.environ.get("OPENVIKING_ENDPOINT", _DEFAULT_ENDPOINT) or the configured plugin endpoint — otherwise this breaks any non-default deployment.
3. cli.py change calls shutdown_memory_provider() on /new
shutdown_memory_provider() calls the provider's shutdown() method, which joins threads and clears _last_active_provider. After this, the provider is dead — it cannot receive sync_turn calls for the new session. The correct approach (as in #9167) is to call commit_memory_session() (commit only) then reinitialize_memory_session() (re-bind to new session). Using shutdown_memory_provider() here corrupts the session lifecycle for the new session.
4. Direct session_store._entries access
The watcher accesses self.session_store._entries directly, bypassing the _ensure_loaded()/lock machinery in the public API. Use the public SessionStore methods or at minimum hold _lock during the full iteration.
5. No tests
The idle commit watcher is non-trivial async logic. It needs at minimum: (a) test that watcher commits idle sessions, (b) test that memory_committed=True is set, (c) test that active sessions are skipped.
What Is Good
- The concept of an idle commit watcher is sound and complementary to the explicit commit hooks in #9167/#7762
memory_committedfield onSessionEntryis clean- Resetting
memory_committedon new activity is correct
Please rewrite the watcher to use async httpx and fix the endpoint sourcing, then rebase onto #9167 so the cli.py change can be removed (it's handled there).
- Replace synchronous requests with async httpx.AsyncClient - Previous implementation blocked the event loop for up to 10s per request - Now uses non-blocking async HTTP requests - Read OpenViking endpoint from environment variable - Supports OPENVIKING_ENDPOINT for remote deployments - Falls back to http://127.0.0.1:1933 for local development - Minor optimization: collect sessions first, then batch commit - Avoids dict modification during iteration - Shares single httpx client across all commits in a cycle
|
plus, i think it's not necessary to auto commit since /new /reset /compress hook would commit the session #10463. If users are in the session, they can just use the in session context. I would probably suggest close this PR. |
|
Thanks for the review @ZaynJarvis! The issues you've raised have been addressed in the latest commit:
The implementation is already using |
|
Thanks for the contribution, @happy5318! After reviewing against current This is an automated hermes-sweeper review. Evidence:
Additionally, 108 of the 112 changed files are compiled/binary dist artifacts ( If there's interest in the narrower 120-second idle-commit optimization specifically for gateway sessions, that would be worth a small focused PR without the dist artifacts. |
Description
Adds automatic commit functionality for OpenViking memory provider, solving the pain point that users have to wait for 2-hour session timeout to search their conversation history.
Changes
Compatibility
Usage
After enabling OpenViking memory provider, users can search their conversation history: