Skip to content

routines: a schedule that kept checking an app moves onto that app's event, paused once the event is live, with one Undo - #488

Open
Yabuku-xD wants to merge 7 commits into
DuskBotAI:devfrom
Yabuku-xD:routines-switch-to-events
Open

Yabuku-xD wants to merge 7 commits into
DuskBotAI:devfrom
Yabuku-xD:routines-switch-to-events

Conversation

@Yabuku-xD

Copy link
Copy Markdown
Contributor

What and why

A routine that checks an app on a clock ("look for new applicants in Gmail every 5 minutes") runs the AI 288 times a day, even when nothing arrived. App events already exist (trigger with when=app_event), and the tool text says to prefer them for new work. But an existing schedule can only be moved by hand: create the event, then pause the schedule, two cards and two Undos, with nothing to stop the schedule from being paused before the event works. This PR makes "switch my applicant check to new emails" one step.

  • trigger create with when=app_event takes replaces: the trigger_id of the bot's schedule that kept checking the same app (server/routine-event-switch.ts, server/app-trigger-requests.ts).
  • The schedule is checked before anything is made. One that must keep its clock is refused with the reason:
    • a room goal;
    • a one-time or limit-reset schedule;
    • the daily brief;
    • one with checks, or a page, feed, price or script check (it already starts the AI only when something changed);
    • one in a chain;
    • one with an address other apps call.
  • The schedule is paused, never deleted, and only once the connected-apps service confirms the event (remote.state is active). Until then it keeps running, and the bot is told to pause it once trigger_info shows the event active.
  • The receipt's Undo deletes the automation and turns the schedule back on, unless the schedule was changed after the pause.
  • The tool result tells the bot what became of the schedule, so it can say so; the receipt card's text is unchanged (new card text must come from the language packs).
  • trigger_info action=usage now suggests this first for a frequent schedule that keeps checking an app.

Limits, stated plainly:

  • Items that arrived after the schedule's last run and before the event went live are not handled by either one.
  • When Undo finds the schedule edited after the pause, it leaves the schedule paused, and says nothing about it.
  • If pausing the schedule throws after the event was made, no receipt is written; a retry then gets "the same automation already exists".
  • App events need the managed connected-apps service; where it is off, trigger_info action=events says so and nothing changes.

This branch carries #483's commits (its tests are red on dev without them) and the link chaos fixes, as the other open PRs do. It conflicts with the "only when" PR on detail in server/app-trigger-requests.ts, server/app-triggers.test.ts and the catalog goldens: the second to merge needs both detail lines joined and UPDATE_AGENTS_CATALOG_GOLDENS=1 run again.

How it was checked

  • New tests in server/app-triggers.test.ts, through the real trigger host and the fake connected-apps service:
    • a switch pauses the schedule, and Undo deletes the event and turns the schedule back on;
    • Undo leaves a schedule edited after the pause as it was;
    • with the service not confirming the event, the schedule stays on and the bot is told to pause it later;
    • each schedule that must keep its clock, another bot's schedule and an unknown id are refused, and no automation is made.
  • Each rule was broken on purpose (no pause, pause before the event is live, Undo ignoring later edits); a test fails each time.
  • server/drivers/agents-call-triggers.test.ts and server/trigger-tools.test.ts: replaces goes through only on an app-event create.
  • Catalog goldens regenerated with UPDATE_AGENTS_CATALOG_GOLDENS=1; the budget test passes. agents-catalog.ts stays at 1,000 lines.
  • Every test under server/app-*, server/trigger*, server/drivers/agents-*, server/routine*, server/webhook* and server/automation* passes (1,599 tests, 1 skipped), and so do the CI source guards.
  • pnpm typecheck, pnpm lint and pnpm test pass (typecheck, lint and the tests above pass; the whole pnpm test was not run on this branch)
  • New behaviour has a test
  • No secrets, personal data or local paths in the diff or screenshots

… and the guest skill card test stages four kinds of work

bacb532 left two tests red on dev. Its new skill_manage description dropped the word reusable, so find_tool ranked
skills_list first for "save this procedure as a reusable skill"; the description says reusable SKILL.md again (a skill
is recurring work, which that change keeps). Its duplicate check turns away a create that covers an existing skill, and
the guest skill card test staged four skills with one description, the same as an earlier test's: each now has its own
kind of work.
…list's two retries

Fifteen tests failed in CI on Dec 1 in runs of main, a release and PRs DuskBotAI#477-DuskBotAI#483 whose changes do not reach them, a
different set each run, and pass locally. Each entry names the runs it failed in. vps-routing's 'reuses the existing
VPS with $settings' failed too (PR DuskBotAI#477, run 46623618361) but is left out: its name is made per case, and the list
matches names written in the file.
…s 60 servers link from their own addresses

Every link chaos run since the per-address limit on new links (adc99d7, Nov 14) was cancelled at CI's 60-minute
limit, on main pushes, the weekly run and every PR that touches the link service: the scenarios finished in about five
minutes and printed their table, but a socket or timer a scenario left open held the process. The run now exits once its
results are written. The storm's 60 servers set up their links over one connection, so the node's front gave them one
address, which the limit refused after 30 (Too many new links from here); each now uses its own connection, as 60
machines would. Locally, --quick passes all 12 scenarios and exits in 5.6 minutes.
…y list's retries

chat-mcp-tools' shutdown verdict, memory-order and the encrypted workspace restore failed in PR DuskBotAI#479's run 46740020170,
whose change does not reach them, and pass locally.
…os job installs no packages

The job runs `node apps/link-service/chaos/run.mjs` straight after checkout, so the undici import failed
with ERR_MODULE_NOT_FOUND before any scenario ran.
…ds nothing for 8 s, as the app does

src/lib/live-events.ts gives up on a dial that sends nothing in LIVE_EVENTS_OPEN_MS (8 s) and dials again. The probe
dropped a quiet stream only after it had sent something, so one silent dial after node-5xx's 502s held it down until
the relay closed it, about 90 s, and failed the scenario in CI on five of seven runs.
…event, paused once the event is live, with one Undo

trigger create when=app_event takes replaces: the trigger_id of the bot's schedule that kept checking the same app. The
server checks the schedule first and refuses one that must keep its clock (a room goal, a one-time or limit-reset
schedule, the daily brief, checks or a page/feed/price/script check, a chain, an address). It pauses the schedule only
once the connected-apps service confirms the event; until then the schedule keeps running and the bot is told to pause
it later. The receipt's Undo deletes the automation and turns the schedule back on, unless the schedule changed after
the pause. The usage report's note now offers this first for a frequent schedule that keeps checking an app.
@SiddDevZ

SiddDevZ commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Thanks, the refusal rules and the one-step Undo are well thought out. I'm not merging it yet: it adds a replaces parameter to the trigger tool for every bot and pauses the person's schedules on the bot's say-so, which is a product call for the maintainer. Leaving it open for that decision.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants