From a89013c8641203c76c21e2e4a93c291d9e02b611 Mon Sep 17 00:00:00 2001 From: Gabriel Vidal Date: Fri, 27 Nov 2026 10:57:30 +0100 Subject: [PATCH] feat(cron): guest jobs start on Sonnet; the local ones move to it once Inkling 2 Mini runs looped on the same command until they were stopped (Arthur's veille pharma 1fec9543, the mail secretary d5aa1be7/c2a4e62c). Gabriel chose Sonnet as the default for guests' scheduled jobs: - cron/guests.py: DEFAULT_MODEL sonnet; move_local_jobs_to_sonnet() runs once at startup (marker next to the cron store) and moves every guest job still on qwen (or with no model) and a saved 'qwen' policy to Sonnet. The local model stays a choice, with its Sonnet fallback. - users/store.py + schemas: cronLimits.defaultModel defaults to sonnet. - UI: Sonnet first and the fallback value in the guest job editor, their list, Guest defaults and the owner's guest-job form; mock /api/me/cron. - CLI help + scheduled-jobs skill; openapi + generated types re-dumped. Co-Authored-By: Claude Opus 5.5 --- backend/cron/guest_routes.py | 2 +- backend/cron/guests.py | 52 ++++++++++++++++--- backend/schemas/cron.py | 6 +-- backend/schemas/users.py | 4 +- backend/test_guest_cron.py | 49 ++++++++++++++--- backend/users/store.py | 6 +-- cli/ai_agent.py | 2 +- cli/skills/scheduled-jobs/SKILL.md | 8 +-- frontend/openapi.json | 8 +-- .../business/jobs/components/JobEditor.tsx | 6 +-- frontend/src/business/jobs/pages/MyJobs.tsx | 8 +-- .../src/business/settings/pages/CronJobs.tsx | 4 +- .../users/components/GuestDefaults.tsx | 10 ++-- .../business/users/components/GuestJobs.tsx | 2 +- .../src/generated/model/guestCronLimitsOut.ts | 2 +- frontend/src/mock/handlers.ts | 16 ++++++ 16 files changed, 138 insertions(+), 47 deletions(-) diff --git a/backend/cron/guest_routes.py b/backend/cron/guest_routes.py index 0f51d029..97032a33 100644 --- a/backend/cron/guest_routes.py +++ b/backend/cron/guest_routes.py @@ -23,7 +23,7 @@ class GuestCronBody(BaseModel): name: str | None = None schedule: str | None = None prompt: str | None = None - model: str | None = None # "qwen" | "sonnet" + model: str | None = None # "sonnet" | "qwen" project: str | None = None # "" = their own folder email: bool | None = None mailHtml: str | None = None # the mail's HTML from a project file ("" = none) diff --git a/backend/cron/guests.py b/backend/cron/guests.py index 358d8fb1..e05442a1 100644 --- a/backend/cron/guests.py +++ b/backend/cron/guests.py @@ -7,11 +7,13 @@ job differs from an owner's in every way that matters: * **its prompt is in the store** (``prompt``), not in a ``.claude/agents`` file of the lab repo — a guest can't write there; -* **it says what it runs on with one word**, ``model``: ``qwen`` (the - default — the EVOX2's local model, Inkling 2 Mini since 2026-11-23, the pi - harness, $0; the key predates it) or ``sonnet``. A local - job whose box can't take it within ``FALLBACK_WAIT_S`` runs on Sonnet - instead, which then counts toward their budget like any Sonnet run; +* **it says what it runs on with one word**, ``model``: ``sonnet`` (the + default since 2026-11-27, under their budget) or ``qwen`` (the EVOX2's + local model, Inkling 2 Mini since 2026-11-23, the pi harness, $0; the key + predates it — it was the default until its runs looped on one command, see + :func:`move_local_jobs_to_sonnet`). A local job whose box can't take it + within ``FALLBACK_WAIT_S`` runs on Sonnet instead, which then counts toward + their budget like any Sonnet run; * **it always runs lean**, with an allowlist: :data:`BASE_ALLOW` (``web`` — search, news and fetch for a model with no web tools — and ``notify-done``) plus ``allow``, programs only the owner adds to a job @@ -32,6 +34,7 @@ fire at most once an hour (its minute field is a single value). from __future__ import annotations import datetime +import json import logging import os import re @@ -49,8 +52,10 @@ log = logging.getLogger(__name__) # The models a guest job runs on (the UI's two chips). "qwen" is the stored # name of the *local* choice — the EVOX2's default local model, Inkling 2 Mini # since 2026-11-23 (Qwen 3.8 27B before; the key stayed so saved jobs keep it). +# A job starts on Sonnet since 2026-11-27: Inkling looped on the same command +# until the run was stopped (the mail secretary's and Arthur's veille pharma). MODELS = ("qwen", "sonnet") -DEFAULT_MODEL = "qwen" +DEFAULT_MODEL = "sonnet" QWEN_MODEL = os.environ.get("GUEST_JOB_QWEN_MODEL", "inkling-2-mini") # How long a local job waits for the EVOX2 (asleep, or its GPU taken) before # it runs on Sonnet. @@ -785,7 +790,42 @@ def deliver_sweep(deps) -> int: return n +# Written next to the cron store once :func:`move_local_jobs_to_sonnet` ran. +SONNET_MOVE_MARKER = "guest-jobs-on-sonnet.done" + + +def move_local_jobs_to_sonnet(deps) -> list[str]: + """Once (2026-11-27): every guest job still on the local model — ``qwen``, + or no ``model`` (the old default) — moves to Sonnet, and so does the + owner's saved "new jobs start on" policy. Inkling 2 Mini looped on one + command until its runs were stopped; Gabriel chose Sonnet for them all. + A guest (or the owner) may still pick the local model again afterwards: + the marker file keeps this from running twice. The ids moved.""" + store = deps.cron_store + marker = store.path.with_name(SONNET_MOVE_MARKER) + if marker.exists(): + return [] + moved = [] + for job in store.list(): + if is_guest_job(job) and (job.get("model") or "qwen") == "qwen": + store.update_guest(job["id"], {"model": "sonnet"}) + moved.append(job["id"]) + if limits(deps).get("defaultModel") == "qwen": + deps.users.set_defaults({"cronLimits": {"defaultModel": "sonnet"}}) + marker.write_text(json.dumps({"at": datetime.datetime.now().isoformat(timespec="seconds"), + "moved": moved}) + "\n") + if moved: + log.info("guest jobs moved from the local model to Sonnet: %s", ", ".join(moved)) + deps.hub.publish({"type": "cron"}) + return moved + + def start(deps, every_s: float = SWEEP_S) -> None: + try: + move_local_jobs_to_sonnet(deps) + except Exception: + log.exception("moving the guest jobs to Sonnet failed") + def loop(): while True: time.sleep(every_s) diff --git a/backend/schemas/cron.py b/backend/schemas/cron.py index 0514dfd4..ac741e3a 100644 --- a/backend/schemas/cron.py +++ b/backend/schemas/cron.py @@ -117,8 +117,8 @@ class GuestCronJob(Schema): schedule: str enabled: bool prompt: str - # "qwen" (the EVOX2's local model — Inkling 2 Mini —, Sonnet when it - # can't; the key predates Inkling) | "sonnet". + # "sonnet" (the default) | "qwen" (the EVOX2's local model — Inkling 2 + # Mini —, Sonnet when it can't; the key predates Inkling). model: str # The project it runs in (one they hold chat on); None = their own folder. project: Optional[str] = None @@ -139,7 +139,7 @@ class GuestCronJob(Schema): class GuestCronLimits(Schema): maxJobs: int - defaultModel: str = "qwen" + defaultModel: str = "sonnet" class GuestCronJobsResponse(Schema): diff --git a/backend/schemas/users.py b/backend/schemas/users.py index 6e930016..5e0a31c5 100644 --- a/backend/schemas/users.py +++ b/backend/schemas/users.py @@ -589,9 +589,9 @@ class AnimationCurve(Schema): class GuestCronLimitsOut(Schema): """How many scheduled jobs of their own each guest may have, and the model - a new one starts on ("qwen" | "sonnet").""" + a new one starts on ("sonnet" | "qwen").""" maxJobs: int = 5 - defaultModel: str = "qwen" + defaultModel: str = "sonnet" class GuestDefaults(Schema): diff --git a/backend/test_guest_cron.py b/backend/test_guest_cron.py index 138ab2ab..52df93b1 100644 --- a/backend/test_guest_cron.py +++ b/backend/test_guest_cron.py @@ -1,7 +1,8 @@ """A guest's own scheduled jobs (cron/guests.py, cron/guest_routes.py): the REST a guest's page and their runs' `ai-agent cron` use, the limits, how a -firing is pinned (as the guest, lean, confined, on Qwen with a Sonnet -fallback), the owner's view and extras, read-only runs + « Discuter », and +firing is pinned (as the guest, lean, confined, on Sonnet — or on the local +model with a Sonnet fallback), the one-time move of the local jobs to Sonnet, +the owner's view and extras, read-only runs + « Discuter », and the delivery of a run's result. Imports ``main`` against throwaway paths (no startup event → no threads).""" @@ -80,8 +81,9 @@ class GuestCron(unittest.TestCase): self.assertEqual(r.status_code, 200, r.text) j = r.json() self.assertTrue(j["id"].startswith("arthur-")) + # a new job starts on Sonnet (the local model looped — 2026-11-27) self.assertEqual((j["model"], j["project"], j["email"], j["allow"]), - ("qwen", None, False, [])) + ("sonnet", None, False, [])) self.assertIsNotNone(j["nextRun"]) stored = DEPS.cron_store.get(j["id"]) self.assertEqual(stored["owner"], "arthur") @@ -89,11 +91,11 @@ class GuestCron(unittest.TestCase): # the owner hears of it self.assertTrue(any("Arthur scheduled a job" in p["title"] for p in self.pings)) self.assertEqual([x["id"] for x in g.get("/api/me/cron").json()["jobs"]], [j["id"]]) - r = g.put(f"/api/me/cron/{j['id']}", json={"model": "sonnet", "email": True, + r = g.put(f"/api/me/cron/{j['id']}", json={"model": "qwen", "email": True, "enabled": False}, headers=ORIGIN) self.assertEqual(r.status_code, 200, r.text) self.assertEqual((r.json()["model"], r.json()["email"], r.json()["enabled"]), - ("sonnet", True, False)) + ("qwen", True, False)) self.assertIsNone(r.json()["nextRun"]) self.assertEqual(g.delete(f"/api/me/cron/{j['id']}", headers=ORIGIN).status_code, 200) self.assertIsNone(DEPS.cron_store.get(j["id"])) @@ -148,7 +150,7 @@ class GuestCron(unittest.TestCase): # ── firing ─────────────────────────────────────────────────────────────── def test_a_qwen_job_fires_as_the_guest_lean_and_confined(self): calls = self._capture() - job = guests.create(DEPS, guest_from_record(DEPS.users.get("arthur")), dict(JOB)) + job = guests.create(DEPS, guest_from_record(DEPS.users.get("arthur")), {**JOB, "model": "qwen"}) out = guests.fire(DEPS, job) prompt, kw = calls[0] self.assertTrue(prompt.startswith(' dict: # A guest's own scheduled jobs (cron/guests.py): how many each may have, and -# the model a new one starts on (qwen | sonnet). -DEFAULT_CRON_LIMITS = {"maxJobs": 5, "defaultModel": "qwen"} +# the model a new one starts on (sonnet | qwen — sonnet since 2026-11-27). +DEFAULT_CRON_LIMITS = {"maxJobs": 5, "defaultModel": "sonnet"} def clean_cron_limits(raw, base: dict | None = None) -> dict: @@ -406,7 +406,7 @@ def clean_cron_limits(raw, base: dict | None = None) -> dict: pass if raw.get("defaultModel") in ("qwen", "sonnet"): cur["defaultModel"] = raw["defaultModel"] - model = cur["defaultModel"] if cur.get("defaultModel") in ("qwen", "sonnet") else "qwen" + model = cur["defaultModel"] if cur.get("defaultModel") in ("qwen", "sonnet") else "sonnet" return {"maxJobs": int(cur["maxJobs"]), "defaultModel": model} diff --git a/cli/ai_agent.py b/cli/ai_agent.py index 8439002e..98de45c8 100755 --- a/cli/ai_agent.py +++ b/cli/ai_agent.py @@ -1664,7 +1664,7 @@ def build_parser() -> argparse.ArgumentParser: cr.add_argument("--cron", help="add/edit: a 5-field cron expression instead (at most hourly)") cr.add_argument("--prompt", help="add/edit: what the job does each time") cr.add_argument("--model", choices=("qwen", "sonnet"), - help="add/edit: qwen (default: the local model, Inkling 2 Mini — free, Sonnet when the box can't) | sonnet") + help="add/edit: sonnet (default) | qwen (the local model, Inkling 2 Mini — free, Sonnet when the box can't)") cr.add_argument("--project", help="add/edit: run in this project of theirs ('' = their own folder)") cr.add_argument("--name", help="edit: rename it") cr.add_argument("--email", dest="email", action="store_true", default=None, diff --git a/cli/skills/scheduled-jobs/SKILL.md b/cli/skills/scheduled-jobs/SKILL.md index 7b6b7055..048c278e 100644 --- a/cli/skills/scheduled-jobs/SKILL.md +++ b/cli/skills/scheduled-jobs/SKILL.md @@ -36,10 +36,10 @@ ai-agent cron rm JOB `1-5`). `--cron 'M H * * D'` takes a cron expression instead. A job runs **at most once an hour** (a single minute), and each person has a few jobs at most — the hub says so when the limit is reached. -- **Model**: `qwen` (the default — Qwen 3.8 on the lab's own GPU, free; if - the box can't take it within 10 minutes the run goes to Sonnet, which - counts toward their budget) or `sonnet` (Claude, better at long reading and - careful writing; counts toward their budget every time). +- **Model**: `sonnet` (the default — Claude, reliable on long reading and + careful writing; counts toward their budget every time) or `qwen` (the + lab's own local model, Inkling 2 Mini, free but it can loop on a command; if + the box can't take it within 10 minutes the run goes to Sonnet). - **Where**: `--project P` runs it in one of their projects (it can read and write there); without it, in a private folder of its own. - **A designed mail** (`--email` + `--project P`): `--mail-html PATH` (a diff --git a/frontend/openapi.json b/frontend/openapi.json index bc4c3e9a..13449ab3 100644 --- a/frontend/openapi.json +++ b/frontend/openapi.json @@ -23783,7 +23783,7 @@ "defaultModel": { "type": "string", "title": "Defaultmodel", - "default": "qwen" + "default": "sonnet" } }, "type": "object", @@ -23802,12 +23802,12 @@ "defaultModel": { "type": "string", "title": "Defaultmodel", - "default": "qwen" + "default": "sonnet" } }, "type": "object", "title": "GuestCronLimitsOut", - "description": "How many scheduled jobs of their own each guest may have, and the model\na new one starts on (\"qwen\" | \"sonnet\")." + "description": "How many scheduled jobs of their own each guest may have, and the model\na new one starts on (\"sonnet\" | \"qwen\")." }, "GuestCronRunResult": { "properties": { @@ -23860,7 +23860,7 @@ "$ref": "#/components/schemas/GuestCronLimitsOut", "default": { "maxJobs": 5, - "defaultModel": "qwen" + "defaultModel": "sonnet" } } }, diff --git a/frontend/src/business/jobs/components/JobEditor.tsx b/frontend/src/business/jobs/components/JobEditor.tsx index fd0fa3ab..db9f7679 100644 --- a/frontend/src/business/jobs/components/JobEditor.tsx +++ b/frontend/src/business/jobs/components/JobEditor.tsx @@ -121,8 +121,8 @@ function WhenField({ expr, onChange }: { expr: string; onChange: (e: string) => function ModelChoice({ value, onChange }: { value: "qwen" | "sonnet"; onChange: (v: "qwen" | "sonnet") => void }) { const opts = [ - { v: "qwen" as const, label: t("Inkling 2 Mini · local, free"), hint: t("on the host's own GPU; Sonnet takes over when it's busy or asleep") }, { v: "sonnet" as const, label: "Sonnet", hint: t("Claude — better at long reading; counts toward your budget") }, + { v: "qwen" as const, label: t("Inkling 2 Mini · local, free"), hint: t("on the host's own GPU; Sonnet takes over when it's busy or asleep") }, ]; return ( @@ -156,7 +156,7 @@ export function JobEditor({ open, onClose, job, - defaultModel = "qwen", + defaultModel = "sonnet", }: { open: boolean; onClose: () => void; @@ -169,7 +169,7 @@ export function JobEditor({ const [schedule, setSchedule] = useState(job?.schedule ?? "30 7 * * *"); const [prompt, setPrompt] = useState(job?.prompt ?? ""); const [model, setModel] = useState<"qwen" | "sonnet">( - ((job?.model ?? defaultModel) === "sonnet" ? "sonnet" : "qwen"), + ((job?.model ?? defaultModel) === "qwen" ? "qwen" : "sonnet"), ); const [project, setProject] = useState(job?.project ?? ""); const [email, setEmail] = useState(!!job?.email); diff --git a/frontend/src/business/jobs/pages/MyJobs.tsx b/frontend/src/business/jobs/pages/MyJobs.tsx index a41b38bb..5623cbf8 100644 --- a/frontend/src/business/jobs/pages/MyJobs.tsx +++ b/frontend/src/business/jobs/pages/MyJobs.tsx @@ -104,7 +104,7 @@ function JobCard({ job, onEdit }: { job: GuestCronJob; onEdit: () => void }) {
- {job.model === "sonnet" ? "Sonnet" : t("Inkling 2 Mini · free")} + {job.model === "qwen" ? t("Inkling 2 Mini · free") : "Sonnet"} {job.project && {job.project}} {job.email && ( @@ -141,8 +141,8 @@ function JobCard({ job, onEdit }: { job: GuestCronJob; onEdit: () => void }) { /** * Settings → Scheduled jobs (`/settings/jobs`, guests only): prompts that run - * on their own at the times they pick — on Inkling 2 Mini on the host's GPU by - * default, Sonnet when it can't or when they choose it — whose result is + * on their own at the times they pick — on Sonnet by default, or Inkling 2 + * Mini on the host's GPU when they choose it (Sonnet when it can't) — whose result is * pushed (and mailed, if they like) when each run ends (backend * `cron/guests.py`). Their runs can also set one up (`ai-agent cron`). */ @@ -197,7 +197,7 @@ export function MyJobsPage() { open onClose={() => setEditing(null)} job={editing === "new" ? undefined : editing} - defaultModel={data?.limits.defaultModel ?? "qwen"} + defaultModel={data?.limits.defaultModel ?? "sonnet"} /> )} diff --git a/frontend/src/business/settings/pages/CronJobs.tsx b/frontend/src/business/settings/pages/CronJobs.tsx index fea9139c..baa07a61 100644 --- a/frontend/src/business/settings/pages/CronJobs.tsx +++ b/frontend/src/business/settings/pages/CronJobs.tsx @@ -653,13 +653,13 @@ function GuestJobCard({ job, defaultOpen }: { job: CronJob; defaultOpen: boolean
diff --git a/frontend/src/business/users/components/GuestDefaults.tsx b/frontend/src/business/users/components/GuestDefaults.tsx index 9e855fb5..f949ee83 100644 --- a/frontend/src/business/users/components/GuestDefaults.tsx +++ b/frontend/src/business/users/components/GuestDefaults.tsx @@ -182,7 +182,7 @@ function ComputerLimitsPolicy({ saved }: { saved?: ComputerLimits }) { /** Every guest's scheduled jobs (backend cron/guests.py): how many, and the model a new one starts on. */ function CronLimitsPolicy({ saved }: { saved?: { maxJobs?: number; defaultModel?: string } | null }) { const maxSaved = saved?.maxJobs ?? 5; - const modelSaved = saved?.defaultModel === "sonnet" ? "sonnet" : "qwen"; + const modelSaved = saved?.defaultModel === "qwen" ? "qwen" : "sonnet"; const [max, setMax] = useState(String(maxSaved)); const [seed, setSeed] = useState(maxSaved); const [busy, setBusy] = useState(false); @@ -208,13 +208,13 @@ function CronLimitsPolicy({ saved }: { saved?: { maxJobs?: number; defaultModel? } title="Scheduled jobs" - secondLine={`${maxSaved} per guest · at most hourly · new ones on ${modelSaved === "sonnet" ? "Sonnet" : "Inkling 2 Mini"}`} + secondLine={`${maxSaved} per guest · at most hourly · new ones on ${modelSaved === "qwen" ? "Inkling 2 Mini" : "Sonnet"}`} >

Every guest may schedule prompts of their own (their Settings → Scheduled jobs, or by asking a conversation — their runs have the ai-agent CLI, on by default for every guest). They run on the lab as - them, lean and confined, at most once an hour; Qwen jobs fall back on Sonnet when the EVOX2 can't take - them. All of them:{" "} + them, lean and confined, at most once an hour; Inkling 2 Mini jobs fall back on Sonnet when the EVOX2 + can't take them. All of them:{" "} Settings → Cron → Guests @@ -247,8 +247,8 @@ function CronLimitsPolicy({ saved }: { saved?: { maxJobs?: number; defaultModel? onChange={(e) => void save({ defaultModel: e.target.value })} className={cn(SELECT, "w-full")} > - +

diff --git a/frontend/src/business/users/components/GuestJobs.tsx b/frontend/src/business/users/components/GuestJobs.tsx index c3d413f7..a373c59c 100644 --- a/frontend/src/business/users/components/GuestJobs.tsx +++ b/frontend/src/business/users/components/GuestJobs.tsx @@ -24,7 +24,7 @@ export function GuestJobs({ uid }: { uid: string }) { {j.name} - {describe(j.schedule)} · {j.model === "sonnet" ? "Sonnet" : "Inkling 2 Mini"} + {describe(j.schedule)} · {j.model === "qwen" ? "Inkling 2 Mini" : "Sonnet"} {j.enabled ? "" : " · paused"} diff --git a/frontend/src/generated/model/guestCronLimitsOut.ts b/frontend/src/generated/model/guestCronLimitsOut.ts index d3aeb772..aa34dcac 100644 --- a/frontend/src/generated/model/guestCronLimitsOut.ts +++ b/frontend/src/generated/model/guestCronLimitsOut.ts @@ -7,7 +7,7 @@ /** * How many scheduled jobs of their own each guest may have, and the model - * a new one starts on ("qwen" | "sonnet"). + * a new one starts on ("sonnet" | "qwen"). */ export interface GuestCronLimitsOut { maxJobs?: number; diff --git a/frontend/src/mock/handlers.ts b/frontend/src/mock/handlers.ts index 062d2d1d..98500df7 100644 --- a/frontend/src/mock/handlers.ts +++ b/frontend/src/mock/handlers.ts @@ -1848,6 +1848,22 @@ export async function handle(url: URL, init: RequestInit | undefined, request?: return json({ revoked }); } } + // A guest's own scheduled jobs (Settings → Scheduled jobs, backend + // cron/guests.py) — read-only here: one job, and the policy's default model. + if (p === "/api/me/cron" && method === "GET") { + const dm = (guestDefaults as { cronLimits?: { defaultModel?: string } }).cronLimits?.defaultModel; + return json({ + jobs: [ + { + id: "dom-revue-de-presse", owner: "dom", name: "Revue de presse", schedule: "15 8 * * 1-5", + enabled: true, prompt: "Les 5 nouvelles cinéma du jour, en français.", model: "sonnet", + project: null, email: true, mailHtml: "", allow: [], effort: "", + nextRun: "2026-11-30T08:15+01:00", lastStatus: "ok", createdAt: "2026-11-20T09:00:00", runs: [], + }, + ], + limits: { maxJobs: 5, defaultModel: dm === "qwen" ? "qwen" : "sonnet" }, + }); + } if (p === "/api/guest-defaults") { if (method === "PUT") { const patch = await body>(); -- 2.54.0