Back to articles
Understand OpenClaw by Building One - 6: Agents are Running, Your are Sleeping

Understand OpenClaw by Building One - 6: Agents are Running, Your are Sleeping

via Dev.toZane Chen

1. Every Agent Starts as a Loop 2. Gear up Your Agent 3. Pack the Conversation And Carry On 4. Beyond the CLI 5. Many of Them 6. Agents are Running, Your are Sleeping 7. More Context! More Context! All code snippets and working code bases are available at this repo . Cron & Heartbeat Your agent works when you talk to it. But what if it could work while you sleep? Nothing different from a cron job in engineer world, cron expressions define when a job runs. A background worker checks every minute, finds due jobs, and dispatches them. Jobs are defined in CRON.md files with a schedule and prompt. The agent runs at the appointed time, does the work, and optionally posts a message back. class CronDef ( BaseModel ): id : str name : str description : str agent : str schedule : str # Cron expression prompt : str one_off : bool = False class CronWorker ( Worker ): async def run ( self ) -> None : while True : await self . _tick () await asyncio . sleep ( 60 ) async def _tick ( self ) -> None : j

Continue reading on Dev.to

Opens in a new tab

Read Full Article
3 views

Related Articles