fix(doctor): only check the active memory provider, not all providers unconditionally (#6285)
* fix(tools): skip camofox auto-cleanup when managed persistence is enabled
When managed_persistence is enabled, cleanup_browser() was calling
camofox_close() which destroys the server-side browser context via
DELETE /sessions/{userId}, killing login sessions across cron runs.
Add camofox_soft_cleanup() — a public wrapper that drops only the
in-memory session entry when managed persistence is on, returning True.
When persistence is off it returns False so the caller falls back to
the full camofox_close(). The inactivity reaper still handles idle
resource cleanup.
Also surface a logger.warning() when _managed_persistence_enabled()
fails to load config, replacing a silent except-and-return-False.
Salvaged from #6182 by el-analista (Eduardo Perea Fernandez).
Added public API wrapper to avoid cross-module private imports,
and test coverage for both persistence paths.
Co-authored-by: Eduardo Perea Fernandez <el-analista@users.noreply.github.com>
* fix(doctor): only check the active memory provider, not all providers unconditionally
hermes doctor had hardcoded Honcho Memory and Mem0 Memory sections that
always ran regardless of the user's memory.provider config setting. After
the swappable memory provider update (#4623), users with leftover Honcho
config but no active provider saw false 'broken' errors.
Replaced both sections with a single Memory Provider section that reads
memory.provider from config.yaml and only checks the configured provider.
Users with no external provider see a green 'Built-in memory active' check.
Reported by community user michaelruiz001, confirmed by Eri (Honcho).
---------
Co-authored-by: Eduardo Perea Fernandez <el-analista@users.noreply.github.com>
This commit is contained in:
co-authored by
Eduardo Perea Fernandez
parent
ff6a86cb52
commit
4f467700d4
@@ -65,6 +65,62 @@ class TestBrowserCleanup:
|
||||
mock_stop.assert_called_once_with("task-1")
|
||||
mock_run.assert_called_once_with("task-1", "close", [], timeout=10)
|
||||
|
||||
def test_cleanup_camofox_managed_persistence_skips_close(self):
|
||||
"""When camofox mode + managed persistence, soft_cleanup fires instead of close."""
|
||||
browser_tool = self.browser_tool
|
||||
browser_tool._active_sessions["task-1"] = {
|
||||
"session_name": "sess-1",
|
||||
"bb_session_id": None,
|
||||
}
|
||||
browser_tool._session_last_activity["task-1"] = 123.0
|
||||
|
||||
with (
|
||||
patch("tools.browser_tool._is_camofox_mode", return_value=True),
|
||||
patch("tools.browser_tool._maybe_stop_recording") as mock_stop,
|
||||
patch(
|
||||
"tools.browser_tool._run_browser_command",
|
||||
return_value={"success": True},
|
||||
),
|
||||
patch("tools.browser_tool.os.path.exists", return_value=False),
|
||||
patch(
|
||||
"tools.browser_camofox.camofox_soft_cleanup",
|
||||
return_value=True,
|
||||
) as mock_soft,
|
||||
patch("tools.browser_camofox.camofox_close") as mock_close,
|
||||
):
|
||||
browser_tool.cleanup_browser("task-1")
|
||||
|
||||
mock_soft.assert_called_once_with("task-1")
|
||||
mock_close.assert_not_called()
|
||||
|
||||
def test_cleanup_camofox_no_persistence_calls_close(self):
|
||||
"""When camofox mode but managed persistence is off, camofox_close fires."""
|
||||
browser_tool = self.browser_tool
|
||||
browser_tool._active_sessions["task-1"] = {
|
||||
"session_name": "sess-1",
|
||||
"bb_session_id": None,
|
||||
}
|
||||
browser_tool._session_last_activity["task-1"] = 123.0
|
||||
|
||||
with (
|
||||
patch("tools.browser_tool._is_camofox_mode", return_value=True),
|
||||
patch("tools.browser_tool._maybe_stop_recording") as mock_stop,
|
||||
patch(
|
||||
"tools.browser_tool._run_browser_command",
|
||||
return_value={"success": True},
|
||||
),
|
||||
patch("tools.browser_tool.os.path.exists", return_value=False),
|
||||
patch(
|
||||
"tools.browser_camofox.camofox_soft_cleanup",
|
||||
return_value=False,
|
||||
) as mock_soft,
|
||||
patch("tools.browser_camofox.camofox_close") as mock_close,
|
||||
):
|
||||
browser_tool.cleanup_browser("task-1")
|
||||
|
||||
mock_soft.assert_called_once_with("task-1")
|
||||
mock_close.assert_called_once_with("task-1")
|
||||
|
||||
def test_emergency_cleanup_clears_all_tracking_state(self):
|
||||
browser_tool = self.browser_tool
|
||||
browser_tool._cleanup_done = False
|
||||
|
||||
Reference in New Issue
Block a user