AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
fix(backend/copilot): block the CLI cron tools that silently schedule nothing (#14468)
Krzysztof Czerwinskibaca625b8149
diff --git a/autogpt_platform/backend/backend/blocks/orchestrator.py b/autogpt_platform/backend/backend/blocks/orchestrator.pyindex 9f6dfd093c..6052eae9d1 100644--- a/autogpt_platform/backend/backend/blocks/orchestrator.py+++ b/autogpt_platform/backend/backend/blocks/orchestrator.py@@ -405,6 +405,23 @@ def _select_final_answer_parts(return current+def sdk_disallowed_tools() -> list[str]:+ """Disable ALL known SDK built-in tools — only graph MCP tools available.++ This blocklist is the ONLY thing that removes a built-in: per the SDK,+ ``allowed_tools`` merely auto-approves without prompting, and the base set+ is controlled by ``tools`` (unset here, so every Claude Code default stays+ in the model's context). A built-in missing from this list is therefore+ callable, not blocked — which is why it is derived from the copilot's own+ inventory rather than kept in sync by hand.+ """+ # Local import: tool_adapter pulls in the whole copilot tool registry,+ # which every block load should not have to pay for.+ from backend.copilot.sdk.tool_adapter import get_sdk_builtin_tools++ return [*get_sdk_builtin_tools(), "NotebookEdit"]++class OrchestratorBlock(Block):"""A block that uses a language model to orchestrate tool calls.@@ -1674,28 +1691,7 @@ class OrchestratorBlock(Block):f"{MCP_PREFIX}{tf['function']['name']}" for tf in tool_functions]- # Disable ALL known SDK built-in tools — only graph MCP tools available.- # `allowed_tools` (above) is the primary restriction: the SDK only- # enables tools explicitly listed there. This blocklist is a- # defense-in-depth measure in case the SDK's allowlist logic changes.- # IMPORTANT: Keep this list in sync with the Claude Agent SDK.- # If a new built-in tool is added in a future SDK version, it will- # still be blocked by `allowed_tools` (only MCP-prefixed names are- # allowed), but adding it here provides an extra safety layer.- disallowed_tools = [- "Bash",- "WebFetch",- "AskUserQuestion",- "Read",- "Write",- "Edit",- "Glob",- "Grep",- "Task",- "WebSearch",- "TodoWrite",- "NotebookEdit",- ]+ disallowed_tools = sdk_disallowed_tools()# Build SDK env — provider-aware credential routing.# Extended thinking does not support subscription-mode (platform-managed credits).diff --git a/autogpt_platform/backend/backend/copilot/prompting.py b/autogpt_platform/backend/backend/copilot/prompting.pyindex 255c8dc0fa..be56fb4bb6 100644--- a/autogpt_platform/backend/backend/copilot/prompting.py+++ b/autogpt_platform/backend/backend/copilot/prompting.py@@ -223,6 +223,23 @@ as prose. Questions asked only in text are invisible to the user's Homethe tool call is what parks the question for them. A short closing sentencemay restate it, but never replace the tool call with prose.+### Scheduling future work — use `schedule_followup`+`schedule_followup` is the ONLY way to schedule a future copilot turn: "remind+me", "check every morning", "watch X and tell me when it changes". Pass+`delay_seconds` for one-shot, `cron` for recurring, and the `session_id` from+`<session_context>` to land it in this chat (omit it to fire into a fresh+chat). To run an *agent* on a schedule, use `run_agent` with `schedule_name` ++`cron` instead — that registers a graph schedule that runs the agent directly,+with no copilot turn re-deciding what to do each time; for event-driven runs+use `setup_agent_webhook_trigger`. Those are the only calls that outlive the+turn: no shell command, background process, or CLI cron-style tool survives the+end of the turn, even if it reports success and says it persisted to disk. So+never tell the user you will keep checking on something unless a scheduling+call actually succeeded — an unscheduled promise is silent, and they only find+out by noticing that nothing ever arrived. Use `list_schedules` to verify what+is set up; it shows every schedule in this expert's scope (or the plain+copilot's) across all chats, not only the ones created here.+### Complex multi-step work- Use `TodoWrite` to track the plan once the job has 3+ distinct steps.- Delegate self-contained subtasks to `run_sub_session` to keep theirdiff --git a/autogpt_platform/backend/backend/copilot/prompting_test.py b/autogpt_platform/backend/backend/copilot/prompting_test.pyindex ab81523161..27b5854122 100644--- a/autogpt_platform/backend/backend/copilot/prompting_test.py+++ b/autogpt_platform/backend/backend/copilot/prompting_test.py@@ -189,3 +189,42 @@ class TestExpertOversightSupplement:)== "")+++class TestSchedulingGuidance:+ """The CLI's cron built-ins are blocked (REQ-121), but blocking alone just+ moves the failure: the model must be told which primitive is durable, and+ told not to promise monitoring it never scheduled.+ """++ def test_supplement_names_schedule_followup_as_the_only_primitive(self):+ result = prompting.get_sdk_supplement(use_e2b=False)+ assert "### Scheduling future work — use `schedule_followup`" in result+ assert "ONLY way to schedule a future copilot turn" in result++ def test_supplement_keeps_agent_schedules_on_run_agent(self):+ # "Run my report agent every morning" must stay a graph schedule, not+ # become a recurring copilot turn that re-decides what to run.+ result = prompting.get_sdk_supplement(use_e2b=False)+ assert "use `run_agent` with `schedule_name` +" in result+ assert "use `setup_agent_webhook_trigger`" in result++ def test_supplement_rejects_the_confirmed_but_dead_alternative(self):+ result = prompting.get_sdk_supplement(use_e2b=False)+ # CronCreate reports success and claims it persisted to disk, so+ # "it said it worked" must not be treated as evidence it is scheduled.+ assert "even if it reports success and says it persisted to disk" in result+ assert "unless a scheduling" in result+ assert "call actually succeeded" in result++ def test_supplement_describes_list_schedules_scope_honestly(self):+ # list_schedules filters by expert_id, not session_id: it returns the+ # expert's (or plain copilot's) schedules from every chat.+ result = prompting.get_sdk_supplement(use_e2b=False)+ assert "across all chats, not only the ones created here" in result+ assert "current chat's scope" not in result++ def test_baseline_mode_gets_the_same_rule(self):+ # SHARED_TOOL_NOTES feeds both the SDK supplement and baseline's+ # system prompt; the rule is useless if it only reaches one mode.+ assert "### Scheduling future work" in prompting.SHARED_TOOL_NOTESdiff --git a/autogpt_platform/backend/backend/copilot/sdk/tool_adapter.py b/autogpt_platform/backend/backend/copilot/sdk/tool_adapter.pyindex aafe3762c5..ad5da9395a 100644--- a/autogpt_platform/backend/backend/copilot/sdk/tool_adapter.py+++ b/autogpt_platform/backend/backend/copilot/sdk/tool_adapter.py@@ -1041,6 +1041,13 @@ _SDK_BUILTIN_TOOLS = [*_SDK_BUILTIN_FILE_TOOLS, *_SDK_BUILTIN_ALWAYS]# prod without issues.# ScheduleWakeup: no /loop runtime in copilot turns; the handler returns# {"scheduledFor": 0} and nothing is scheduled.+# CronCreate/CronList/CronDelete: same failure mode as ScheduleWakeup, but+# worse because CronCreate *confirms* success ("Persisted to+# .claude/scheduled_tasks.json"). Those jobs belong to the CLI process,+# which exits with the turn; nothing here ever reads or runs that file, and+# sdk_cwd is a per-session /tmp dir that is never restored. Leaving them+# exposed lets the model promise unattended monitoring that silently never+# fires — `schedule_followup` is the primitive that actually persists.SDK_DISALLOWED_TOOLS = ["Bash","WebFetch",@@ -1050,6 +1057,9 @@ SDK_DISALLOWED_TOOLS = ["Edit","Read","ScheduleWakeup",+ "CronCreate",+ "CronList",+ "CronDelete",]# Tools that are blocked entirely in security hooks (defence-in-depth).@@ -1166,3 +1176,13 @@ def get_sdk_disallowed_tools(*, use_e2b: bool = False) -> list[str]:if not use_e2b:return list(SDK_DISALLOWED_TOOLS)return [*SDK_DISALLOWED_TOOLS, *_SDK_BUILTIN_FILE_TOOLS]+++def get_sdk_builtin_tools() -> list[str]:+ """Every Claude Code built-in this module knows about, blocked or kept.++ For callers that want *no* built-ins at all — the orchestrator block hands+ its model graph MCP tools only — so a built-in that is new here (a CLI+ scheduler, say) is blocked there without a second, hand-synced edit.+ """+ return list(dict.fromkeys([*SDK_DISALLOWED_TOOLS, *_SDK_BUILTIN_TOOLS]))diff --git a/autogpt_platform/backend/backend/copilot/sdk/tool_adapter_test.py b/autogpt_platform/backend/backend/copilot/sdk/tool_adapter_test.pyindex a98c3f535b..298d774f9d 100644--- a/autogpt_platform/backend/backend/copilot/sdk/tool_adapter_test.py+++ b/autogpt_platform/backend/backend/copilot/sdk/tool_adapter_test.py@@ -19,12 +19,14 @@ from .tool_adapter import (_MCP_MAX_CHARS,_STRIP_FROM_LLM,BASELINE_ONLY_MCP_TOOLS,+ BLOCKED_TOOLS,SDK_DISALLOWED_TOOLS,_make_truncating_wrapper,_strip_llm_fields,_text_from_mcp_result,create_copilot_mcp_server,create_tool_handler,+ get_sdk_disallowed_tools,pop_pending_tool_output,reset_pending_tool_outputs,reset_stash_event,@@ -743,6 +745,39 @@ class TestSDKDisallowedTools:def test_schedule_wakeup_tool_is_disallowed(self):assert "ScheduleWakeup" in SDK_DISALLOWED_TOOLS+ @pytest.mark.parametrize("tool", ["CronCreate", "CronList", "CronDelete"])+ def test_cli_cron_tools_are_disallowed(self, tool: str):+ """The CLI's cron built-ins schedule nothing that outlives the turn.++ CronCreate confirms success and claims it persisted to disk, so an+ exposed cron tool lets the model promise unattended monitoring that+ never fires. `schedule_followup` is the only durable primitive.+ """+ assert tool in SDK_DISALLOWED_TOOLS++ @pytest.mark.parametrize("tool", ["CronCreate", "CronList", "CronDelete"])+ @pytest.mark.parametrize("use_e2b", [False, True])+ def test_cron_tools_reach_sdk_options_in_both_modes(self, tool: str, use_e2b: bool):+ """`disallowed_tools` is what removes a built-in from the model's+ context, so the names must survive the E2B branch too."""+ assert tool in get_sdk_disallowed_tools(use_e2b=use_e2b)++ @pytest.mark.parametrize("tool", ["CronCreate", "CronList", "CronDelete"])+ def test_cron_tools_reach_security_hook_denylist(self, tool: str):+ """Defence in depth: security_hooks denies on BLOCKED_TOOLS, which is+ a denylist — an unlisted tool falls through and executes."""+ assert tool in BLOCKED_TOOLS++ def test_orchestrator_block_disallows_every_known_builtin(self):+ # The orchestrator's model gets graph MCP tools only, so its blocklist+ # must cover everything the copilot blocks *and* everything the+ # copilot deliberately keeps (sub-agents, todo list, file search).+ from backend.blocks.orchestrator import sdk_disallowed_tools++ blocked = set(sdk_disallowed_tools())+ assert set(get_sdk_disallowed_tools(use_e2b=True)) <= blocked+ assert {"Task", "Agent", "TodoWrite", "Glob", "Grep"} <= blocked+# ---------------------------------------------------------------------------# _read_file_handler — bridge_and_annotate integration