Skip to content

Create Smart Job Schduler - #28

Merged
ayyshim merged 48 commits into
mainfrom
canopy/create-smart-job-schduler
Nov 21, 2026
Merged

ayyshim merged 48 commits into
mainfrom
canopy/create-smart-job-schduler

Conversation

@ayyshim

@ayyshim ayyshim commented Nov 21, 2026

Copy link
Copy Markdown
Owner

Handover: smart job scheduler, phase 1 (G-30)

What you asked for

You asked us to build the job scheduler planned in G-29. We built phase 1 of that plan:

  • Single run jobs. For example, "check today's logs and report anything odd". Each run starts fresh.
  • Continuous jobs. For example, "write a new episode on this theme every day at 9". Each run remembers what earlier runs did.

Each run goes straight to one staff member. Where the plan left a question open, we used its recommended answer (section 14).

What we built

All of it is on the branch canopy/create-smart-job-schduler: 47 commits and 92 files. No commit has a Claude co-author line.

How it works:

  1. A job is a saved instruction. It has a schedule, an owner and the staff member who does the work.
  2. When a job is due, Canopy starts a run. Every 15 seconds the hub checks for jobs that are due. Each run is an ordinary goal with one task for the assignee, so it shows up on the board and in the usage numbers as usual.
  3. Continuous jobs get their memory. The run's instructions include the summary written so far and one line for each of the last 10 runs. The agent can open older runs if it needs them.
  4. At the end, the agent reports. It says what it did and whether someone should look (ok, needs attention, or nothing to do). A continuous job also sends its new memory.
  5. Memory is saved only if the run succeeds. A failed run leaves memory exactly as it was. Memory is capped at 5,000 characters; a longer one is refused and the agent is told to shorten it.
  6. Job runs skip the handover step. They close on their own, so a daily job doesn't wait for anyone. Normal goals still get a handover, as before.

Safety rules:

  • Two runs of the same job never run at once. If the next due time comes while a run is still going, that time is skipped and the reason is written down.
  • After an outage, missed runs are never replayed in a pile. A job runs once late if it's still within its window; otherwise that time is marked "too late".
  • Pause and resume. Resuming starts from now and doesn't replay anything that was missed while paused.
  • Run now and Test run. Neither moves the schedule. A test run never saves memory.
  • Time limit. A run that goes past its time limit is stopped. If the owner's computer never picked it up, the run is marked "computer off".
  • Token limit. A run that uses more tokens than its per-run limit is stopped and marked "capped".
  • Auto-pause. A job pauses itself after 3 failed runs in a row.
  • Owner's limits. If the owner is over their usage limit, the run is skipped.
  • New "Stopped" status. Goals can now be "Stopped", for runs that were cut off. The board shows them as Stopped instead of Done.

Schedules:

  • You can write a schedule in plain words, like "every weekday at 9:30", "every Monday at 8" or "first of the month at 10". You can also pick it from a list, or type a raw cron line under Advanced.
  • Plain words are read by simple rules, not AI.
  • The schedule follows time zones and handles daylight saving. It was tested with New York and Kathmandu (+05:45).
  • The create screen always shows the schedule as a plain sentence and the next 5 run times.

Screens:

  • Jobs button next to Outputs, opening the Jobs list. Each job shows its type, its schedule in words, the next run, the last result and its status, plus Run now and Pause/Resume buttons.
  • "Create a job", in four steps: What, Who, When, Rules.
  • Job page with three tabs:
    • Runs: every run, with its status, why it was skipped, tokens used, and a link to its goal.
    • Memory: continuous jobs only. You can edit the summary, see and restore earlier versions, reset memory, and read the run log. Editing is locked while a run is going.
    • Settings: edit or delete the job.
  • Board: job runs carry a small "Job" tag.
  • Notifications: a new "Scheduled jobs" type in Discord and account settings. By default you hear about failures, auto-pauses and runs that need attention. A daily check that finds nothing stays quiet.

Where the code is:

Part Where
The plan docs from G-29, copied in unchanged docs/design/job-scheduler*.md
Database tables and queries hub/internal/store/migrations/00030_jobs.sql, 00031_jobs_notify_kind.sql, hub/internal/store/queries/jobs.sql
Schedule reading (cron, plain words, time zones) hub/internal/jobs/schedule/
Timer, run creation, pause, limits hub/internal/jobs/engine.go, control.go, prompt.go
Run finishing, memory, notifications hub/internal/jobs/finish.go, memory.go, notify.go, hub/internal/orch/goals.go
Agent tools (report a run, read memory, read an old run) hub/internal/orch/tools.go, client/internal/tools/tools.go
API and permissions hub/internal/api/jobs.go, hub/internal/authz/jobs.go, shared/openapi.yaml
Screens frontend/src/app/(app)/w/[id]/jobs/

