Soul-driven AI agent with permission-hardened tools, token budgets, and multi-channel access. Runs 24/7 from CLI, Telegram or More.
"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([["454"],{2979(e,n,r){r.r(n),r.d(n,{metadata:()=>s,default:()=>u,frontMatter:()=>o,contentTitle:()=>c,toc:()=>d,assets:()=>a});var s=JSON.parse('{"id":"reference/scheduling","title":"Scheduling","description":"Mercury can schedule tasks using cron expressions or one-shot delays.","source":"@site/docs/reference/scheduling.mdx","sourceDirName":"reference","slug":"/reference/scheduling","permalink":"/docs/reference/scheduling","draft":false,"unlisted":false,"editUrl":"https://github.com/cosmicstack-labs/mercury-agent/tree/main/website/docs/reference/scheduling.mdx","tags":[],"version":"current","frontMatter":{"id":"scheduling","title":"Scheduling"},"sidebar":"docsSidebar","previous":{"title":"Provider Fallback","permalink":"/docs/reference/provider-fallback"},"next":{"title":"Skills","permalink":"/docs/reference/skills"}}'),t=r(74848),i=r(28453);let o={id:"scheduling",title:"Scheduling"},c,a={},d=[{value:"Recurring tasks",id:"recurring-tasks",level:2},{value:"One-shot delays",id:"one-shot-delays",level:2},{value:"Time zones and overlap",id:"time-zones-and-overlap",level:2},{value:"Offline and interrupted work",id:"offline-and-interrupted-work",level:2},{value:"Run outcomes",id:"run-outcomes",level:2}];function l(e){let n={code:"code",h2:"h2",li:"li",p:"p",strong:"strong",ul:"ul",...(0,i.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.p,{children:"Mercury can schedule tasks using cron expressions or one-shot delays."}),"\n",(0,t.jsx)(n.h2,{id:"recurring-tasks",children:"Recurring tasks"}),"\n",(0,t.jsx)(n.p,{children:"Tell Mercury in conversation:"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:'"Remind me every day at 9am to check the server"'}),"\n",(0,t.jsx)(n.li,{children:'"Schedule a weekly summary every Monday at 10am"'}),"\n"]}),"\n",(0,t.jsx)(n.h2,{id:"one-shot-delays",children:"One-shot delays"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:'"Remind me in 15 minutes to take a break"'}),"\n",(0,t.jsx)(n.li,{children:'"Ping me in 2 hours about the deployment"'}),"\n"]}),"\n",(0,t.jsxs)(n.p,{children:["Tasks persist to ",(0,t.jsx)(n.code,{children:"~/.mercury/schedules.yaml"})," and restore on restart. Responses route back to the channel (CLI or Telegram) where the task was created."]}),"\n",(0,t.jsx)(n.h2,{id:"time-zones-and-overlap",children:"Time zones and overlap"}),"\n",(0,t.jsxs)(n.p,{children:["Use a timezone for recurring work, for example: \u201CEvery weekday at 9am in\nAmerica/New_York, brief me on my calendar.\u201D The ",(0,t.jsx)(n.code,{children:"schedule_task"})," tool accepts an\nIANA ",(0,t.jsx)(n.code,{children:"timezone"}),"; the Schedules editor exposes the same setting. Existing schedules\nwithout one continue using the host timezone. Cron follows that zone's local clock,\nincluding daylight-saving changes."]}),"\n",(0,t.jsx)(n.p,{children:"A schedule never queues another main-agent run while its previous run is still\nqueued or running. Overlapping ticks are skipped, rather than accumulated for later.\nRecurring ticks missed while Mercury was offline are not replayed."}),"\n",(0,t.jsx)(n.h2,{id:"offline-and-interrupted-work",children:"Offline and interrupted work"}),"\n",(0,t.jsxs)(n.p,{children:["One-shot tasks have an explicit ",(0,t.jsx)(n.code,{children:"missed_run_policy"}),":"]}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.code,{children:"skip"})," (default, including older schedules): keep a skipped record when Mercury\nstarts after the due time."]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.code,{children:"run_once"}),": start the overdue task once after restart, provided no run had begun."]}),"\n"]}),"\n",(0,t.jsxs)(n.p,{children:["This policy does ",(0,t.jsx)(n.strong,{children:"not"})," retry failed or interrupted work. Mercury records a run\nbefore invoking it. If the process stops before the outcome is confirmed, the run\nbecomes ",(0,t.jsx)(n.strong,{children:"interrupted"})," and the schedule pauses. Failed runs also pause, because an\nexternal action may have succeeded before its response was lost."]}),"\n",(0,t.jsxs)(n.p,{children:["Check the prior run's effects before repeating it. In ",(0,t.jsx)(n.strong,{children:"Schedules \u2192 Edit"}),", choose\n",(0,t.jsx)(n.strong,{children:"Schedule again"})," to explicitly resume. For a one-shot, the delay starts again\nfrom when you save. Editing only a description or policy does not repeat the work.\nThe API equivalent is ",(0,t.jsx)(n.code,{children:"PUT /api/schedules/:id"})," with ",(0,t.jsx)(n.code,{children:'{"resume": true}'})," and, for a\none-shot, the desired ",(0,t.jsx)(n.code,{children:"delaySeconds"}),". Running tasks cannot be edited."]}),"\n",(0,t.jsx)(n.h2,{id:"run-outcomes",children:"Run outcomes"}),"\n",(0,t.jsxs)(n.p,{children:["The Schedules page and ",(0,t.jsx)(n.code,{children:"list_scheduled_tasks"})," show pending, running, completed,\nfailed, interrupted, skipped, or dispatched status. ",(0,t.jsx)(n.strong,{children:"Completed"})," means the main\nagent finished its turn; inspect its response for the actual task result. Bot\nschedules show ",(0,t.jsx)(n.strong,{children:"dispatched"})," after their separate queue accepts them; inspect the\nbot's run history for completion. Scheduled bot jobs whose run or retry was\ninterrupted go to the dead-letter queue (DLQ) instead of replaying automatically;\nfuture routines pause. Check their effects, then use ",(0,t.jsx)(n.code,{children:"/bots start <id>"})," to resume\nfuture routines or ",(0,t.jsx)(n.code,{children:"/bots replay <id> <jobId>"})," to explicitly repeat that job.\nA fresh queued bot job that never started can still resume. Manual/chat bot jobs\nkeep their existing recovery behavior."]}),"\n",(0,t.jsxs)(n.p,{children:["Run records are stored with the schedule in ",(0,t.jsx)(n.code,{children:"~/.mercury/schedules.yaml"}),", using an\natomic replacement. The latest run is kept for each recurring task. The most recent\n100 resolved one-shot records are retained; active work and unresolved failures are\nkept until you remove them. These safeguards prevent automatic scheduler replay;\nthey cannot guarantee exactly-once behavior from external services."]})]})}function u(e={}){let{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(l,{...e})}):l(e)}},28453(e,n,r){r.d(n,{R:()=>o,x:()=>c});var s=r(96540);let t={},i=s.createContext(t);function o(e){let n=s.useContext(i);return s.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function c(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:o(e.components),s.createElement(i.Provider,{value:n},e.children)}}}]);