Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
test(cli): lock disabled dream cursor advancement
Xubin Ren34f776b48ba8
diff --git a/nanobot/cli/commands.py b/nanobot/cli/commands.pyindex ae288de2a..67d70dbd3 100644--- a/nanobot/cli/commands.py+++ b/nanobot/cli/commands.py@@ -154,6 +154,12 @@ def _install_gateway_shutdown_handlers(return restore+def _advance_dream_cursor_if_behind(memory: Any) -> None:+ latest = memory.get_latest_cursor()+ if memory.get_last_dream_cursor() < latest:+ memory.set_last_dream_cursor(latest)++class SafeFileHistory(FileHistory):"""FileHistory subclass that sanitizes surrogate characters on write.@@ -1165,9 +1171,7 @@ def _run_gateway(console.print(f"[green]✓[/green] Dream: {dream_cfg.describe_schedule()}")else:console.print("[yellow]○[/yellow] Dream: disabled")- latest = agent.context.memory.get_latest_cursor()- if agent.context.memory.get_last_dream_cursor() < latest:- agent.context.memory.set_last_dream_cursor(latest)+ _advance_dream_cursor_if_behind(agent.context.memory)# Register Heartbeat system job (idempotent on restart)if hb_cfg.enabled:diff --git a/tests/cli/test_commands.py b/tests/cli/test_commands.pyindex 3a6ad2864..3d9e79c61 100644--- a/tests/cli/test_commands.py+++ b/tests/cli/test_commands.py@@ -10,6 +10,7 @@ from unittest.mock import AsyncMock, MagicMock, patchimport pytestfrom typer.testing import CliRunner+from nanobot.agent.memory import MemoryStorefrom nanobot.bus.events import InboundMessage, OutboundMessagefrom nanobot.cli import commands as cli_commandsfrom nanobot.cli.commands import app@@ -140,6 +141,19 @@ def test_gateway_tty_signal_mode_restores_ctrl_c(monkeypatch) -> None:os.close(slave_fd)+def test_disabled_dream_cursor_only_advances_when_behind(tmp_path) -> None:+ store = MemoryStore(tmp_path)+ store.append_history("first")+ store.append_history("second")++ cli_commands._advance_dream_cursor_if_behind(store)+ assert store.get_last_dream_cursor() == 2++ store.set_last_dream_cursor(10)+ cli_commands._advance_dream_cursor_if_behind(store)+ assert store.get_last_dream_cursor() == 10++@pytest.fixturedef mock_paths():"""Mock config/workspace paths for test isolation."""