feat(tools): add "scheduler" toolset to run instructions on a time or recurring interval#3632
Open
dwin-gharibi wants to merge 8 commits into
Open
feat(tools): add "scheduler" toolset to run instructions on a time or recurring interval#3632dwin-gharibi wants to merge 8 commits into
dwin-gharibi wants to merge 8 commits into
Conversation
…r one-shot and recurring triggers
…ore with recurring rearming
… and runtime recall support
…iring, and lifecycle tests
Contributor
Author
…o fix the lint problems
Contributor
Author
|
Hi @Sayt-0, the linting problems are now fixed. Could you please review the PR when you have a chance? Thanks! |
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.
Closes #3631
Summary
Adds a new built-in toolset,
scheduler, that lets an agent schedule an instruction to run once at a time, after a delay, or on a recurring interval (every:1h, orminutely/hourly/daily/weekly). When a schedule is due, the instruction is injected back into the agent loop via the runtime's recall mechanism and the agent carries out the action with its normal tools.Tools:
create_schedule,list_schedules,cancel_schedule.Motivation
background_jobscan run work now and recall on completion, but nothing lets an agent make something happen later or repeatedly - e.g. "every 15 minutes, check if origin/main moved," or "at 09:00, post the standup summary." The scheduler fills that gap and lets docker-agent drive timed / recurring workflows during a live session.Design - execution model
The scheduler does not execute shell/api itself. When a schedule fires it calls
Runtime.Recall(ctx, <instruction>)and the agent performs the action with its own tools. This was a deliberate choice:Recallexactly as designed ("background work completed → inject a message"), the same primitivebackground_jobsuses;shelltool instead of adding a second, unattended command runner.A deterministic-execution variant (the scheduler runs a shell command itself) is noted as a possible follow-up but is intentionally out of scope here.
Lifecycle: the toolset implements
tools.Startable;Stopcancels the fire loop so no goroutine outlives the session. Schedules live in memory (not persisted across restarts). Scheduling requires host recall support (Runtime.Supports(CapabilityRecall)); otherwisecreate_schedulereturns a clear error.What changed
pkg/tools/builtin/scheduler/schedule.goparseWhen— spec → first fire time + interval.pkg/tools/builtin/scheduler/store.gopopDue(re-arm recurring, skip missed slots) /untilNext. Clock-injected, pure.pkg/tools/builtin/scheduler/scheduler.goToolSet: 3 tools,Recallfiring,Startablefire loop, instructions.pkg/tools/builtin/scheduler/*_test.gopkg/teamloader/toolsets/toolsets.goschedulercreator.pkg/teamloader/toolsets/catalog.goschedulercatalog entry (required by the drift-guard test).docs/configuration/tools/index.mdschedulerto the built-in toolsets table.docs/tools/scheduler/index.mdThe existing catalog drift-guard test (
TestBuiltinToolsetsCatalogMatchesRegistry) forces the catalog entry: registering the type without documenting it fails the build.Example
Testing
go test ./pkg/tools/builtin/scheduler/ ./pkg/teamloader/toolsets/parseWhen: all spec forms + rejections (empty, garbage, pastat:, non-positiveevery:).store: add/list ordering, cancel, one-shot removal, recurring re-arm, missed-slot skipping,untilNextclamping.Recall,Start/Stopclean shutdown.TestBuiltinToolsetsCatalogMatchesRegistrypasses withschedulerin both registry and catalog.All pass;
gofmt -landgo vetclean. (CI runstask lint/task test.)Scope / non-goals