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.
feat(backend): AutoPilot manages all schedules, experts see only their runs (#14416)
Abhimanyu Yadavb5619d089ed5
diff --git a/autogpt_platform/backend/backend/api/features/chat/routes.py b/autogpt_platform/backend/backend/api/features/chat/routes.pyindex 26d71449e8..9ddd707bdf 100644--- a/autogpt_platform/backend/backend/api/features/chat/routes.py+++ b/autogpt_platform/backend/backend/api/features/chat/routes.py@@ -102,6 +102,7 @@ from backend.copilot.tools.manage_presets import (from backend.copilot.tools.manage_schedules import (ScheduleDeletedResponse,ScheduleListResponse,+ ScheduleToggledResponse,)from backend.copilot.tools.models import (AgentDetailsResponse,@@ -2312,6 +2313,7 @@ ToolResponseUnion = (| TaskDecompositionResponse| ScheduleListResponse| ScheduleDeletedResponse+ | ScheduleToggledResponse| PresetListResponse| PresetUpdatedResponse| PresetDeletedResponsediff --git a/autogpt_platform/backend/backend/api/features/experts/experts_db.py b/autogpt_platform/backend/backend/api/features/experts/experts_db.pyindex 702adb2b26..db2a2ec52b 100644--- a/autogpt_platform/backend/backend/api/features/experts/experts_db.py+++ b/autogpt_platform/backend/backend/api/features/experts/experts_db.py@@ -480,6 +480,26 @@ async def owns_active_expert(user_id: str, expert_id: str) -> bool:)+async def active_expert_ids(user_id: str, expert_ids: set[str]) -> set[str]:+ """Which of *expert_ids* are live hires of *user_id*, in one query.++ The batched form of :func:`owns_active_expert`, for callers holding a set:+ a per-id loop is unbounded in the number of experts on a request that+ previously did no expert work at all.+ """+ if not expert_ids:+ return set()+ rows = await prisma.models.Expert.prisma().find_many(+ where={+ "id": {"in": sorted(expert_ids)},+ "ownerUserId": user_id,+ "isTemplate": False,+ "isArchived": False,+ }+ )+ return {row.id for row in rows}++async def owns_private_active_expert(user_id: str, expert_id: str) -> bool:"""True iff *user_id* owns *expert_id* as a live, private hire.diff --git a/autogpt_platform/backend/backend/api/features/schedule_visibility.py b/autogpt_platform/backend/backend/api/features/schedule_visibility.pynew file mode 100644index 0000000000..b45920d3d0--- /dev/null+++ b/autogpt_platform/backend/backend/api/features/schedule_visibility.py@@ -0,0 +1,33 @@+from backend.executor.scheduler import CopilotTurnJobInfo, GraphExecutionJobInfo++Job = GraphExecutionJobInfo | CopilotTurnJobInfo+++async def hidden_expert_ids(jobs: list[Job], user_id: str) -> set[str]:+ """Experts whose paused schedules must not be reachable.++ A schedule with no next run belonging to an expert the user no longer has+ is one ``detach_expert_triggers`` paused so re-hire can restore it. Deleting+ or resuming it from outside that flow loses the cadence permanently, so both+ the REST listing and the copilot tools have to hide the same rows — one+ batched query, because a request that previously did no expert work at all+ must not grow a lookup per archived expert.+ """+ # Imported here, not at module scope: experts_db reaches back into+ # copilot.tools, which imports this module, and that is a cycle.+ from backend.api.features.experts import experts_db++ paused = {j.expert_id for j in jobs if j.expert_id and not j.next_run_time}+ return paused - await experts_db.active_expert_ids(user_id, paused)+++async def visible_graph_schedules(+ schedules: list[GraphExecutionJobInfo], user_id: str+) -> list[GraphExecutionJobInfo]:+ hidden = await hidden_expert_ids(list(schedules), user_id)+ return [s for s in schedules if is_visible_schedule(s, hidden)]+++def is_visible_schedule(job: Job, hidden: set[str]) -> bool:+ """The one rule both readers apply, so neither can list what the other hides."""+ return bool(job.next_run_time) or job.expert_id not in hiddendiff --git a/autogpt_platform/backend/backend/api/features/schedule_visibility_test.py b/autogpt_platform/backend/backend/api/features/schedule_visibility_test.pynew file mode 100644index 0000000000..84e0d6bbc1--- /dev/null+++ b/autogpt_platform/backend/backend/api/features/schedule_visibility_test.py@@ -0,0 +1,119 @@+from unittest.mock import AsyncMock, MagicMock, patch++import pytest+from autogpt_libs.auth.models import RequestContext++from backend.api.features.schedule_visibility import (+ is_visible_schedule,+ visible_graph_schedules,+)+from backend.api.features.schedules.routes import (+ list_all_graphs_execution_schedules,+ list_graph_execution_schedules,+)+from backend.executor.scheduler import GraphExecutionJobInfo++[email protected]("graph_only", [False, True])+async def test_rest_lists_paused_active_expert_schedules(graph_only):+ schedule = GraphExecutionJobInfo(+ id="paused",+ name="Paused QA",+ next_run_time="",+ user_id="owner",+ graph_id="graph",+ graph_version=1,+ cron="0 9 * * *",+ input_data={},+ expert_id="expert-a",+ )++ async def list_schedules(**kwargs):+ return [schedule] if kwargs.get("include_paused") else []++ with (+ patch(+ "backend.api.features.schedules.routes.get_scheduler_client",+ return_value=MagicMock(+ get_graph_execution_schedules=AsyncMock(side_effect=list_schedules)+ ),+ ),+ patch(+ "backend.api.features.experts.experts_db.active_expert_ids",+ AsyncMock(return_value={"expert-a"}),+ ),+ ):+ ctx = RequestContext(+ user_id="owner",+ org_id=None,+ team_id=None,+ is_org_owner=False,+ is_org_admin=False,+ is_org_billing_manager=False,+ is_team_admin=False,+ is_team_billing_manager=False,+ seat_status="ACTIVE",+ )+ result = (+ await list_graph_execution_schedules("owner", ctx, "graph")+ if graph_only+ else await list_all_graphs_execution_schedules("owner", ctx)+ )+ assert result == [schedule]+++async def test_paused_archived_expert_schedules_stay_hidden():+ base = GraphExecutionJobInfo(+ id="paused",+ name="QA",+ next_run_time="",+ user_id="owner",+ graph_id="graph",+ graph_version=1,+ cron="0 9 * * *",+ input_data={},+ )+ archived = base.model_copy(+ update={"id": "archived", "expert_id": "archived-expert"}+ )+ with patch(+ "backend.api.features.experts.experts_db.active_expert_ids",+ AsyncMock(return_value=set()),+ ) as active:+ result = await visible_graph_schedules([base, archived], "owner")+ assert result == [base]+ # One batched call for the whole listing, not one per archived expert.+ active.assert_awaited_once_with("owner", {"archived-expert"})+++async def test_both_readers_apply_the_same_rule():+ """The REST listing and `list_schedules` must not disagree about a row.++ They read the same jobs and each used to carry its own condition; a row one+ listed and the other hid is what let the model act on what the UI could not+ show. `is_visible_schedule` is now the only rule, so this pins the decision+ rather than either call site.+ """+ live = GraphExecutionJobInfo(+ id="live",+ name="QA",+ next_run_time="2026-01-01T09:00:00Z",+ user_id="owner",+ graph_id="graph",+ graph_version=1,+ cron="0 9 * * *",+ input_data={},+ expert_id="archived-expert",+ )+ paused_archived = live.model_copy(update={"id": "gone", "next_run_time": ""})+ paused_owner = live.model_copy(+ update={"id": "mine", "next_run_time": "", "expert_id": None}+ )+ hidden = {"archived-expert"}+ assert is_visible_schedule(live, hidden) is True+ assert is_visible_schedule(paused_archived, hidden) is False+ # No expert and no next run: paused by the owner, and theirs to resume.+ assert is_visible_schedule(paused_owner, hidden) is Truediff --git a/autogpt_platform/backend/backend/api/features/schedules/routes.py b/autogpt_platform/backend/backend/api/features/schedules/routes.pyindex 512f1d603e..992988a774 100644--- a/autogpt_platform/backend/backend/api/features/schedules/routes.py+++ b/autogpt_platform/backend/backend/api/features/schedules/routes.py@@ -6,6 +6,7 @@ from fastapi import APIRouter, Body, HTTPException, Path, Securityfrom starlette.status import HTTP_404_NOT_FOUNDfrom backend.api.features.experts import experts_db+from backend.api.features.schedule_visibility import visible_graph_schedulesfrom backend.api.features.schedules.model import ScheduleCreationRequestfrom backend.data import graph as graph_dbfrom backend.data.onboarding import OnboardingStep, complete_onboarding_step@@ -103,12 +104,14 @@ async def list_graph_execution_schedules(graph_id: str = Path(),) -> list[scheduler.GraphExecutionJobInfo]:team_ids = await get_user_team_ids(user_id, ctx.org_id) if ctx.org_id else []- return await get_scheduler_client().get_graph_execution_schedules(+ schedules = await get_scheduler_client().get_graph_execution_schedules(user_id=user_id,graph_id=graph_id,organization_id=ctx.org_id,team_ids=team_ids,+ include_paused=True,)+ return await visible_graph_schedules(schedules, user_id)@router.get(@@ -120,11 +123,13 @@ async def list_all_graphs_execution_schedules(ctx: Annotated[RequestContext, Security(get_request_context)],) -> list[scheduler.GraphExecutionJobInfo]:team_ids = await get_user_team_ids(user_id, ctx.org_id) if ctx.org_id else []- return await get_scheduler_client().get_graph_execution_schedules(+ schedules = await get_scheduler_client().get_graph_execution_schedules(user_id=user_id,organization_id=ctx.org_id,team_ids=team_ids,+ include_paused=True,)+ return await visible_graph_schedules(schedules, user_id)# Keep above /schedules/{schedule_id}: a GET added there would otherwise matchdiff --git a/autogpt_platform/backend/backend/copilot/permissions.py b/autogpt_platform/backend/backend/copilot/permissions.pyindex 4232779c2c..010de6aa4c 100644--- a/autogpt_platform/backend/backend/copilot/permissions.py+++ b/autogpt_platform/backend/backend/copilot/permissions.py@@ -124,6 +124,7 @@ ToolName = Literal["memory_store","move_agents_to_folder","move_folder",+ "pause_schedule","post_to_chat_platform","raise_expert","read_expert_chat",@@ -131,6 +132,7 @@ ToolName = Literal["read_workspace_file","remove_expert_workflow","request_credential_grant",+ "resume_schedule","revoke_expert_credential","run_agent","run_block",diff --git a/autogpt_platform/backend/backend/copilot/tools/__init__.py b/autogpt_platform/backend/backend/copilot/tools/__init__.pyindex ffd1a1ddfb..e60c8c1cc5 100644--- a/autogpt_platform/backend/backend/copilot/tools/__init__.py+++ b/autogpt_platform/backend/backend/copilot/tools/__init__.py@@ -61,7 +61,12 @@ from .manage_folders import (UpdateFolderTool,)from .manage_presets import DeletePresetTool, ListPresetsTool, UpdatePresetTool-from .manage_schedules import DeleteScheduleTool, ListSchedulesTool+from .manage_schedules import (+ DeleteScheduleTool,+ ListSchedulesTool,+ PauseScheduleTool,+ ResumeScheduleTool,+)from .models import ErrorResponsefrom .platform_info import PlatformInfoToolfrom .raise_expert import RaiseExpertTool@@ -118,6 +123,8 @@ TOOL_REGISTRY: dict[str, BaseTool] = {# Schedule management"list_schedules": ListSchedulesTool(),"delete_schedule": DeleteScheduleTool(),+ "pause_schedule": PauseScheduleTool(),+ "resume_schedule": ResumeScheduleTool(),"schedule_followup": ScheduleFollowupTool(),# Proactive chat-platform output (post message / open thread on user's behalf)"post_to_chat_platform": PostToChatPlatformTool(),diff --git a/autogpt_platform/backend/backend/copilot/tools/agent_output.py b/autogpt_platform/backend/backend/copilot/tools/agent_output.pyindex 38bc400ec6..041918d3c2 100644--- a/autogpt_platform/backend/backend/copilot/tools/agent_output.py+++ b/autogpt_platform/backend/backend/copilot/tools/agent_output.py@@ -112,6 +112,11 @@ def parse_time_expression(return None, None+def _run_visible(execution: GraphExecutionMeta, expert_id: str | None) -> bool:+ """Personal AutoPilot sees every run; an expert only runs it started."""+ return expert_id is None or execution.expert_id == expert_id++class AgentOutputTool(BaseTool):"""Tool for retrieving execution outputs from user's library agents."""@@ -250,6 +255,7 @@ class AgentOutputTool(BaseTool):time_end: datetime | None,include_running: bool = False,include_node_executions: bool = False,+ expert_id: str | None = None,) -> tuple[GraphExecution | GraphExecutionWithNodes | None,list[GraphExecutionMeta],@@ -262,6 +268,7 @@ class AgentOutputTool(BaseTool):Args:include_running: If True, also look for running/queued executions (for waiting)include_node_executions: If True, include node-by-node execution details+ expert_id: Only runs this expert started; None sees every run."""exec_db = execution_db()@@ -272,7 +279,7 @@ class AgentOutputTool(BaseTool):execution_id=execution_id,include_node_executions=include_node_executions,)- if not execution:+ if not execution or not _run_visible(execution, expert_id):return None, [], f"Execution '{execution_id}' not found"return execution, [], None@@ -298,6 +305,7 @@ class AgentOutputTool(BaseTool):created_time_gte=time_start,created_time_lte=time_end,limit=10,+ expert_id=expert_id,)if not executions:@@ -491,7 +499,7 @@ class AgentOutputTool(BaseTool):execution_id=input_data.execution_id,include_node_executions=input_data.show_execution_details,)- if not execution:+ if not execution or not _run_visible(execution, session.expert_id):return ErrorResponse(message=f"Execution '{input_data.execution_id}' not found",session_id=session_id,@@ -539,6 +547,7 @@ class AgentOutputTool(BaseTool):# Fetch execution(s) - include running if we're going to waitexecution, available_executions, exec_error = await self._get_execution(+ expert_id=session.expert_id,user_id=user_id,graph_id=agent.graph_id,execution_id=input_data.execution_id or None,diff --git a/autogpt_platform/backend/backend/copilot/tools/expert_isolation_test.py b/autogpt_platform/backend/backend/copilot/tools/expert_isolation_test.pynew file mode 100644index 0000000000..e7bdae89f5--- /dev/null+++ b/autogpt_platform/backend/backend/copilot/tools/expert_isolation_test.py@@ -0,0 +1,150 @@+"""Cross-tool expert isolation: workflow discovery, block credentials, MCP+credentials, and run visibility all follow the session's expert."""++from unittest.mock import AsyncMock, MagicMock, patch++from backend.copilot.model import ChatSession+from backend.copilot.tools.agent_output import AgentOutputTool, _run_visible+from backend.copilot.tools.expert_scope import ExpertWorkflowScope+from backend.copilot.tools.find_library_agent import FindLibraryAgentTool+from backend.copilot.tools.helpers import resolve_block_credentials+from backend.copilot.tools.models import AgentInfo, AgentsFoundResponse+++def _session(expert_id: str | None) -> ChatSession:+ return ChatSession.new("user-1", dry_run=False, expert_id=expert_id)+++def _agent(agent_id: str, graph_id: str) -> AgentInfo:+ return AgentInfo(+ id=agent_id, name=agent_id, description="", source="library", graph_id=graph_id+ )+++async def test_find_library_agent_lists_only_installed_workflows_for_experts():+ found = AgentsFoundResponse(+ message="Found",+ agents=[_agent("lib-in", "graph-in"), _agent("lib-out", "graph-out")],+ count=2,+ session_id="s",+ )+ scope = ExpertWorkflowScope(expert_id="expert-a", graph_ids=["graph-in"])+ with (+ patch.object(+ FindLibraryAgentTool, "_search", new=AsyncMock(return_value=found)+ ),+ patch(+ "backend.copilot.tools.find_library_agent.session_workflow_scope",+ new=AsyncMock(return_value=scope),+ ),+ ):+ result = await FindLibraryAgentTool()._execute(+ "user-1", _session("expert-a"), query="anything"+ )+ assert isinstance(result, AgentsFoundResponse)+ assert [a.id for a in result.agents] == ["lib-in"]+ assert result.count == 1+++async def test_find_library_agent_is_unfiltered_for_personal_autopilot():+ found = AgentsFoundResponse(+ message="Found", agents=[_agent("a", "g1"), _agent("b", "g2")], count=2+ )+ with patch.object(+ FindLibraryAgentTool, "_search", new=AsyncMock(return_value=found)+ ):+ result = await FindLibraryAgentTool()._execute("user-1", _session(None))+ assert isinstance(result, AgentsFoundResponse) and result.count == 2+++async def test_block_credentials_reach_the_matcher_under_the_session_expert():+ """Pins the wiring only: the matcher is patched out, so this says nothing+ about the filter itself. That is proved in ``utils_test.py``+ (``test_a_block_run_in_an_expert_session_uses_only_a_granted_credential``+ and its ungranted twin), where emptying ``scope_credentials_to_expert``+ turns them red."""+ block = MagicMock()+ with (+ patch(+ "backend.copilot.tools.helpers._resolve_discriminated_credentials",+ return_value={"credentials": MagicMock()},+ ),+ patch(+ "backend.copilot.tools.helpers.match_credentials_to_requirements",+ new=AsyncMock(return_value=({}, [])),+ ) as match,+ ):+ await resolve_block_credentials("user-1", block, {}, "expert-a")+ assert match.await_args.args[2] == "expert-a"+++def test_run_visibility_follows_the_session_expert():+ assert _run_visible(MagicMock(expert_id="expert-a"), None)+ assert _run_visible(MagicMock(expert_id=None), None)+ assert _run_visible(MagicMock(expert_id="expert-a"), "expert-a")+ assert not _run_visible(MagicMock(expert_id="expert-b"), "expert-a")+ assert not _run_visible(MagicMock(expert_id=None), "expert-a")+++async def test_expert_cannot_read_another_experts_run_by_id():+ exec_db = MagicMock()+ exec_db.get_graph_execution = AsyncMock(+ return_value=MagicMock(expert_id="expert-b")+ )+ with patch("backend.copilot.tools.agent_output.execution_db", return_value=exec_db):+ execution, _, error = await AgentOutputTool()._get_execution(+ user_id="user-1",+ graph_id="g",+ execution_id="run-1",+ time_start=None,+ time_end=None,+ expert_id="expert-a",+ )+ assert execution is None and error is not None+++async def test_expert_run_listing_is_filtered_in_the_query():+ exec_db = MagicMock()+ exec_db.get_graph_executions = AsyncMock(return_value=[])+ with patch("backend.copilot.tools.agent_output.execution_db", return_value=exec_db):+ await AgentOutputTool()._get_execution(+ user_id="user-1",+ graph_id="g",+ execution_id=None,+ time_start=None,+ time_end=None,+ expert_id="expert-a",+ )+ assert exec_db.get_graph_executions.await_args.kwargs["expert_id"] == "expert-a"+++async def test_run_agent_refuses_uninstalled_workflow_for_expert():+ from backend.copilot.tools.run_agent import RunAgentTool++ lib_agent = MagicMock(id="lib-1", graph_id="graph-out", graph_version=1)+ graph = MagicMock(id="graph-out", name="Outside", version=1)+ lib_db = MagicMock()+ lib_db.get_library_agent = AsyncMock(return_value=lib_agent)+ graph_db = MagicMock()+ graph_db.get_graph = AsyncMock(return_value=graph)+ experts = MagicMock()+ experts.get_expert = AsyncMock(+ return_value=MagicMock(+ workflows=[MagicMock(library_agent_id="lib-in", graph_id="graph-in")]+ )+ )+ add_exec = AsyncMock()+ with (+ patch("backend.copilot.tools.run_agent.library_db", return_value=lib_db),+ patch("backend.copilot.tools.run_agent.graph_db", return_value=graph_db),+ patch("backend.copilot.tools.expert_scope.experts_db", return_value=experts),+ patch(+ "backend.copilot.tools.run_agent.execution_utils.add_graph_execution",+ new=add_exec,+ ),+ ):+ result = await RunAgentTool()._execute(+ user_id="user-1", session=_session("expert-a"), library_agent_id="lib-1"+ )+ assert result.error == "workflow_not_installed"+ add_exec.assert_not_awaited()diff --git a/autogpt_platform/backend/backend/copilot/tools/manage_schedules.py b/autogpt_platform/backend/backend/copilot/tools/manage_schedules.pyindex 60ef794699..32dc9c47d5 100644--- a/autogpt_platform/backend/backend/copilot/tools/manage_schedules.py+++ b/autogpt_platform/backend/backend/copilot/tools/manage_schedules.py@@ -6,6 +6,10 @@ from typing import Any, Literalfrom pydantic import BaseModelfrom backend.api.features.library.db import get_library_agent+from backend.api.features.schedule_visibility import (+ hidden_expert_ids,+ is_visible_schedule,+)from backend.copilot.model import ChatSessionfrom backend.data.activity_event import ActivityEventDraftfrom backend.executor.scheduler import CopilotTurnJobInfo, GraphExecutionJobInfo@@ -21,7 +25,33 @@ logger = logging.getLogger(__name__)def _is_in_session_scope(job: GraphExecutionJobInfo | CopilotTurnJobInfo, session: ChatSession) -> bool:- return job.expert_id == session.expert_id+ """Personal AutoPilot manages every schedule on the account; an expert+ only its own."""+ return session.expert_id is None or job.expert_id == session.expert_id+++async def _find_scoped_schedule(+ scheduler: Any, user_id: str, session: ChatSession, schedule_id: str+) -> GraphExecutionJobInfo | CopilotTurnJobInfo | None:+ # include_paused: a paused expert schedule or fired one-shot must still be+ # reachable — the default listing hides them.+ jobs = await scheduler.get_execution_schedules(user_id=user_id, include_paused=True)+ match = next(+ (+ job+ for job in jobs+ if job.id == schedule_id and _is_in_session_scope(job, session)+ ),+ None,+ )+ if match is None or not match.expert_id or match.next_run_time:+ return match+ # An archived expert's paused schedules are the ones the archive flow keeps+ # for re-hire; the REST listing already hides them, and delete/resume here+ # would lose or revive them behind that flow's back.+ return (+ None if match.expert_id in await hidden_expert_ids([match], user_id) else match+ )class ScheduleSummary(BaseModel):@@ -32,6 +62,10 @@ class ScheduleSummary(BaseModel):name: strtimezone: strnext_run_time: str+ # Owning expert; None for personal AutoPilot schedules.+ expert_id: str | None = None+ # No next fire is scheduled: paused, or a one-shot that already ran.+ paused: bool = False# Either cron (recurring) or run_at (one-shot) is populated, never both.cron: str | None = Nonerun_at: str | None = None@@ -57,6 +91,8 @@ def _to_summary(return ScheduleSummary(schedule_id=job.id,kind="graph",+ expert_id=job.expert_id,+ paused=not job.next_run_time,name=job.name,timezone=job.timezone,next_run_time=job.next_run_time,@@ -68,6 +104,8 @@ def _to_summary(return ScheduleSummary(schedule_id=job.id,kind="copilot_turn",+ expert_id=job.expert_id,+ paused=not job.next_run_time,name=job.name,timezone=job.timezone,next_run_time=job.next_run_time,@@ -158,13 +196,21 @@ class ListSchedulesTool(BaseTool):)graph_id = lib_agent.graph_id+ # include_paused: a paused schedule must stay listable so its id can+ # be handed to resume_schedule or delete_schedule later.jobs = await get_scheduler_client().get_execution_schedules(graph_id=graph_id,user_id=user_id,+ include_paused=True,)+ # Same rule as the mutation tools and the REST listing: an archived+ # expert's paused rows are held for re-hire, so showing one the model+ # cannot then delete or resume is worse than not showing it.+ in_scope = [job for job in jobs if _is_in_session_scope(job, session)]+ hidden = await hidden_expert_ids(in_scope, user_id)schedules = [- _to_summary(job) for job in jobs if _is_in_session_scope(job, session)+ _to_summary(job) for job in in_scope if is_visible_schedule(job, hidden)]message = (@@ -252,19 +298,7 @@ class DeleteScheduleTool(BaseTool):)scheduler = get_scheduler_client()- # include_paused: a paused expert schedule or fired one-shot must- # still be deletable — the default listing hides them.- jobs = await scheduler.get_execution_schedules(- user_id=user_id, include_paused=True- )- current = next(- (- job- for job in jobs- if job.id == schedule_id and _is_in_session_scope(job, session)- ),- None,- )+ current = await _find_scoped_schedule(scheduler, user_id, session, schedule_id)if current is None:return ErrorResponse(message=f"Schedule '{schedule_id}' not found.",@@ -295,3 +329,128 @@ class DeleteScheduleTool(BaseTool):schedule_id=schedule_id,session_id=session_id,)+++class ScheduleToggledResponse(ToolResponseBase):+ type: ResponseType = ResponseType.SCHEDULE_TOGGLED+ schedule_id: str+ paused: bool+ # False when the schedule was already in that state. The activity log is+ # append-only, so a no-op must not leave an entry in it.+ changed: bool = True+++class _ToggleScheduleTool(BaseTool):+ _pause: bool = True++ @property+ def requires_auth(self) -> bool:+ return True++ @property+ def parameters(self) -> dict[str, Any]:+ return {+ "type": "object",+ "properties": {+ "schedule_id": {+ "type": "string",+ "description": "Schedule ID from list_schedules.",+ },+ },+ "required": ["schedule_id"],+ }++ async def _execute(+ self,+ user_id: str | None,+ session: ChatSession,+ schedule_id: str = "",+ **kwargs,+ ) -> ToolResponseBase:+ session_id = session.session_id+ if not user_id:+ return ErrorResponse(+ message="Authentication required.",+ error="auth_required",+ session_id=session_id,+ )+ if not schedule_id:+ return ErrorResponse(+ message="schedule_id is required.",+ error="missing_schedule_id",+ session_id=session_id,+ )+ scheduler = get_scheduler_client()+ if (+ await _find_scoped_schedule(scheduler, user_id, session, schedule_id)+ is None+ ):+ return ErrorResponse(+ message=f"Schedule '{schedule_id}' not found.",+ error="schedule_not_found",+ session_id=session_id,+ )+ try:+ if self._pause:+ changed = await scheduler.pause_schedule(schedule_id, user_id)+ else:+ changed = await scheduler.resume_schedule(schedule_id, user_id)+ except NotAuthorizedError as e:+ return ErrorResponse(+ message=f"Not authorized: {e}",+ error="not_authorized",+ session_id=session_id,+ )+ state = "paused" if self._pause else "resumed"+ return ScheduleToggledResponse(+ schedule_id=schedule_id,+ paused=self._pause,+ changed=changed,+ message=(+ f"Schedule {schedule_id} {state}."+ if changed+ else f"Schedule {schedule_id} was already {state}."+ ),+ session_id=session_id,+ )++ def activity_event(+ self,+ session: ChatSession,+ result: ToolResponseBase,+ **kwargs,+ ) -> ActivityEventDraft | None:+ # Halting an expert's automation is the one new action here that stops+ # work, so it belongs in the owner's feed beside schedule.deleted.+ if not isinstance(result, ScheduleToggledResponse) or not result.changed:+ return None+ return ActivityEventDraft(+ category="SCHEDULE",+ event_type="schedule.paused" if self._pause else "schedule.resumed",+ title="Paused a schedule" if self._pause else "Resumed a schedule",+ schedule_id=result.schedule_id,+ )+++class PauseScheduleTool(_ToggleScheduleTool):+ _pause = True++ @property+ def name(self) -> str:+ return "pause_schedule"++ @property+ def description(self) -> str:+ return "Pause a schedule without deleting it. Resume with resume_schedule."+++class ResumeScheduleTool(_ToggleScheduleTool):+ _pause = False++ @property+ def name(self) -> str:+ return "resume_schedule"++ @property+ def description(self) -> str:+ return "Resume a paused schedule. Missed fires are not replayed."diff --git a/autogpt_platform/backend/backend/copilot/tools/manage_schedules_test.py b/autogpt_platform/backend/backend/copilot/tools/manage_schedules_test.pyindex 7b22ae0172..cd5244b22e 100644--- a/autogpt_platform/backend/backend/copilot/tools/manage_schedules_test.py+++ b/autogpt_platform/backend/backend/copilot/tools/manage_schedules_test.py@@ -8,8 +8,11 @@ import pytestfrom backend.copilot.tools.manage_schedules import (DeleteScheduleTool,ListSchedulesTool,+ PauseScheduleTool,+ ResumeScheduleTool,ScheduleDeletedResponse,ScheduleListResponse,+ ScheduleToggledResponse,)from backend.copilot.tools.models import ErrorResponsefrom backend.executor.scheduler import CopilotTurnJobInfo, GraphExecutionJobInfo@@ -187,7 +190,7 @@ async def test_list_schedules_by_library_agent(list_tool, session):assert isinstance(result, ScheduleListResponse)mock_client.get_execution_schedules.assert_called_once_with(- graph_id="graph-42", user_id=_USER+ graph_id="graph-42", user_id=_USER, include_paused=True)@@ -211,12 +214,16 @@ async def test_list_schedules_library_agent_not_found(list_tool, session):@pytest.mark.parametrize(- ("session_expert_id", "expected_id"),- [(None, "autopilot"), ("expert-a", "expert-a-job"), ("expert-b", "expert-b-job")],+ ("session_expert_id", "expected_ids"),+ [+ (None, ["autopilot", "expert-a-job", "expert-b-job"]),+ ("expert-a", ["expert-a-job"]),+ ("expert-b", ["expert-b-job"]),+ ],)@pytest.mark.asyncio-async def test_list_schedules_only_returns_current_persona_scope(- list_tool, session_expert_id, expected_id+async def test_list_schedules_autopilot_sees_all_experts_see_their_own(+ list_tool, session_expert_id, expected_ids):scoped_session = make_session(_USER, expert_id=session_expert_id)mock_client = AsyncMock()@@ -232,7 +239,12 @@ async def test_list_schedules_only_returns_current_persona_scope(result = await list_tool._execute(user_id=_USER, session=scoped_session)assert isinstance(result, ScheduleListResponse)- assert [schedule.schedule_id for schedule in result.schedules] == [expected_id]+ assert [schedule.schedule_id for schedule in result.schedules] == expected_ids+ assert all(+ schedule.expert_id == schedule.schedule_id.removesuffix("-job")+ for schedule in result.schedules+ if schedule.schedule_id != "autopilot"+ )# ── DeleteScheduleTool ─────────────────────────────────────────────@@ -324,14 +336,13 @@ async def test_delete_schedule_not_authorized(delete_tool, session):@pytest.mark.parametrize(("session_expert_id", "target_expert_id"),[- (None, "expert-a"),("expert-a", None),("expert-a", "expert-b"),("expert-b", "expert-a"),],)@pytest.mark.asyncio-async def test_delete_schedule_refuses_cross_persona_job(+async def test_delete_schedule_refuses_cross_expert_job(delete_tool, session_expert_id, target_expert_id):scoped_session = make_session(_USER, expert_id=session_expert_id)@@ -375,3 +386,221 @@ async def test_delete_schedule_allows_same_expert_job(delete_tool):mock_client.delete_schedule.assert_awaited_once_with(schedule_id="expert-job", user_id=_USER)+++async def test_autopilot_can_delete_an_expert_schedule(delete_tool, session):+ mock_client = AsyncMock()+ mock_client.get_execution_schedules = AsyncMock(+ return_value=[_make_graph_info(schedule_id="expert-job", expert_id="expert-a")]+ )+ mock_client.delete_schedule = AsyncMock()++ with patch(f"{_SCHEDULES_PATH}.get_scheduler_client", return_value=mock_client):+ result = await delete_tool._execute(+ user_id=_USER, session=session, schedule_id="expert-job"+ )++ assert isinstance(result, ScheduleDeletedResponse)+ mock_client.delete_schedule.assert_awaited_once()+++ ("tool", "method", "session_expert_id"),+ [+ (PauseScheduleTool(), "pause_schedule", None),+ (ResumeScheduleTool(), "resume_schedule", None),+ (PauseScheduleTool(), "pause_schedule", "expert-a"),+ ],+)+async def test_pause_and_resume_within_scope(tool, method, session_expert_id):+ scoped_session = make_session(_USER, expert_id=session_expert_id)+ mock_client = AsyncMock()+ mock_client.get_execution_schedules = AsyncMock(+ return_value=[_make_graph_info(schedule_id="expert-job", expert_id="expert-a")]+ )+ setattr(mock_client, method, AsyncMock(return_value=True))++ with patch(f"{_SCHEDULES_PATH}.get_scheduler_client", return_value=mock_client):+ result = await tool._execute(+ user_id=_USER, session=scoped_session, schedule_id="expert-job"+ )++ assert isinstance(result, ScheduleToggledResponse)+ getattr(mock_client, method).assert_awaited_once_with("expert-job", _USER)+++async def test_expert_cannot_pause_another_experts_schedule():+ scoped_session = make_session(_USER, expert_id="expert-b")+ mock_client = AsyncMock()+ mock_client.get_execution_schedules = AsyncMock(+ return_value=[_make_graph_info(schedule_id="expert-job", expert_id="expert-a")]+ )+ mock_client.pause_schedule = AsyncMock()++ with patch(f"{_SCHEDULES_PATH}.get_scheduler_client", return_value=mock_client):+ result = await PauseScheduleTool()._execute(+ user_id=_USER, session=scoped_session, schedule_id="expert-job"+ )++ assert isinstance(result, ErrorResponse) and result.error == "schedule_not_found"+ mock_client.pause_schedule.assert_not_awaited()+++async def test_list_schedules_marks_paused_entries(list_tool, session):+ paused = _make_graph_info(schedule_id="paused-job")+ paused.next_run_time = ""+ mock_client = AsyncMock()+ mock_client.get_execution_schedules = AsyncMock(return_value=[paused])++ with patch(f"{_SCHEDULES_PATH}.get_scheduler_client", return_value=mock_client):+ result = await list_tool._execute(user_id=_USER, session=session)++ assert isinstance(result, ScheduleListResponse)+ assert result.schedules[0].paused is True+ assert (+ mock_client.get_execution_schedules.call_args.kwargs["include_paused"] is True+ )+++ ("tool", "method"),+ [+ (DeleteScheduleTool(), "delete_schedule"),+ (ResumeScheduleTool(), "resume_schedule"),+ ],+)+async def test_an_archived_experts_paused_schedule_is_out_of_reach(+ tool, method, session+):+ """detach_expert_triggers pauses rather than deletes so re-hire can restore+ the cadence. Deleting one loses it permanently; resuming one produces a+ schedule that fires and is refused at run time. The REST listing already+ hides these rows, so the tools have to agree."""+ paused = _make_graph_info(schedule_id="archived-job", expert_id="gone")+ paused = paused.model_copy(update={"next_run_time": ""})+ mock_client = AsyncMock()+ mock_client.get_execution_schedules = AsyncMock(return_value=[paused])++ with (+ patch(f"{_SCHEDULES_PATH}.get_scheduler_client", return_value=mock_client),+ patch(+ "backend.api.features.experts.experts_db.active_expert_ids",+ AsyncMock(return_value=set()),+ ),+ ):+ result = await tool._execute(+ user_id=_USER, session=session, schedule_id="archived-job"+ )++ assert isinstance(result, ErrorResponse) and result.error == "schedule_not_found"+ getattr(mock_client, method).assert_not_awaited()+++async def test_a_live_experts_paused_schedule_is_still_reachable(session):+ """The guard keys on the expert being gone, not on the schedule being+ paused — pausing one and resuming it must keep working."""+ paused = _make_graph_info(schedule_id="live-job", expert_id="expert-a")+ paused = paused.model_copy(update={"next_run_time": ""})+ mock_client = AsyncMock()+ mock_client.get_execution_schedules = AsyncMock(return_value=[paused])+ mock_client.resume_schedule = AsyncMock(return_value=True)++ with (+ patch(f"{_SCHEDULES_PATH}.get_scheduler_client", return_value=mock_client),+ patch(+ "backend.api.features.experts.experts_db.active_expert_ids",+ AsyncMock(return_value={"expert-a"}),+ ),+ ):+ result = await ResumeScheduleTool()._execute(+ user_id=_USER, session=session, schedule_id="live-job"+ )++ assert isinstance(result, ScheduleToggledResponse)+ mock_client.resume_schedule.assert_awaited_once()+++async def test_list_hides_an_archived_experts_paused_schedule(list_tool, session):+ """Listing one the mutation tools refuse is worse than not listing it: the+ model would hand its id to resume_schedule and be told it does not exist."""+ live = _make_graph_info(schedule_id="live", expert_id="expert-a")+ archived = _make_graph_info(schedule_id="archived", expert_id="gone").model_copy(+ update={"next_run_time": ""}+ )+ mock_client = AsyncMock()+ mock_client.get_execution_schedules = AsyncMock(return_value=[live, archived])++ with (+ patch(f"{_SCHEDULES_PATH}.get_scheduler_client", return_value=mock_client),+ patch(+ "backend.api.features.experts.experts_db.active_expert_ids",+ AsyncMock(return_value={"expert-a"}),+ ),+ ):+ result = await list_tool._execute(user_id=_USER, session=session)++ assert isinstance(result, ScheduleListResponse)+ assert [s.schedule_id for s in result.schedules] == ["live"]+++async def test_list_keeps_a_live_experts_paused_schedule(list_tool, session):+ """The guard keys on the expert being gone, not on the schedule being+ paused — a paused row still needs to be listable to be resumed."""+ paused = _make_graph_info(schedule_id="paused", expert_id="expert-a").model_copy(+ update={"next_run_time": ""}+ )+ mock_client = AsyncMock()+ mock_client.get_execution_schedules = AsyncMock(return_value=[paused])++ with (+ patch(f"{_SCHEDULES_PATH}.get_scheduler_client", return_value=mock_client),+ patch(+ "backend.api.features.experts.experts_db.active_expert_ids",+ AsyncMock(return_value={"expert-a"}),+ ),+ ):+ result = await list_tool._execute(user_id=_USER, session=session)++ assert isinstance(result, ScheduleListResponse)+ assert [s.schedule_id for s in result.schedules] == ["paused"]+ assert result.schedules[0].paused is True+++ ("tool", "method", "changed", "expect_event"),+ [+ (PauseScheduleTool(), "pause_schedule", True, True),+ (PauseScheduleTool(), "pause_schedule", False, False),+ (ResumeScheduleTool(), "resume_schedule", True, True),+ (ResumeScheduleTool(), "resume_schedule", False, False),+ ],+)+async def test_a_no_op_toggle_leaves_no_activity_event(+ tool, method, changed, expect_event, session+):+ """The scheduler returns False when the schedule was already in that state.+ The activity log is append-only, so pausing an already-paused schedule must+ not leave a schedule.paused entry the user never caused."""+ mock_client = AsyncMock()+ mock_client.get_execution_schedules = AsyncMock(+ return_value=[_make_graph_info(schedule_id="sched-1")]+ )+ setattr(mock_client, method, AsyncMock(return_value=changed))++ with patch(f"{_SCHEDULES_PATH}.get_scheduler_client", return_value=mock_client):+ result = await tool._execute(+ user_id=_USER, session=session, schedule_id="sched-1"+ )++ assert isinstance(result, ScheduleToggledResponse)+ assert result.changed is changed+ assert (tool.activity_event(session, result) is not None) is expect_eventdiff --git a/autogpt_platform/backend/backend/copilot/tools/models.py b/autogpt_platform/backend/backend/copilot/tools/models.pyindex e9d5f02d40..9258bcea3b 100644--- a/autogpt_platform/backend/backend/copilot/tools/models.py+++ b/autogpt_platform/backend/backend/copilot/tools/models.py@@ -49,6 +49,7 @@ class ResponseType(str, Enum):# SchedulesSCHEDULE_LIST = "schedule_list"SCHEDULE_DELETED = "schedule_deleted"+ SCHEDULE_TOGGLED = "schedule_toggled"# Expert resources (installed workflows, credential grants)EXPERT_WORKFLOW = "expert_workflow"EXPERT_WORKFLOWS = "expert_workflows"diff --git a/autogpt_platform/backend/backend/copilot/tools/run_agent.py b/autogpt_platform/backend/backend/copilot/tools/run_agent.pyindex e1c40cd354..1717883c28 100644--- a/autogpt_platform/backend/backend/copilot/tools/run_agent.py+++ b/autogpt_platform/backend/backend/copilot/tools/run_agent.py@@ -1202,7 +1202,7 @@ class RunAgentTool(BaseTool):inputs: dict[str, Any],schedule_name: str,cron: str,- timezone: str,+ timezone: str | None,) -> ToolResponseBase:"""Set up scheduled execution for an agent."""session_id = session.session_iddiff --git a/autogpt_platform/backend/backend/copilot/tools/run_agent_timezone_test.py b/autogpt_platform/backend/backend/copilot/tools/run_agent_timezone_test.pynew file mode 100644index 0000000000..d8ee330ac8--- /dev/null+++ b/autogpt_platform/backend/backend/copilot/tools/run_agent_timezone_test.py@@ -0,0 +1,59 @@+from unittest.mock import AsyncMock, MagicMock, patch++import pytest++from backend.copilot.model import ChatSession+from backend.copilot.tools.run_agent import RunAgentInput, RunAgentTool++_PATH = "backend.copilot.tools.run_agent"+++ "requested,expected", [("UTC", "UTC"), ("Europe/London", "Europe/London")]+)+async def test_schedule_explicit_timezone(requested, expected):+ await _check_schedule_timezone(requested, expected)+++async def test_schedule_omitted_timezone_uses_account():+ await _check_schedule_timezone(RunAgentInput().timezone, "Asia/Calcutta")+++async def _check_schedule_timezone(requested, expected):+ session = ChatSession.new("owner", dry_run=False)+ session.organization_id = "org"+ session.team_id = "team"+ scheduler = MagicMock(+ add_execution_schedule=AsyncMock(side_effect=RuntimeError("captured"))+ )+ with (+ patch(+ f"{_PATH}.get_or_create_library_agent", AsyncMock(return_value=MagicMock())+ ),+ patch(f"{_PATH}.emit_tool_display_name"),+ patch(+ f"{_PATH}.user_db",+ return_value=MagicMock(+ get_user_by_id=AsyncMock(+ return_value=MagicMock(timezone="Asia/Calcutta")+ )+ ),+ ),+ patch(f"{_PATH}.get_scheduler_client", return_value=scheduler),+ ):+ with pytest.raises(RuntimeError, match="captured"):+ await RunAgentTool()._schedule_agent(+ "owner",+ session,+ MagicMock(id="graph"),+ {},+ {},+ "QA",+ "0 9 * * *",+ requested,+ )+ assert (+ scheduler.add_execution_schedule.await_args.kwargs["user_timezone"] == expected+ )diff --git a/autogpt_platform/backend/backend/copilot/tools/tool_schema_test.py b/autogpt_platform/backend/backend/copilot/tools/tool_schema_test.pyindex 0dfc8498e2..92d460e14a 100644--- a/autogpt_platform/backend/backend/copilot/tools/tool_schema_test.py+++ b/autogpt_platform/backend/backend/copilot/tools/tool_schema_test.py@@ -147,7 +147,13 @@ from backend.copilot.tools import TOOL_REGISTRY# Measure it the way this test does — one json.dumps over the whole list —# not by summing per-tool lengths, which misses ~142 chars of array# separators and overstates the headroom.-_CHAR_BUDGET = 67_651+# Bumped 67_651 -> 68_238 for pause_schedule and resume_schedule, the two tools+# this PR adds. MEASURE ON THE PR'S MERGE REF, never on the branch tip: a stacked+# PR's CI builds this branch merged through its base into dev, so dev's own growth+# counts against this ceiling. The tip reads 68,235 and `refs/pull/14416/merge`+# 68,237 — dev widened raise_expert by two characters after this line was first+# set, which reddened three interpreters on a branch that had added nothing.+_CHAR_BUDGET = 68_238@pytest.fixture(scope="module")diff --git a/autogpt_platform/backend/backend/data/execution.py b/autogpt_platform/backend/backend/data/execution.pyindex f38a2a4e72..0700a673c3 100644--- a/autogpt_platform/backend/backend/data/execution.py+++ b/autogpt_platform/backend/backend/data/execution.py@@ -630,6 +630,7 @@ async def get_graph_executions(offset: Optional[int] = None,order_by: Literal["createdAt", "startedAt", "updatedAt"] = "createdAt",order_direction: Literal["asc", "desc"] = "desc",+ expert_id: Optional[str] = None,) -> list[GraphExecutionMeta]:"""Get graph executions with optional filters and ordering.@@ -661,6 +662,8 @@ async def get_graph_executions(where_filter["agentGraphId"] = graph_idif graph_version is not None:where_filter["agentGraphVersion"] = graph_version+ if expert_id:+ where_filter["expertId"] = expert_idif created_time_gte or created_time_lte:where_filter["createdAt"] = {"gte": created_time_gte or datetime.min.replace(tzinfo=timezone.utc),diff --git a/autogpt_platform/backend/backend/executor/scheduler.py b/autogpt_platform/backend/backend/executor/scheduler.pyindex 96cecff59a..9b013d0c15 100644--- a/autogpt_platform/backend/backend/executor/scheduler.py+++ b/autogpt_platform/backend/backend/executor/scheduler.py@@ -2266,6 +2266,7 @@ class Scheduler(AppService):user_id: str | None = None,organization_id: str | None = None,team_ids: list[str] | None = None,+ include_paused: bool = False,) -> list[GraphExecutionJobInfo]:"""Return graph-kind schedules only (typed for legacy callers).@@ -2282,6 +2283,7 @@ class Scheduler(AppService):kind="graph",organization_id=organization_id,team_ids=team_ids,+ include_paused=include_paused,)if isinstance(info, GraphExecutionJobInfo)]diff --git a/autogpt_platform/backend/backend/executor/scheduler_unit_test.py b/autogpt_platform/backend/backend/executor/scheduler_unit_test.pyindex 0cced5e5d5..1afcb46990 100644--- a/autogpt_platform/backend/backend/executor/scheduler_unit_test.py+++ b/autogpt_platform/backend/backend/executor/scheduler_unit_test.py@@ -1965,3 +1965,28 @@ class TestMorningBriefingSchedule:"Failed to remove morning briefing job" in r.getMessage()for r in caplog.records)+++def test_graph_schedule_listing_can_include_paused_jobs():+ fixtures = TestScheduleOrgVisibility()+ info = fixtures._graph_info(user_id="owner")+ sched, jobs, decode = fixtures._scheduler_with_jobs([info])+ jobs[0].next_run_time = None+ # Two caches, not one: the default path reads the SQL-filtered+ # _get_active_jobs_cached and only include_paused reads the unfiltered+ # _get_jobs_cached. Patching one leaves the other on the real jobstore,+ # which this Scheduler.__new__ instance does not have.+ active = [j for j in jobs if j.next_run_time is not None]+ with (+ patch.object(Scheduler, "_get_jobs_cached", return_value=jobs),+ patch.object(Scheduler, "_get_active_jobs_cached", return_value=active),+ patch("backend.executor.scheduler._job_to_info", side_effect=decode),+ ):+ assert sched.get_graph_execution_schedules(user_id="owner") == []+ assert sched.get_graph_execution_schedules(+ user_id="owner", include_paused=True+ ) == [info]+ assert (+ sched.get_graph_execution_schedules(user_id="other", include_paused=True)+ == []+ )diff --git a/autogpt_platform/frontend/src/app/api/openapi.json b/autogpt_platform/frontend/src/app/api/openapi.jsonindex 4b9941126f..4143e21ebf 100644--- a/autogpt_platform/frontend/src/app/api/openapi.json+++ b/autogpt_platform/frontend/src/app/api/openapi.json@@ -3902,6 +3902,7 @@},{ "$ref": "#/components/schemas/ScheduleListResponse" },{ "$ref": "#/components/schemas/ScheduleDeletedResponse" },+ { "$ref": "#/components/schemas/ScheduleToggledResponse" },{ "$ref": "#/components/schemas/PresetListResponse" },{ "$ref": "#/components/schemas/PresetUpdatedResponse" },{ "$ref": "#/components/schemas/PresetDeletedResponse" },@@ -27469,6 +27470,7 @@"review_required","schedule_list","schedule_deleted",+ "schedule_toggled","expert_workflow","expert_workflows","expert_credentials",@@ -27909,6 +27911,11 @@"name": { "type": "string", "title": "Name" },"timezone": { "type": "string", "title": "Timezone" },"next_run_time": { "type": "string", "title": "Next Run Time" },+ "expert_id": {+ "anyOf": [{ "type": "string" }, { "type": "null" }],+ "title": "Expert Id"+ },+ "paused": { "type": "boolean", "title": "Paused", "default": false },"cron": {"anyOf": [{ "type": "string" }, { "type": "null" }],"title": "Cron"@@ -27945,6 +27952,25 @@"title": "ScheduleSummary","description": "Summary of a single schedule (either a graph run or copilot turn)."},+ "ScheduleToggledResponse": {+ "properties": {+ "type": {+ "$ref": "#/components/schemas/ResponseType",+ "default": "schedule_toggled"+ },+ "message": { "type": "string", "title": "Message" },+ "session_id": {+ "anyOf": [{ "type": "string" }, { "type": "null" }],+ "title": "Session Id"+ },+ "schedule_id": { "type": "string", "title": "Schedule Id" },+ "paused": { "type": "boolean", "title": "Paused" },+ "changed": { "type": "boolean", "title": "Changed", "default": true }+ },+ "type": "object",+ "required": ["message", "schedule_id", "paused"],+ "title": "ScheduleToggledResponse"+ },"SchedulesListResponse": {"properties": {"schedules": {diff --git a/autogpt_platform/frontend/src/components/contextual/SchedulesPanel/components/GraphScheduleListItem/GraphScheduleListItem.test.tsx b/autogpt_platform/frontend/src/components/contextual/SchedulesPanel/components/GraphScheduleListItem/GraphScheduleListItem.test.tsxnew file mode 100644index 0000000000..1e96cee7cf--- /dev/null+++ b/autogpt_platform/frontend/src/components/contextual/SchedulesPanel/components/GraphScheduleListItem/GraphScheduleListItem.test.tsx@@ -0,0 +1,54 @@+import type { GraphExecutionJobInfo } from "@/app/api/__generated__/models/graphExecutionJobInfo";+import { render, screen } from "@/tests/integrations/test-utils";+import userEvent from "@testing-library/user-event";+import { describe, expect, it } from "vitest";+import { GraphScheduleListItem } from "./GraphScheduleListItem";++const schedule: GraphExecutionJobInfo = {+ id: "schedule",+ user_id: "owner",+ name: "Expert schedule",+ graph_id: "graph",+ graph_version: 1,+ cron: "0 9 * * *",+ input_data: {},+ next_run_time: "",+};++describe("GraphScheduleListItem", () => {+ it("shows a paused schedule with its name and actions", () => {+ render(<GraphScheduleListItem schedule={schedule} />);+ expect(screen.getByText("Expert schedule")).toBeDefined();+ expect(screen.getByText("Paused")).toBeDefined();+ expect(screen.queryByText("Pending")).toBeNull();+ });++ it("shows the relative next run in both the row and the dialog", async () => {+ // The other side of nextRunValue: a schedule that is actually going to+ // fire. The row prefixes it, the dialog shows it bare, and neither says+ // Paused.+ const future = new Date(Date.now() + 60 * 60 * 1000).toISOString();+ render(+ <GraphScheduleListItem+ schedule={{ ...schedule, next_run_time: future }}+ />,+ );+ expect(screen.getByText(/^Next in about 1 hour$/)).toBeDefined();+ expect(screen.queryByText("Paused")).toBeNull();++ await userEvent.setup().click(screen.getByLabelText("View schedule"));+ expect(await screen.findByText("Next run")).toBeDefined();+ expect(screen.getByText("in about 1 hour")).toBeDefined();+ });++ it("says Paused in the View dialog too, not Pending", async () => {+ // The row and the dialog used to derive this separately, so a paused+ // schedule read "Paused" in the row and "Next run: Pending" on opening it.+ render(<GraphScheduleListItem schedule={schedule} />);+ await userEvent.setup().click(screen.getByLabelText("View schedule"));++ expect(await screen.findByText("Next run")).toBeDefined();+ expect(screen.queryByText("Pending")).toBeNull();+ expect(screen.getAllByText("Paused").length).toBeGreaterThan(1);+ });+});diff --git a/autogpt_platform/frontend/src/components/contextual/SchedulesPanel/components/GraphScheduleListItem/GraphScheduleListItem.tsx b/autogpt_platform/frontend/src/components/contextual/SchedulesPanel/components/GraphScheduleListItem/GraphScheduleListItem.tsxindex ebff862a1e..670b0f8348 100644--- a/autogpt_platform/frontend/src/components/contextual/SchedulesPanel/components/GraphScheduleListItem/GraphScheduleListItem.tsx+++ b/autogpt_platform/frontend/src/components/contextual/SchedulesPanel/components/GraphScheduleListItem/GraphScheduleListItem.tsx@@ -39,7 +39,7 @@ export function GraphScheduleListItem({}: Props) {const {nextRunLabel,- nextRunRelative,+ nextRunValue,nextRunTitle,recurrenceLabel,agentLabel,@@ -164,7 +164,7 @@ export function GraphScheduleListItem({<dl className="divide-y divide-zinc-100 overflow-hidden rounded-xl border border-zinc-200/80 bg-zinc-50/60"><ScheduleMetaRowlabel="Next run"- value={nextRunRelative ?? "Pending"}+ value={nextRunValue}title={nextRunTitle}/><ScheduleMetaRow label="Repeats" value={recurrenceLabel} />diff --git a/autogpt_platform/frontend/src/components/contextual/SchedulesPanel/components/GraphScheduleListItem/useGraphScheduleListItem.ts b/autogpt_platform/frontend/src/components/contextual/SchedulesPanel/components/GraphScheduleListItem/useGraphScheduleListItem.tsindex 3540352a20..146847f1b7 100644--- a/autogpt_platform/frontend/src/components/contextual/SchedulesPanel/components/GraphScheduleListItem/useGraphScheduleListItem.ts+++ b/autogpt_platform/frontend/src/components/contextual/SchedulesPanel/components/GraphScheduleListItem/useGraphScheduleListItem.ts@@ -27,7 +27,15 @@ export function useGraphScheduleListItem({ schedule }: Args) {nextRunDate && !Number.isNaN(nextRunDate.valueOf())? formatDistanceToNow(nextRunDate, { addSuffix: true }): null;- const nextRunLabel = nextRunRelative ? `Next ${nextRunRelative}` : "Pending";+ // One source of truth: the row prefixes it, the View dialog shows it bare.+ const nextRunValue = nextRunRelative+ ? nextRunRelative+ : schedule.next_run_time+ ? "Pending"+ : "Paused";+ const nextRunLabel = nextRunRelative+ ? `Next ${nextRunRelative}`+ : nextRunValue;const nextRunTitle = nextRunDate ? nextRunDate.toString() : undefined;const recurrenceLabel = schedule.cron@@ -70,7 +78,7 @@ export function useGraphScheduleListItem({ schedule }: Args) {return {nextRunLabel,- nextRunRelative,+ nextRunValue,nextRunTitle,recurrenceLabel,agentLabel,diff --git a/docs/integrations/block-integrations/misc.md b/docs/integrations/block-integrations/misc.mdindex d1312d1bdd..3cedff60d9 100644--- a/docs/integrations/block-integrations/misc.md+++ b/docs/integrations/block-integrations/misc.md@@ -96,7 +96,7 @@ Tool and block identifiers provided in `tools` and `blocks` are validated at run| transport | Run on platform credits, or on your connected ChatGPT subscription if supported by your plan. | "platform" \| "codex_app_server" | No || session_id | Session ID to continue an existing autopilot conversation. Leave empty to start a new session. Use the session_id output from a previous run to continue. | str | No || max_recursion_depth | Maximum nesting depth when the autopilot calls this block recursively (sub-agent pattern). Prevents infinite loops. | int | No |-| tools | Tool names to filter. Works with tools_exclude to form an allow-list or deny-list. Leave empty to apply no tool filter. | List["add_understanding" \| "ask_question" \| "bash_exec" \| "browser_act" \| "browser_navigate" \| "browser_screenshot" \| "confirm_expert_change" \| "confirm_expert_soul_update" \| "connect_integration" \| "continue_run_block" \| "create_agent" \| "create_feature_request" \| "create_folder" \| "customize_agent" \| "decompose_goal" \| "delegate_to_expert" \| "delete_folder" \| "delete_preset" \| "delete_schedule" \| "delete_skill" \| "delete_workspace_file" \| "edit_agent" \| "enter_agent_building_mode" \| "expert_onboarding" \| "find_agent" \| "find_block" \| "find_library_agent" \| "fix_agent_graph" \| "get_agent_building_guide" \| "get_doc_page" \| "get_mcp_guide" \| "get_platform_info" \| "get_sub_session_result" \| "grant_expert_credential" \| "handoff_to_expert" \| "hire_expert" \| "install_expert_workflow" \| "list_agent_triggers" \| "list_chat_platform_channels" \| "list_expert_chats" \| "list_expert_credentials" \| "list_expert_workflows" \| "list_folders" \| "list_presets" \| "list_schedules" \| "list_skills" \| "list_team" \| "list_workspace_files" \| "memory_forget_confirm" \| "memory_forget_search" \| "memory_search" \| "memory_store" \| "move_agents_to_folder" \| "move_folder" \| "post_to_chat_platform" \| "raise_expert" \| "read_expert_chat" \| "read_skill" \| "read_workspace_file" \| "remove_expert_workflow" \| "request_credential_grant" \| "revoke_expert_credential" \| "run_agent" \| "run_block" \| "run_mcp_tool" \| "run_sub_session" \| "schedule_followup" \| "search_docs" \| "search_feature_requests" \| "setup_agent_webhook_trigger" \| "store_skill" \| "update_expert" \| "update_expert_soul" \| "update_folder" \| "update_preset" \| "validate_agent_graph" \| "view_agent_output" \| "web_fetch" \| "web_search" \| "write_workspace_file" \| "Agent" \| "Edit" \| "Glob" \| "Grep" \| "Read" \| "Task" \| "TodoWrite" \| "WebSearch" \| "Write"] | No |+| tools | Tool names to filter. Works with tools_exclude to form an allow-list or deny-list. Leave empty to apply no tool filter. | List["add_understanding" \| "ask_question" \| "bash_exec" \| "browser_act" \| "browser_navigate" \| "browser_screenshot" \| "confirm_expert_change" \| "confirm_expert_soul_update" \| "connect_integration" \| "continue_run_block" \| "create_agent" \| "create_feature_request" \| "create_folder" \| "customize_agent" \| "decompose_goal" \| "delegate_to_expert" \| "delete_folder" \| "delete_preset" \| "delete_schedule" \| "delete_skill" \| "delete_workspace_file" \| "edit_agent" \| "enter_agent_building_mode" \| "expert_onboarding" \| "find_agent" \| "find_block" \| "find_library_agent" \| "fix_agent_graph" \| "get_agent_building_guide" \| "get_doc_page" \| "get_mcp_guide" \| "get_platform_info" \| "get_sub_session_result" \| "grant_expert_credential" \| "handoff_to_expert" \| "hire_expert" \| "install_expert_workflow" \| "list_agent_triggers" \| "list_chat_platform_channels" \| "list_expert_chats" \| "list_expert_credentials" \| "list_expert_workflows" \| "list_folders" \| "list_presets" \| "list_schedules" \| "list_skills" \| "list_team" \| "list_workspace_files" \| "memory_forget_confirm" \| "memory_forget_search" \| "memory_search" \| "memory_store" \| "move_agents_to_folder" \| "move_folder" \| "pause_schedule" \| "post_to_chat_platform" \| "raise_expert" \| "read_expert_chat" \| "read_skill" \| "read_workspace_file" \| "remove_expert_workflow" \| "request_credential_grant" \| "resume_schedule" \| "revoke_expert_credential" \| "run_agent" \| "run_block" \| "run_mcp_tool" \| "run_sub_session" \| "schedule_followup" \| "search_docs" \| "search_feature_requests" \| "setup_agent_webhook_trigger" \| "store_skill" \| "update_expert" \| "update_expert_soul" \| "update_folder" \| "update_preset" \| "validate_agent_graph" \| "view_agent_output" \| "web_fetch" \| "web_search" \| "write_workspace_file" \| "Agent" \| "Edit" \| "Glob" \| "Grep" \| "Read" \| "Task" \| "TodoWrite" \| "WebSearch" \| "Write"] | No || tools_exclude | Controls how the 'tools' list is interpreted. True (default): 'tools' is a deny-list — listed tools are blocked, all others are allowed. An empty 'tools' list means allow everything. False: 'tools' is an allow-list — only listed tools are permitted. | bool | No || blocks | Block identifiers to filter when the copilot uses run_block. Each entry can be: a block name (e.g. 'HTTP Request'), a full block UUID, or the first 8 hex characters of the UUID (e.g. 'c069dc6b'). Works with blocks_exclude. Leave empty to apply no block filter. | List[str] | No || blocks_exclude | Controls how the 'blocks' list is interpreted. True (default): 'blocks' is a deny-list — listed blocks are blocked, all others are allowed. An empty 'blocks' list means allow everything. False: 'blocks' is an allow-list — only listed blocks are permitted. | bool | No |