How to check it

  1. Run the tests. Run make infra, then make test. The new tests need the database; without it they quietly skip, so make sure make infra is up.
    • The main one is TestJobsPhase1ExitCheck. It runs both job types three times on a fake clock and checks that run 3 of the continuous job knows what runs 1 and 2 did.
  2. Try it in the app. Run make gen, then make hub and make web, and open http://localhost:8000.
    • Open a workspace and click Jobs, then Create a job.
    • Make a continuous job and type "every day at 9" in the When step. Check that the sentence and the next 5 times look right for your time zone.
    • Click Test run. Then open the job page and check the Runs tab. Check that the Memory tab did not change, because test runs never save memory.
    • Click Run now twice in a row. The second click should be refused while the first run is going.
  3. Look at the screenshots. Trevor's screenshots are attached to T-182: the list, the dialog, the job page, desktop and phone, light and dark.
  4. See the change: git diff main...canopy/create-smart-job-schduler.

What isn't done, and the risks

Not built yet (planned for phase 2, or left out on purpose):

  • Monthly token cap. You can set it, but nothing enforces it yet. Only the per-run cap works.
  • "Let the manager plan each run" mode. A job with no assignee just gives the work to its manager.
  • Limit on runs per computer. The plan suggested at most 2 job runs at once per computer. It wasn't built, so ten jobs due at 9:00 all start at 9:00.
  • Retries, end-of-run file links, and a board filter. Retries after a failure, giving an agent the files from an old run, and a board filter for finished job goals are all phase 2.
  • Prototype. The clickable prototype from G-29 was not built. We went straight to the real feature.

Small rough edges:

  • Time zone default. "Create a job" starts with your browser's time zone, not the organization's. You can change it, and it's always shown on screen.
  • Job tag. The "Job" tag on a board card is a label only. It doesn't link to the job yet.
  • Job page address. It is /w/:id/jobs/job?id=… instead of /w/:id/jobs/<id>, because of how the web app is built.
  • Job tools visible everywhere. The three job tools appear in every agent's tool list. Only job runs are told about them, and Canopy refuses them anywhere else.
  • Notify setting "always". It sends a message for every finished continuous run. A single run job that finds nothing stays quiet even on "always". The plan said "every success".
  • Missed-run rule. The plan didn't say exactly how "skip" and "run once" differ, so Tommy decided:
    • "skip" only runs if the hub picks it up within 1 minute of the due time;
    • "run once" runs late as long as it's inside the job's window (by default 6 hours for continuous jobs and 1 hour for single ones).
  • Not seen on screen. The dotted "Stopped" look on the board is in the code but wasn't captured in a screenshot. Finished goals are hidden by default.

Risks:

  • Runs need the owner's computer on. If the laptop is off, the run is marked "computer off". A job can be set to a shared computer to avoid this.
  • Bad memory carries forward. If an agent saves a wrong fact, later runs build on it. Earlier versions, a copy after each run and the Reset button let you fix it, but someone has to notice.
  • Shared code changed. Goal finishing is used by every goal. The change only applies to goals that belong to a job, and the existing handover tests still pass, but it's worth a careful look.
  • One generated file edited by hand. One line in frontend/src/lib/core-types.ts was added by hand, because the type generator needed the network. make gen should produce the same line. If it doesn't, the board's Job tag will stop showing.

What you need to decide

  1. Merge. Can this branch go to main? It also brings the three G-29 plan docs, which were never merged.
  2. Runs per computer. Do you want the "at most 2 job runs at once per computer" limit before people start using jobs, or can it wait for phase 2?
  3. Missed-run rule. Are you happy with Tommy's choice above? "Skip" runs only within 1 minute of the due time; "run once" runs late within the job's window.
  4. Notify "always". Should "always" also message on every quiet single run job? Today it doesn't.
  5. Phase 2. Should we open the next goal? It would cover the monthly cap, retries, manager-planned runs, the per-computer limit, a board filter, a clickable Job tag and the organization's time zone as the default.

@ayyshim
ayyshim merged commit 8d905d3 into main Nov 21, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant