golem-recurring-task-moonbit

Implements recurring cron-like tasks in MoonBit Golem agents via self-scheduling invocations.

1.5k|212|Updated Nov 24, 2023
One-click install
npx skills add https://github.com/golemcloud/golem --skill golem-recurring-task-moonbit
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golem-recurring-task-moonbit
Source: https://github.com/golemcloud/golem/tree/main/golem-skills/skills/moonbit/golem-recurring-task-moonbit
Command: npx skills add https://github.com/golemcloud/golem --skill golem-recurring-task-moonbit

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Golem agents have no built-in cron scheduler, so developers need a durable pattern to run periodic work like polling, cleanup, and heartbeats that survives agent crashes and restarts.

Core Features & Use Cases

  • Self-Scheduling Pattern: The agent calls schedule_ on its own generated client at the end of each invocation, creating a durable recurring loop that survives crashes.
  • Exponential Backoff: Increase the delay between runs on repeated failures and reset it on success, with configurable base and maximum intervals.
  • Cancellation Support: Stop recurring tasks via CancellationToken from schedule_cancelable_ methods, a simple state flag, or the Golem CLI with an idempotency key.
  • Use Case: Build a poller agent that checks an external API every 60 seconds, a cleanup agent that removes expired entries hourly, or a heartbeat agent that pings a monitoring service every 30 seconds.

Quick Start

Show me how to implement a recurring polling task in a MoonBit Golem agent that reschedules itself every 60 seconds.

Frequently Asked Questions about golem-recurring-task-moonbit

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a recurring task in a Golem agent with MoonBit?

Have the agent call schedule_ on its own generated client at the end of each invocation, passing a wall-clock datetime for the next run. This creates a durable loop where each execution enqueues the following one.

How do I implement exponential backoff for a scheduled agent task?

Track consecutive failures in agent state, then compute the delay as base interval times a power of two capped at a maximum interval. Reset the failure counter to zero whenever the work succeeds.

Can I cancel a scheduled Golem agent invocation?

Yes, use the schedule_cancelable_ client variant which returns a CancellationToken and call cancel() on it. Alternatively use a boolean state flag checked at the start of the method, or cancel via the Golem CLI with an idempotency key.

Does a scheduled Golem agent task survive crashes?

Yes, scheduled invocations are durable and persisted, so if the agent crashes the pending invocation still fires at the designated time and the agent recovers. Invocations on the same agent run sequentially without concurrency.

Why does recovery get slow for long-running recurring Golem agents?

Every scheduled tick appends entries to the agent's oplog, so recovery replays the full history and slows over time. Enable periodic snapshotting with the snapshotting attribute so recovery starts from the latest snapshot instead.