golem-recurring-task-scala

Implements cron-like recurring tasks in Scala Golem agents via self-scheduled invocations.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

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

Core Features & Use Cases

  • Self-Scheduling Pattern: The agent calls .poll.scheduleAt(...) on its own remote client to enqueue the next run, creating a durable recurring loop.
  • Exponential Backoff: Increase the delay between runs on repeated failures and reset it on success, capped at a maximum interval.
  • Cancellation Options: Stop the loop with a CancellationToken from scheduleCancelableAt, a simple state flag, or the Golem CLI using an idempotency key.
  • Use Case: An agent polls an external API every 60 seconds for pending items, processes them, and schedules its next invocation; if the agent crashes, the pending scheduled invocation still fires after recovery.

Quick Start

Ask the AI to implement a recurring polling task in a Scala Golem agent that schedules its own next invocation every 60 seconds using scheduleAt.

Frequently Asked Questions about golem-recurring-task-scala

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

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

Have the agent call scheduleAt on its own remote client at the end of each invocation, for example self.poll.scheduleAt(Datetime.afterSeconds(60)). This enqueues the next run durably, so it fires even if the agent crashes and restarts.

How do I cancel a scheduled invocation in Golem?

Use scheduleCancelableAt, which returns a CancellationToken you can store and cancel later. Alternatively, check a boolean state flag at the start of the scheduled method, or cancel from the CLI with golem agent invocation cancel using the idempotency key.

Does a scheduled Golem invocation survive agent crashes?

Yes. Scheduled invocations are durable and persisted, so a pending invocation still fires after the agent restarts. The agent recovers and the recurring loop continues without external intervention.

How do I add exponential backoff to a polling loop in Scala?

Track consecutive failures in agent state, then compute the delay as baseInterval times 2 to the power of failures, capped at a maximum interval. Reset the counter on success and pass the computed delay to scheduleAt.

What are the limitations of self-scheduling recurring tasks in Golem?

Each scheduled tick appends to the agent's oplog, so high-frequency loops cause unbounded oplog growth and slow crash recovery. The fix is snapshot-based recovery using the snapshotting annotation so recovery starts from the latest snapshot.