fix(cron): start scheduler so CRON_SCHEDULE handlers fire#109
Merged
Conversation
The cron wrapper built a robfig/cron scheduler via cronLib.New() but never called Start(). In robfig/cron v3, AddFunc/Schedule only appends entries to an internal slice while the scheduler is not running; jobs are dispatched solely by the goroutine that Start() launches. As a result, CRON_SCHEDULE handlers were registered but never invoked. RUN_INTERVAL handlers were unaffected because they use their own time.NewTicker goroutine, independent of robfig/cron. The existing TestApplyOption_CronSchedule masked this: its fakeCron fires the command immediately on Add(), so it never exercised the real "must be started" contract. Added cron_test.go which uses the real wrapper and an "@every 1s" job to verify a job actually fires. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The Trivy PR scan flagged 45 CRITICAL/HIGH CVEs in openssl/libssl3t64 whose fixes are already in Debian's archive; the build was serving a stale apt layer. Bump APT_CACHE_BUST to invalidate that layer. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
ashiramin
approved these changes
Jun 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A customer reported that the Go SDK's cron-interval handlers don't run. Investigation traced this to the agent server's cron wrapper, not the SDK surface.
server/cron/cron.gobuilt arobfig/cron/v3scheduler withcronLib.New()but never calledStart():In robfig/cron v3,
cron.New()starts withrunning: false.AddFunc→Scheduleonly appends entries to an internal slice while not running — jobs are dispatched solely by the goroutine thatStart()launches:So
CRON_SCHEDULEhandlers were registered but never invoked.RUN_INTERVALhandlers were unaffected because they use their owntime.NewTickergoroutine, independent of robfig/cron — which is why only the cron-schedule path was broken. Because both the Go and Python SDKs talk to this same Go agent server, cron-scheduled handlers were broken for both.Why tests didn't catch it
TestApplyOption_CronScheduleuses afakeCronwhoseAddruns the command immediately (go cmd()), so it never exercised the real "must be started" contract.Fix
Call
c.Start()inNew().Start()is idempotent, and adding/removing entries while running is fully supported (routed through the scheduler's channels).Test plan
server/cron/cron_test.goexercising the real wrapper with an@every 1sjob.FAIL — cron job never fired; scheduler was not started(3s timeout)PASS (0.20s)go test ./...across the agent module is green, including existing cron and handler tests.🤖 Generated with Claude Code