Skip to content

Codify scheduled prompts/skills into committed, reviewable code (cheaper, deterministic cron runs) #2041

Description

@aminghadersohi

Summary

Add an option to codify a schedule's prompt/skill into a committed, reviewable code file in the schedule's worktree branch, so a recurring run that always calls the same sequence of Agor (and other MCP) tools executes deterministically without spending LLM tokens on orchestration.

Goal: make scheduled runs cheaper, more deterministic, and auditable, while keeping an agent fallback for the cases that genuinely need judgment.

Motivation

Today a schedule fires a prompt template that spins up an agent session. When the task is really just plumbing — "call these 5 MCP tools in this order, bind these params" — we pay full model tokens every run and inherit LLM nondeterminism (and occasional flakiness) for work that has no real judgment in it. Over time many schedules drift toward this fixed-sequence shape.

Three benefits from codifying:

  • Cost — stop paying the model every N minutes to re-derive the same tool calls.
  • Determinism — same inputs → same sequence, every run.
  • Auditability — a committed file is diffable, PR-reviewable, and CI-gatable. You know exactly what a cron does instead of trusting the model to reconstruct it each time. Biggest win for anything with write access.

Prior art: deterministic workflow orchestration primitives (e.g. scripted tool pipelines) and "locked-param" skills in other agent harnesses solve the same problem.

Proposed shape

A schedule is backed by either a prompt template (agentic, today) or a codified routine (a committed executable in the branch worktree). The runner picks the mode.

Represent routines as real code, not a new config DSL. A YAML/JSON "tool + params" manifest inevitably grows conditionals, loops, and error handling until it's a bad programming language. Prefer a real committed script (TS/Python) that talks to MCP through a thin Agor-provided SDK (agor.branches.list(), etc.), with the schedule's identity/permissions injected by the runner. Non-Agor MCPs work the same way when the runner holds their creds. This fits the existing model cleanly: branch = worktree = git ref = PR-reviewable.

Generation loop (don't hand-write routines):

  1. Let the schedule run agentically a few times.
  2. Agor already logs the full tool-call trace — reuse it.
  3. Use the model once, offline to compile the trace into a script, lifting variable bits into params.
  4. Commit to the worktree branch → review as a PR.
  5. Flip the schedule from "prompt template" mode to "run this routine" mode.

A "Codify this schedule" action that generates the routine from the last N traces and opens a PR would be the whole UX loop.

Sharp edges / requirements

  • Pure fixed sequences are rare. Most schedules have a branch ("if PR merged do X else ping"), a data-dependent loop, or an error path — so routines need variable capture from tool outputs, conditionals, and error handling (another reason real code beats a manifest).
  • Brittleness. Deterministic scripts break when the environment shifts (new state appears, API shape changes) in ways an agent would adapt to.
  • Fallback-to-agent (self-healing). On error or unexpected output shape, escalate back to an agent turn instead of silently failing a cron.
  • Tool-surface gating. A headless routine running unattended on cron with write MCP access is a different risk class than an agent a human is watching — restrict which tools a routine may call.
  • Hybrid steps. Allow small inline model calls only where judgment is genuinely needed ("is this log anomalous?", "summarize"), while the plumbing stays deterministic.

Recommendation

Ship codify-with-fallback, not pure codify. The design decision that makes or breaks it is fallback-to-agent + tool gating — that's what keeps this from turning cron jobs into silent, brittle failures.


Filed on behalf of @amin (Preset) from a #agor design discussion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions