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
fix(cron): scope cron job store to workspace instead of global directory
MiguelPFc33e01ee621a
diff --git a/nanobot/cli/commands.py b/nanobot/cli/commands.pyindex 0d4bb3de8..cde143659 100644--- a/nanobot/cli/commands.py+++ b/nanobot/cli/commands.py@@ -465,7 +465,6 @@ def gateway(from nanobot.agent.loop import AgentLoopfrom nanobot.bus.queue import MessageBusfrom nanobot.channels.manager import ChannelManager- from nanobot.config.paths import get_cron_dirfrom nanobot.cron.service import CronServicefrom nanobot.cron.types import CronJobfrom nanobot.heartbeat.service import HeartbeatService@@ -485,8 +484,8 @@ def gateway(provider = _make_provider(config)session_manager = SessionManager(config.workspace_path)- # Create cron service first (callback set after agent creation)- cron_store_path = get_cron_dir() / "jobs.json"+ # Create cron service with workspace-scoped store+ cron_store_path = config.workspace_path / "cron" / "jobs.json"cron = CronService(cron_store_path)# Create agent with cron service@@ -663,7 +662,6 @@ def agent(from nanobot.agent.loop import AgentLoopfrom nanobot.bus.queue import MessageBus- from nanobot.config.paths import get_cron_dirfrom nanobot.cron.service import CronServiceconfig = _load_runtime_config(config, workspace)@@ -673,8 +671,8 @@ def agent(bus = MessageBus()provider = _make_provider(config)- # Create cron service for tool usage (no callback needed for CLI unless running)- cron_store_path = get_cron_dir() / "jobs.json"+ # Create cron service with workspace-scoped store+ cron_store_path = config.workspace_path / "cron" / "jobs.json"cron = CronService(cron_store_path)if logs:diff --git a/tests/test_commands.py b/tests/test_commands.pyindex a820e7755..fcb2f6a6b 100644--- a/tests/test_commands.py+++ b/tests/test_commands.py@@ -275,10 +275,8 @@ def mock_agent_runtime(tmp_path):"""Mock agent command dependencies for focused CLI tests."""config = Config()config.agents.defaults.workspace = str(tmp_path / "default-workspace")- cron_dir = tmp_path / "data" / "cron"with patch("nanobot.config.loader.load_config", return_value=config) as mock_load_config, \- patch("nanobot.config.paths.get_cron_dir", return_value=cron_dir), \patch("nanobot.cli.commands.sync_workspace_templates") as mock_sync_templates, \patch("nanobot.cli.commands._make_provider", return_value=object()), \patch("nanobot.cli.commands._print_agent_response") as mock_print_response, \@@ -351,7 +349,6 @@ def test_agent_config_sets_active_path(monkeypatch, tmp_path: Path) -> None:lambda path: seen.__setitem__("config_path", path),)monkeypatch.setattr("nanobot.config.loader.load_config", lambda _path=None: config)- monkeypatch.setattr("nanobot.config.paths.get_cron_dir", lambda: config_file.parent / "cron")monkeypatch.setattr("nanobot.cli.commands.sync_workspace_templates", lambda _path: None)monkeypatch.setattr("nanobot.cli.commands._make_provider", lambda _config: object())monkeypatch.setattr("nanobot.bus.queue.MessageBus", lambda: object())@@ -508,7 +505,6 @@ def test_gateway_uses_config_directory_for_cron_store(monkeypatch, tmp_path: Patmonkeypatch.setattr("nanobot.config.loader.set_config_path", lambda _path: None)monkeypatch.setattr("nanobot.config.loader.load_config", lambda _path=None: config)- monkeypatch.setattr("nanobot.config.paths.get_cron_dir", lambda: config_file.parent / "cron")monkeypatch.setattr("nanobot.cli.commands.sync_workspace_templates", lambda _path: None)monkeypatch.setattr("nanobot.cli.commands._make_provider", lambda _config: object())monkeypatch.setattr("nanobot.bus.queue.MessageBus", lambda: object())@@ -524,7 +520,7 @@ def test_gateway_uses_config_directory_for_cron_store(monkeypatch, tmp_path: Patresult = runner.invoke(app, ["gateway", "--config", str(config_file)])assert isinstance(result.exception, _StopGateway)- assert seen["cron_store"] == config_file.parent / "cron" / "jobs.json"+ assert seen["cron_store"] == config.workspace_path / "cron" / "jobs.json"def test_gateway_uses_configured_port_when_cli_flag_is_missing(monkeypatch, tmp_path: Path) -> None: