From 4367038a95a8ae96e0fdfbb37b5488cd9a9fbe49 Mon Sep 17 00:00:00 2001 From: Clayton Wilson Date: Wed, 18 Feb 2026 13:32:06 -0600 Subject: [PATCH 1/2] fix: make cron run command actually execute the agent Wire up an AgentLoop with an on_job callback in the cron_run CLI command so the job's message is sent to the agent and the response is printed. Previously, CronService was created with no on_job callback, causing _execute_job to skip execution silently and always report success. Co-Authored-By: Claude Sonnet 4.6 --- nanobot/cli/commands.py | 44 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/nanobot/cli/commands.py b/nanobot/cli/commands.py index 2f4ba7b..a45b4a7 100644 --- a/nanobot/cli/commands.py +++ b/nanobot/cli/commands.py @@ -860,17 +860,51 @@ def cron_run( force: bool = typer.Option(False, "--force", "-f", help="Run even if disabled"), ): """Manually run a job.""" - from nanobot.config.loader import get_data_dir + from nanobot.config.loader import load_config, get_data_dir from nanobot.cron.service import CronService - + from nanobot.bus.queue import MessageBus + from nanobot.agent.loop import AgentLoop + from loguru import logger + logger.disable("nanobot") + + config = load_config() + provider = _make_provider(config) + bus = MessageBus() + agent_loop = AgentLoop( + bus=bus, + provider=provider, + workspace=config.workspace_path, + model=config.agents.defaults.model, + max_iterations=config.agents.defaults.max_tool_iterations, + memory_window=config.agents.defaults.memory_window, + exec_config=config.tools.exec, + restrict_to_workspace=config.tools.restrict_to_workspace, + ) + store_path = get_data_dir() / "cron" / "jobs.json" service = CronService(store_path) - + + result_holder = [] + + async def on_job(job): + response = await agent_loop.process_direct( + job.payload.message, + session_key=f"cron:{job.id}", + channel=job.payload.channel or "cli", + chat_id=job.payload.to or "direct", + ) + result_holder.append(response) + return response + + service.on_job = on_job + async def run(): return await service.run_job(job_id, force=force) - + if asyncio.run(run()): - console.print(f"[green]✓[/green] Job executed") + console.print("[green]✓[/green] Job executed") + if result_holder: + _print_agent_response(result_holder[0], render_markdown=True) else: console.print(f"[red]Failed to run job {job_id}[/red]") From b97b1a5e91bd8778e5625b2debc48c49998f0ada Mon Sep 17 00:00:00 2001 From: Re-bin Date: Fri, 20 Feb 2026 09:04:33 +0000 Subject: [PATCH 2/2] fix: pass full agent config including mcp_servers to cron run command --- nanobot/cli/commands.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/nanobot/cli/commands.py b/nanobot/cli/commands.py index 9389d0b..a135349 100644 --- a/nanobot/cli/commands.py +++ b/nanobot/cli/commands.py @@ -864,11 +864,12 @@ def cron_run( force: bool = typer.Option(False, "--force", "-f", help="Run even if disabled"), ): """Manually run a job.""" + from loguru import logger from nanobot.config.loader import load_config, get_data_dir from nanobot.cron.service import CronService + from nanobot.cron.types import CronJob from nanobot.bus.queue import MessageBus from nanobot.agent.loop import AgentLoop - from loguru import logger logger.disable("nanobot") config = load_config() @@ -879,10 +880,14 @@ def cron_run( provider=provider, workspace=config.workspace_path, model=config.agents.defaults.model, + temperature=config.agents.defaults.temperature, + max_tokens=config.agents.defaults.max_tokens, max_iterations=config.agents.defaults.max_tool_iterations, memory_window=config.agents.defaults.memory_window, + brave_api_key=config.tools.web.search.api_key or None, exec_config=config.tools.exec, restrict_to_workspace=config.tools.restrict_to_workspace, + mcp_servers=config.tools.mcp_servers, ) store_path = get_data_dir() / "cron" / "jobs.json" @@ -890,7 +895,7 @@ def cron_run( result_holder = [] - async def on_job(job): + async def on_job(job: CronJob) -> str | None: response = await agent_loop.process_direct( job.payload.message, session_key=f"cron:{job.id}",