Soul-driven AI agent with permission-hardened tools, token budgets, and multi-channel access. Runs 24/7 from CLI, Telegram or More.
<!doctype html><html lang=en dir=ltr class="blog-wrapper blog-post-page mj-root plugin-blog plugin-id-default" data-has-hydrated=false><head><meta charset=UTF-8><meta name=generator content="Docusaurus v3.10.0"><title data-rh=true>Running an agent overnight: what breaks first | Mercury Agent</title><meta data-rh=true name=viewport content="width=device-width, initial-scale=1.0"/><meta data-rh=true property=og:url content=https://mercuryagent.sh/blog/running-an-agent-overnight /><meta data-rh=true property=og:locale content=en /><meta data-rh=true name=docusaurus_locale content=en /><meta data-rh=true name=docusaurus_tag content=default /><meta data-rh=true name=docsearch:language content=en /><meta data-rh=true name=docsearch:docusaurus_tag content=default /><meta data-rh=true name=theme-color content=#0a0d10 media="(prefers-color-scheme: dark)"/><meta data-rh=true name=theme-color content=#fbfbf8 media="(prefers-color-scheme: light)"/><meta data-rh=true name=description content="We read Mercury's scheduler and budget code and reproduced one behaviour, to find what fails during long unattended runs: skipped tasks, quiet errors, overlapping jobs and budget stops."/><meta data-rh=true property=og:description content="We read Mercury's scheduler and budget code and reproduced one behaviour, to find what fails during long unattended runs: skipped tasks, quiet errors, overlapping jobs and budget stops."/><meta data-rh=true name=keywords content="run ai agent overnight,unattended ai agent,ai agent scheduler failures,cron ai agent,ai agent token budget,long running agent"/><meta data-rh=true property=og:type content=article /><meta data-rh=true property=article:published_time content=2026-10-27T00:00:00.000Z /><meta data-rh=true property=article:author content=https://github.com/tashiriskhan /><meta data-rh=true property=article:tag content=Runtime,Engineering /><meta data-rh=true property=og:image content="https://mercuryagent.sh/img/og/blog/running-an-agent-overnight.jpg?v=2"/><meta data-rh=true property=og:image:secure_url content="https://mercuryagent.sh/img/og/blog/running-an-agent-overnight.jpg?v=2"/><meta data-rh=true property=og:image:type content=image/jpeg /><meta data-rh=true property=og:image:width content=1200 /><meta data-rh=true property=og:image:height content=630 /><meta data-rh=true property=og:image:alt content="Running an agent overnight: what breaks first. Runtime · 6 min read. Mercury Blog"/><meta data-rh=true name=twitter:card content=summary_large_image /><meta data-rh=true name=twitter:image content="https://mercuryagent.sh/img/og/blog/running-an-agent-overnight.jpg?v=2"/><meta data-rh=true name=twitter:image:alt content="Running an agent overnight: what breaks first. Runtime · 6 min read. Mercury Blog"/><meta data-rh=true property=og:title content="Running an agent overnight: what breaks first"/><meta data-rh=true name=twitter:title content="Running an agent overnight: what breaks first"/><meta data-rh=true property=article:section content=Runtime /><meta data-rh=true name=twitter:label1 content=Topic /><meta data-rh=true name=twitter:data1 content=Runtime /><meta data-rh=true name=twitter:label2 content="Reading time"/><meta data-rh=true name=twitter:data2 content="6 min read"/><link data-rh=true rel=icon href=/img/logo-light.png /><link data-rh=true rel=canonical href=https://mercuryagent.sh/blog/running-an-agent-overnight /><link data-rh=true rel=alternate href=https://mercuryagent.sh/blog/running-an-agent-overnight hreflang=en /><link data-rh=true rel=alternate href=https://mercuryagent.sh/blog/running-an-agent-overnight hreflang=x-default /><link data-rh=true rel=alternate type=text/markdown href=/blog/running-an-agent-overnight.md title="Markdown version"/><script data-rh=true type=application/ld+json>{"@context":"https://schema.org","@id":"https://mercuryagent.sh/blog/running-an-agent-overnight","@type":"BlogPosting","author":{"@type":"Person","description":"Contributor, Mercury","image":"https://github.com/tashiriskhan.png","name":"Tashir Khan","url":"https://github.com/tashiriskhan"},"datePublished":"2026-10-27T00:00:00.000Z","description":"We read Mercury's scheduler and budget code and reproduced one behaviour, to find what fails during long unattended runs: skipped tasks, quiet errors, overlapping jobs and budget stops.","headline":"Running an agent overnight: what breaks first","image":{"@id":"https://mercuryagent.sh/assets/images/cover-61d12eaab98994de1b8055f310523bc2.jpg","@type":"ImageObject","caption":"title image for the blog post: Running an agent overnight: what breaks first","contentUrl":"https://mercuryagent.sh/assets/images/cover-61d12eaab98994de1b8055f310523bc2.jpg","url":"https://mercuryagent.sh/assets/images/cover-61d12eaab98994de1b8055f310523bc2.jpg"},"isPartOf":{"@id":"https://mercuryagent.sh/blog","@type":"Blog","name":"Mercury Blog"},"keywords":["run ai agent overnight","unattended ai agent","ai agent scheduler failures","cron ai agent","ai agent token budget","long running agent"],"mainEntityOfPage":"https://mercuryagent.sh/blog/running-an-agent-overnight","name":"Running an agent overnight: what breaks first","url":"https://mercuryagent.sh/blog/running-an-agent-overnight"}</script><script data-rh=true type=application/ld+json>{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","item":"https://mercuryagent.sh/","name":"Mercury","position":1},{"@type":"ListItem","item":"https://mercuryagent.sh/blog","name":"Blog","position":2},{"@type":"ListItem","item":"https://mercuryagent.sh/blog/tags/runtime","name":"Runtime","position":3},{"@type":"ListItem","item":"https://mercuryagent.sh/blog/running-an-agent-overnight","name":"Running an agent overnight: what breaks first","position":4}]}</script><link rel=alternate type=application/rss+xml href=/blog/rss.xml title="Mercury Blog RSS Feed"><link rel=alternate type=application/atom+xml href=/blog/atom.xml title="Mercury Blog Atom Feed"><link rel=alternate type=application/json href=/blog/feed.json title="Mercury Blog JSON Feed"><meta name=twitter:site content=@mercuryagent><meta property=og:site_name content="Mercury Agent"><meta name=application-name content="Mercury Agent"><link rel=preconnect href=https://fonts.googleapis.com><link rel=preconnect href=https://fonts.gstatic.com crossorigin=anonymous><link rel=stylesheet href="https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700&family=Geist+Mono:wght@400;500;600&family=Instrument+Serif:ital@0;1&display=swap"><link rel=apple-touch-icon href=/img/logo-light.png><script src=https://analytics.cosmicstack.org/js/pa--flkUFvdfmsPSUtRivKAK.js async></script><script src=/js/plausible-init.js></script><link rel=stylesheet href=/assets/css/styles.b525f68d.css /><script src=/assets/js/runtime~main.c3075c62.js defer></script><script src=/assets/js/main.69097411.js defer></script></head><body><svg style="display: none;"><defs>
<symbol id=theme-svg-external-link viewBox="0 0 24 24"><path fill=currentColor d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"/></symbol>
</defs></svg>
<script>!function(){var t=function(){try{return new URLSearchParams(window.location.search).get("docusaurus-theme")}catch(t){}}()||function(){try{return window.localStorage.getItem("theme-ebb")}catch(t){}}();document.documentElement.setAttribute("data-theme",t||(window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light")),document.documentElement.setAttribute("data-theme-choice",t||"system")}(),function(){try{for(var[t,e]of new URLSearchParams(window.location.search).entries())if(t.startsWith("docusaurus-data-")){var a=t.replace("docusaurus-data-","data-");document.documentElement.setAttribute(a,e)}}catch(t){}}(),document.documentElement.setAttribute("data-announcement-bar-initially-dismissed",function(){try{return"true"===localStorage.getItem("docusaurus.announcement.dismiss-ebb")}catch(t){}return!1}())</script><div id=__docusaurus><link rel=preload as=image href=/img/logo-light.png /><link rel=preload as=image href=/img/logo-dark.png /><link rel=preload as=image href=https://github.com/tashiriskhan.png /><link rel=preload as=image href=/assets/images/cover-61d12eaab98994de1b8055f310523bc2.jpg fetchpriority=high /><div role=region aria-label="Skip to main content"><a class=skipToContent_fXgn href=#__docusaurus_skipToContent_fallback>Skip to main content</a></div><div class="theme-announcement-bar announcementBar_mb4j" role=banner><div class=announcementBarPlaceholder_vyr4></div><div class="content_knG7 announcementBarContent_xLdY">☿ Mercury 1.5.0 is out with <strong>Mercury Desktop</strong> for macOS, Windows and Linux, remote access you control, and updates that roll back on their own. <a href=/download>Download it →</a></div><button type=button aria-label=Close class="clean-btn close closeButton_CVFx announcementBarClose_gvF7"><svg viewBox="0 0 15 15" width=14 height=14><g stroke=currentColor stroke-width=3.1><path d="M.75.75l13.5 13.5M14.25.75L.75 14.25"/></g></svg></button></div><nav aria-label=Main class="theme-layout-navbar navbar navbar--fixed-top"><div class=navbar__inner><div class="theme-layout-navbar-left navbar__items"><button aria-label="Toggle navigation bar" aria-expanded=false class="navbar__toggle clean-btn" type=button><svg width=30 height=30 viewBox="0 0 30 30" aria-hidden=true><path stroke=currentColor stroke-linecap=round stroke-miterlimit=10 stroke-width=2 d="M4 7h22M4 15h22M4 23h22"/></svg></button><a class=navbar__brand href=/><div class=navbar__logo><img src=/img/logo-light.png alt="Mercury Agent" class="themedComponent_mlkZ themedComponent--light_NVdE"/><img src=/img/logo-dark.png alt="Mercury Agent" class="themedComponent_mlkZ themedComponent--dark_xIcU"/></div><b class="navbar__title text--truncate">Mercury</b></a><a class="navbar__item navbar__link" href=/docs>Docs</a><a class="navbar__item navbar__link" href=/docs/integrations/coding-workspace>Code</a><a class="navbar__item navbar__link" href=/docs/integrations/mercury-bots>Bots</a><a class="navbar__item navbar__link" href=/cloud>Cloud</a><a href=https://skills.mercuryagent.sh target=_blank rel="noopener noreferrer" class="navbar__item navbar__link">Skills<svg width=13.5 height=13.5 aria-label="(opens in new tab)" class=iconExternalLink_nPIU><use href=#theme-svg-external-link /></svg></a><a aria-current=page class="navbar__item navbar__link navbar__link--active" href=/blog>Blog</a><a class="navbar__item navbar__link" href=/docs/releases>Changelog</a></div><div class="theme-layout-navbar-right navbar__items navbar__items--right"><a href=https://github.com/cosmicstack-labs/mercury-agent target=_blank rel="noopener noreferrer" class="navbar__item navbar__link navbar-github" aria-label="Mercury Agent on GitHub"></a><a class="navbar__item navbar__link navbar-cta" href=/download>Download</a><div class="toggle_vylO colorModeToggle_DEke"><button class="clean-btn toggleButton_gllP toggleButtonDisabled_aARS" type=button disabled title="system mode" aria-label="Switch between dark and light mode (currently system mode)"><svg viewBox="0 0 24 24" width=24 height=24 aria-hidden=true class="toggleIcon_g3eP lightToggleIcon_pyhR"><path fill=currentColor d="M12,9c1.65,0,3,1.35,3,3s-1.35,3-3,3s-3-1.35-3-3S10.35,9,12,9 M12,7c-2.76,0-5,2.24-5,5s2.24,5,5,5s5-2.24,5-5 S14.76,7,12,7L12,7z M2,13l2,0c0.55,0,1-0.45,1-1s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S1.45,13,2,13z M20,13l2,0c0.55,0,1-0.45,1-1 s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S19.45,13,20,13z M11,2v2c0,0.55,0.45,1,1,1s1-0.45,1-1V2c0-0.55-0.45-1-1-1S11,1.45,11,2z M11,20v2c0,0.55,0.45,1,1,1s1-0.45,1-1v-2c0-0.55-0.45-1-1-1C11.45,19,11,19.45,11,20z M5.99,4.58c-0.39-0.39-1.03-0.39-1.41,0 c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0s0.39-1.03,0-1.41L5.99,4.58z M18.36,16.95 c-0.39-0.39-1.03-0.39-1.41,0c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0c0.39-0.39,0.39-1.03,0-1.41 L18.36,16.95z M19.42,5.99c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06c-0.39,0.39-0.39,1.03,0,1.41 s1.03,0.39,1.41,0L19.42,5.99z M7.05,18.36c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06 c-0.39,0.39-0.39,1.03,0,1.41s1.03,0.39,1.41,0L7.05,18.36z"/></svg><svg viewBox="0 0 24 24" width=24 height=24 aria-hidden=true class="toggleIcon_g3eP darkToggleIcon_wfgR"><path fill=currentColor d="M9.37,5.51C9.19,6.15,9.1,6.82,9.1,7.5c0,4.08,3.32,7.4,7.4,7.4c0.68,0,1.35-0.09,1.99-0.27C17.45,17.19,14.93,19,12,19 c-3.86,0-7-3.14-7-7C5,9.07,6.81,6.55,9.37,5.51z M12,3c-4.97,0-9,4.03-9,9s4.03,9,9,9s9-4.03,9-9c0-0.46-0.04-0.92-0.1-1.36 c-0.98,1.37-2.58,2.26-4.4,2.26c-2.98,0-5.4-2.42-5.4-5.4c0-1.81,0.89-3.42,2.26-4.4C12.92,3.04,12.46,3,12,3L12,3z"/></svg><svg viewBox="0 0 24 24" width=24 height=24 aria-hidden=true class="toggleIcon_g3eP systemToggleIcon_QzmC"><path fill=currentColor d="m12 21c4.971 0 9-4.029 9-9s-4.029-9-9-9-9 4.029-9 9 4.029 9 9 9zm4.95-13.95c1.313 1.313 2.05 3.093 2.05 4.95s-0.738 3.637-2.05 4.95c-1.313 1.313-3.093 2.05-4.95 2.05v-14c1.857 0 3.637 0.737 4.95 2.05z"/></svg></button></div><div class=navbarSearchContainer_Bca1><div class="navbar__search searchBarContainer_NW3z" dir=ltr><input placeholder=Search aria-label=Search class="navbar__search-input searchInput_YFbd" value="" /><div class="loadingRing_RJI3 searchBarLoadingRing_YnHq"><div></div><div></div><div></div><div></div></div></div></div></div></div><div role=presentation class=navbar-sidebar__backdrop></div></nav><div id=__docusaurus_skipToContent_fallback class="theme-layout-main main-wrapper mainWrapper_z2l0"><main class=mj-post><div class=mj-progress role=progressbar aria-label="Reading progress" aria-valuemin=0 aria-valuemax=100 aria-valuenow=0><span style=transform:scaleX(0)></span></div><button type=button class=mj-progress-pill aria-label="6 min left. Back to top" tabindex=-1><svg viewBox="0 0 20 20" width=18 height=18 aria-hidden=true><circle cx=10 cy=10 r=8 class=mj-ring-bg /><circle cx=10 cy=10 r=8 class=mj-ring style=stroke-dashoffset:50.27 /></svg><span>6 min left</span></button><header class=mj-post-head><a class=mj-back href=/blog>← Blog</a><a class=mj-post-cat href=/blog/tags/runtime>Runtime</a><h1 class=mj-post-title>Running an agent overnight: what breaks first</h1><p class=mj-post-dek>We read Mercury's scheduler and budget code and reproduced one behaviour, to find what fails during long unattended runs: skipped tasks, quiet errors, overlapping jobs and budget stops.<div class=mj-post-byline><div class=mj-post-authors><a class=mj-post-author href=/blog/authors/tashiriskhan><img src=https://github.com/tashiriskhan.png alt="" width=36 height=36 /><span><strong>Tashir Khan</strong><em>Contributor, Mercury</em></span></a></div><div class=mj-meta><time datetime=2026-10-27T00:00:00.000Z>Oct 27, 2026</time><span aria-hidden=true>·</span><span>6<!-- --> min read</span></div></div></header><div class=mj-post-banner><img src=/assets/images/cover-61d12eaab98994de1b8055f310523bc2.jpg alt="" width=1600 height=900 fetchpriority=high decoding=async /></div><div class="mj-post-layout has-toc"><aside class=mj-post-toc aria-label="On this page"><div class=mj-toc-head><p>On this page</p><span class=mj-toc-left>6 min left</span></div><div class=mj-toc-meter aria-hidden=true><span style=transform:scaleX(0)></span></div><div class=tableOfContentsInline_prmo><ul class=table-of-contents><li><a href=#delayed-tasks-due-during-downtime-are-skipped-confirmed-from-code>Delayed tasks due during downtime are skipped [Confirmed from code]</a><li><a href=#some-scheduler-errors-are-logged-but-not-sent-to-you-confirmed-from-code>Some scheduler errors are logged but not sent to you [Confirmed from code]</a><li><a href=#a-delayed-task-leaves-the-schedule-file-once-its-prompt-is-handed-off-confirmed-from-code>A delayed task leaves the schedule file once its prompt is handed off [Confirmed from code]</a><li><a href=#long-runs-may-overlap-reproduced-at-the-scheduler-level-queued-inside-the-agent>Long runs may overlap [Reproduced at the scheduler level; queued inside the agent]</a><li><a href=#budget-stops-can-be-silent-for-unattended-jobs-confirmed-from-code>Budget stops can be silent for unattended jobs [Confirmed from code]</a><li><a href=#a-checklist-before-you-leave-it-running>A checklist before you leave it running</a><li><a href=#recovery-is-not-replay>Recovery is not replay</a><li><a href=#what-still-breaks>What still breaks</a></ul></div></aside><article class="mj-prose markdown"><p>Most overnight agent failures are quiet. The agent doesn't crash. A job just doesn't run, or runs twice, and nobody is told. This post looks at where that happens in Mercury's scheduler and budget code.</p>
<!-- -->
<p>An agent that works when you watch it is a different product from one you leave running. When you're watching, you catch the stuck tool call and the wrong turn. Overnight, nobody catches them. This post covers what we found in Mercury's scheduler and budget code when we asked where an unattended run would fail first.</p>
<p><strong>Code snapshot:</strong> Based on Mercury 1.3.9, commit <code>c969d77</code> on <code>main</code>, as of October 27, 2026. Line references are to that commit.</p>
<p><strong>Evidence levels.</strong> Each finding is labelled:</p>
<ul>
<li class=""><strong>[Reproduced]</strong>: we ran the behaviour and observed it.</li>
<li class=""><strong>[Confirmed from code]</strong>: we traced the code path but did not run it end to end.</li>
<li class=""><strong>[Code-based hypothesis]</strong>: the code suggests it; we have not tested it.</li>
</ul>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id=delayed-tasks-due-during-downtime-are-skipped-confirmed-from-code>Delayed tasks due during downtime are skipped [Confirmed from code]<a href=#delayed-tasks-due-during-downtime-are-skipped-confirmed-from-code class=hash-link aria-label="Direct link to Delayed tasks due during downtime are skipped [Confirmed from code]" title="Direct link to Delayed tasks due during downtime are skipped [Confirmed from code]" translate=no></a></h3>
<p>Delayed tasks are saved to <code>schedules.yaml</code> in Mercury's home directory, with an <code>executeAt</code> time. On startup, <code>restorePersistedTasks</code> in <code>src/core/scheduler.ts</code> checks each one. If <code>executeAt</code> has already passed, it logs <code>Delayed task already expired, skipping</code> and does not run it.</p>
<p>For example, a delayed task due at 02:40, during a restart at 02:50, will not fire. A task due at 03:00 during the same restart will.</p>
<p>Cron tasks are re-registered on startup. We found no catch-up logic in the scheduler, so firings that fall inside a downtime window are not replayed. Different features behave differently; bot routines go through their own governor, described below.</p>
<p><strong>What to do:</strong> Use cron for recurring work. For one-off work that must run, check the log for <code>already expired</code> after every restart.</p>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id=some-scheduler-errors-are-logged-but-not-sent-to-you-confirmed-from-code>Some scheduler errors are logged but not sent to you [Confirmed from code]<a href=#some-scheduler-errors-are-logged-but-not-sent-to-you-confirmed-from-code class=hash-link aria-label="Direct link to Some scheduler errors are logged but not sent to you [Confirmed from code]" title="Direct link to Some scheduler errors are logged but not sent to you [Confirmed from code]" translate=no></a></h3>
<p>This claim is narrow. The scheduler's own error handlers only log:</p>
<ul>
<li class="">In <code>addTask</code>, a throwing handler logs <code>Scheduled task error</code>. Nothing else happens.</li>
<li class="">In <code>startHeartbeat</code>, a failing heartbeat logs <code>Heartbeat error</code>.</li>
<li class="">In <code>addDelayedTask</code>, a failing delayed task logs <code>Delayed task error</code>.</li>
</ul>
<p>Ordinary scheduled prompts take a different route. <code>handleScheduledTask</code> in <code>src/core/agent.ts</code> catches its own errors and logs <code>Scheduled task execution failed</code>. So for ordinary tasks, the scheduler's <code>Scheduled task error</code> path is usually not the one that fires. It fires for bot routines, where an error from enqueueing is not caught.</p>
<p>Successful output is separate. A scheduled task's result goes back through its source channel like any other reply. We did not check whether a failure inside the agent loop is sent to the channel, so treat a missing result as unknown, not as success.</p>
<p><strong>What to do:</strong> Don't rely on error logs for overnight work. Have each task send a short end-of-run message. If it doesn't arrive, assume the run did not finish.</p>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id=a-delayed-task-leaves-the-schedule-file-once-its-prompt-is-handed-off-confirmed-from-code>A delayed task leaves the schedule file once its prompt is handed off [Confirmed from code]<a href=#a-delayed-task-leaves-the-schedule-file-once-its-prompt-is-handed-off-confirmed-from-code class=hash-link aria-label="Direct link to A delayed task leaves the schedule file once its prompt is handed off [Confirmed from code]" title="Direct link to A delayed task leaves the schedule file once its prompt is handed off [Confirmed from code]" translate=no></a></h3>
<p>In <code>addDelayedTask</code>, a <code>finally</code> block removes the task from <code>schedules.yaml</code> when its handler returns, even if the handler threw. For ordinary tasks, <code>handleScheduledTask</code> does not throw, so the removal happens once the prompt has been queued.</p>
<p>The queued prompt is not lost on that basis alone. Accepted jobs are persisted in the work ledger, and on startup <code>recoverInterrupted()</code> re-queues the ones that were queued or interrupted (<code>src/core/agent.ts</code>). We have not tested a restart in the middle of a run.</p>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id=long-runs-may-overlap-reproduced-at-the-scheduler-level-queued-inside-the-agent>Long runs may overlap [Reproduced at the scheduler level; queued inside the agent]<a href=#long-runs-may-overlap-reproduced-at-the-scheduler-level-queued-inside-the-agent class=hash-link aria-label="Direct link to Long runs may overlap [Reproduced at the scheduler level; queued inside the agent]" title="Direct link to Long runs may overlap [Reproduced at the scheduler level; queued inside the agent]" translate=no></a></h3>
<p>Each cron task is registered with <code>cron.schedule</code> and an async handler. The scheduler keeps no in-flight flag per task ID. We reproduced this pattern with node-cron 3.0.3, the version Mercury pins: a job firing every second, with a handler that takes 3.5 seconds, reached four concurrent runs within eight seconds.</p>
<p>Inside Mercury, the effect is different. Scheduled prompts go onto the agent's message queue, which processes one message at a time. Overlapping firings for a main-agent task therefore wait in line rather than running in parallel. [Confirmed from code; not run end to end.] Each queued firing still costs budget when it runs.</p>
<p>Bot routines are different. The bot governor skips a tick when the bot is busy or the last run was too recent (<code>busy</code>, <code>too_soon</code>). [Confirmed from code.]</p>
<p><strong>What to do:</strong> Until overlap is tested on your own setup, avoid non-idempotent jobs (ones that write files, send messages, or spend money) with intervals shorter than their expected run time.</p>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id=budget-stops-can-be-silent-for-unattended-jobs-confirmed-from-code>Budget stops can be silent for unattended jobs [Confirmed from code]<a href=#budget-stops-can-be-silent-for-unattended-jobs-confirmed-from-code class=hash-link aria-label="Direct link to Budget stops can be silent for unattended jobs [Confirmed from code]" title="Direct link to Budget stops can be silent for unattended jobs [Confirmed from code]" translate=no></a></h3>
<p>Mercury tracks daily token use in <code>src/utils/tokens.ts</code>. The total is saved to <code>token-usage.json</code> and resets when the date changes, so a restart does not reset it. <code>isOverBudget()</code> is checked in <code>handleMessage</code> in <code>src/core/agent.ts</code>, before the agent loop runs.</p>
<p>Scheduled prompts are not exempt. They enter the same queue and reach the same check, so a scheduled job is stopped by the same daily budget as chat.</p>
<p>What differs is who hears about it:</p>
<ul>
<li class="">A chat message gets a budget notice. On the CLI, it gets an override prompt.</li>
<li class="">A scheduled job with a source channel gets the same notice on that channel.</li>
<li class="">A scheduled job with no source channel (<code>internal</code>) gets nothing. The check returns without sending a message.</li>
</ul>
<p>We traced this in the code but did not run it: we did not set a one-request budget and fire a job. To confirm on your install, set a low budget, fire one scheduled job with a source channel and one without, and check what each sends and logs.</p>
<p><strong>What to do:</strong> Keep daily headroom for the overnight run. Give unattended jobs a source channel so the notice reaches you. Check <code>/budget</code> in the morning.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id=a-checklist-before-you-leave-it-running>A checklist before you leave it running<a href=#a-checklist-before-you-leave-it-running class=hash-link aria-label="Direct link to A checklist before you leave it running" title="Direct link to A checklist before you leave it running" translate=no></a></h2>
<ul>
<li class="">Recurring work is on cron, not one-off delays.</li>
<li class="">Each overnight task sends an end-of-run message. No message means unknown.</li>
<li class="">Non-idempotent jobs don't run on intervals shorter than their expected run time.</li>
<li class="">The daily budget covers the overnight run with headroom.</li>
<li class="">Unattended jobs have a source channel, so budget notices reach you.</li>
<li class="">You've checked the log for <code>already expired</code> after the last restart.</li>
<li class="">You know what the agent does when a tool call hangs, and you've tested it.</li>
</ul>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id=recovery-is-not-replay>Recovery is not replay<a href=#recovery-is-not-replay class=hash-link aria-label="Direct link to Recovery is not replay" title="Direct link to Recovery is not replay" translate=no></a></h2>
<p>Mercury can recover after a restart. Accepted jobs that were queued or interrupted are re-queued from the work ledger. That does not mean every scheduled run is replayed. Firings during downtime are skipped, and expired delayed tasks are not run. Recovery covers work that was accepted. It does not cover work that never reached the ledger.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id=what-still-breaks>What still breaks<a href=#what-still-breaks class=hash-link aria-label="Direct link to What still breaks" title="Direct link to What still breaks" translate=no></a></h2>
<p>Scheduler reliability tells you a job ran. It doesn't tell you the job did the right thing. A tool that returns success with bad data, or a task that does the wrong thing correctly, passes every check above. An overnight run needs both: a schedule that fires, and a task that is correct when it does. We'll report the open tests here as we run them.</article></div><footer class=mj-post-foot><div class=mj-tools aria-label="Share and export"><button type=button>Copy as Markdown</button><a href=/blog/running-an-agent-overnight.md>View .md</a><button type=button>Copy link</button><a href="https://x.com/intent/post?url=https%3A%2F%2Fmercuryagent.sh%2Fblog%2Frunning-an-agent-overnight&text=Running%20an%20agent%20overnight%3A%20what%20breaks%20first" target=_blank rel="noopener noreferrer">Share on X</a><a href="https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fmercuryagent.sh%2Fblog%2Frunning-an-agent-overnight" target=_blank rel="noopener noreferrer">LinkedIn</a></div><div class=mj-post-tags><a href=/blog/tags/runtime>Runtime</a><a href=/blog/tags/engineering>Engineering</a></div><nav class=mj-pager aria-label="More posts"><a href=/blog/agent-observability-first-wrong-step><small>Newer</small>Your agent returned 200 OK. It may still have failed</a><a class=is-next href=/blog/how-optimus-works><small>Older</small>How Optimus works: an agent that uses your computer</a></nav><section class=mj-more><h2>More from the blog</h2><ul><li><a href=/blog/what-is-a-personal-ai-assistant>What Is a Personal AI Assistant? 10 Real Tasks in 2026</a><time datetime=2026-11-11T00:00:00.000Z>Nov 11, 2026</time><li><a href=/blog/six-ai-agents-compared-for-real-work>9 Safest, Most Secure, and Permission-Aware AI Agents for Real-World Tasks</a><time datetime=2026-11-05T00:00:00.000Z>Nov 5, 2026</time><li><a href=/blog/mercury-1-5>Mercury 1.5: Mercury Desktop</a><time datetime=2026-11-03T00:00:00.000Z>Nov 3, 2026</time></ul></section></footer></main></div><footer class="theme-layout-footer footer"><div class="container container-fluid"><div class="row footer__links"><div class="theme-layout-footer-column col footer__col"><div class=footer__title>Product</div><ul class="footer__items clean-list"><li class=footer__item><a class=footer__link-item href=/download>Download</a><li class=footer__item><a class=footer__link-item href=/#install>Install on a server</a><li class=footer__item><a class=footer__link-item href=/docs/integrations/coding-workspace>Mercury Code</a><li class=footer__item><a class=footer__link-item href=/docs/integrations/mercury-bots>Mercury Bots</a><li class=footer__item><a class=footer__link-item href=/cloud>Mercury Cloud</a><li class=footer__item><a class=footer__link-item href=/blog>Blog</a><li class=footer__item><a class=footer__link-item href=/docs/releases>Changelog</a></ul></div><div class="theme-layout-footer-column col footer__col"><div class=footer__title>Trust</div><ul class="footer__items clean-list"><li class=footer__item><a class=footer__link-item href=/docs/reference/permissions>Permissions model</a><li class=footer__item><a class=footer__link-item href=/docs/reference/second-brain>Second Brain memory</a><li class=footer__item><a class=footer__link-item href=/docs/reference/completion-architecture>Completion contract</a><li class=footer__item><a class=footer__link-item href=/#compare>Honest comparison</a></ul></div><div class="theme-layout-footer-column col footer__col"><div class=footer__title>Docs</div><ul class="footer__items clean-list"><li class=footer__item><a class=footer__link-item href=/docs>Getting started</a><li class=footer__item><a class=footer__link-item href=/docs/cli-commands/cli-commands>CLI commands</a><li class=footer__item><a class=footer__link-item href=/docs/reference/built-in-tools>Built-in tools</a><li class=footer__item><a class=footer__link-item href=/docs/reference/configuration>Configuration</a></ul></div><div class="theme-layout-footer-column col footer__col"><div class=footer__title>Community</div><ul class="footer__items clean-list"><li class=footer__item><a href=https://github.com/cosmicstack-labs/mercury-agent target=_blank rel="noopener noreferrer" class=footer__link-item>GitHub<svg width=13.5 height=13.5 aria-label="(opens in new tab)" class=iconExternalLink_nPIU><use href=#theme-svg-external-link /></svg></a><li class=footer__item><a href=https://github.com/cosmicstack-labs/mercury-agent/issues target=_blank rel="noopener noreferrer" class=footer__link-item>Issues<svg width=13.5 height=13.5 aria-label="(opens in new tab)" class=iconExternalLink_nPIU><use href=#theme-svg-external-link /></svg></a><li class=footer__item><a href=https://skills.mercuryagent.sh target=_blank rel="noopener noreferrer" class=footer__link-item>Skills registry<svg width=13.5 height=13.5 aria-label="(opens in new tab)" class=iconExternalLink_nPIU><use href=#theme-svg-external-link /></svg></a><li class=footer__item><a href=https://www.npmjs.com/package/@cosmicstack/mercury-agent target=_blank rel="noopener noreferrer" class=footer__link-item>npm<svg width=13.5 height=13.5 aria-label="(opens in new tab)" class=iconExternalLink_nPIU><use href=#theme-svg-external-link /></svg></a></ul></div></div><div class="footer__bottom text--center"><div class=footer__copyright>© 2026 Cosmic Stack · Mercury Agent is MIT-licensed open source.</div></div></div></footer></div></body>