Back to blog
EngineeringDate unavailable· min read

Making Recurring Jobs Actually Recur

We shipped a fix for recurring worker jobs that weren't recurring, plus automatic scheduling for memory consolidation and model deprecation monitoring.

We shipped a fix today for a problem that's been lurking in our worker system since we built it: recurring jobs were only running once.

The Problem

Our worker handles scheduled jobs—things like nightly memory consolidation (sleep_consolidation) and weekly model deprecation checks. These jobs are supposed to run on a recurring schedule. Nightly jobs should run every night. Weekly jobs should run every week.

Instead, they ran once and then disappeared from the schedule. The scheduler was treating recurring jobs like one-off tasks. After the first execution, it would mark them complete and move on.

This meant we were relying on manual restarts to keep essential maintenance running. Not great for a platform that's supposed to operate autonomously.

The Fix

We updated the worker's job scheduling logic in backend/worker/schedule.py to handle recurring jobs properly. When a recurring job completes, the scheduler now automatically calculates the next run time and re-registers it. Nightly jobs get scheduled for the next night. Weekly jobs for the next week.

We also added automatic pipeline scheduling for two critical maintenance jobs: memory consolidation (which archives and optimizes agent memory during low-traffic hours) and model deprecation monitoring (which alerts us when Anthropic retires model IDs we depend on).

The changes touched backend/worker/jobs.py, backend/worker/main.py, backend/worker/schedule.py, lib/agent/routers/maintenance.py, and lib/agent/sleep_consolidation.py. We added tests to verify the recurrence behavior.

Why It Matters

Autonomous operation depends on reliable background maintenance. Memory consolidation keeps the agent_memory table performant as it grows. Model deprecation monitoring prevents surprise failures when Anthropic retires older models.

Before this fix, both processes required manual intervention. Now they run automatically on schedule, every night and every week, without human oversight.

What's Next

This fix closes a gap in our infrastructure reliability. The next step is extending the maintenance pipeline framework to cover other periodic health checks—things like database connection pool monitoring, task queue depth analysis, and agent execution performance metrics.

We're also exploring more sophisticated scheduling patterns: adaptive intervals based on system load, priority queuing for critical maintenance tasks, and dead-letter handling for jobs that fail repeatedly.

For now, recurring jobs actually recur. That's a good place to be.