Self-Hosted Coding Agent Runner for Scheduled Agents
A self-hosted coding agent runner is a small process on a machine you control that waits for agent runs to be requested (by a schedule, a webhook or a person), starts each agent with its own short-lived key and task, and stops them when the run is stopped or its budget is spent. The coordination (queue, schedules, permissions, budgets, results) can live in a service; the agents, your code and your model subscriptions stay on your hardware. This guide explains why teams split it that way, what you give up, and how to set it up with forkit daemon.
Why run agents yourself
Hosted background agents are convenient. Upstash describes the model plainly: "A background agent runs on cloud infrastructure and keeps going after you disconnect." Factory's Automations, generally available since September 2026, can run "locally, on a connected machine you provide, or on a Factory-managed Droid Computer". Cognition's scheduled Devins set up recurring sessions such as weekly feature-flag cleanup and daily QA.
Teams still choose their own machines for a few reasons:
- The code stays put. No checkout leaves your network, which matters for some contracts and audits.
- Your subscriptions. Agents run on the plans and API keys you already pay for, with any model or vendor.
- Your sandbox. Containers, VMs or a spare Mac mini, configured the way your security team approved.
- Your tools. Internal package registries, private networks and test databases are already reachable.
What you give up:
- Upkeep. Someone keeps the machine patched, the agent CLIs updated and the disk from filling.
- Elastic scale. A box runs as many agents as it has memory and CPU for.
- Availability. If the machine sleeps, the runs wait.
If none of the reasons above apply to you, a hosted agent is less work. The rest of this guide is for when they do.
The split: a service that coordinates, a runner you own
| Job | Where |
|---|---|
| Queue of requested runs, schedules, webhook addresses | Forkit |
| Keys per agent, budgets, tool-call caps, stopping | Forkit |
| Permission requests, rules, the person who answers | Forkit |
| Claims, messages, merge check, results per run | Forkit |
| Starting the agent processes, the checkout, the model calls | Your runner |
Forkit never runs an agent. The runner is a command you start, and it can only do what the keys it receives allow.
Step 1: a factory
A factory is a saved fan-out: a prompt template, how many agents, a repository, budgets in dollars and tool calls, a time limit, whether it is a shadow run, and optionally a schedule.
forkit factory create --name deps --prompt-file upgrade-prompt.md \
--agents 4 --max-cost 8 --max-tool-calls 400 --push \
--schedule "daily 06:30"
Note the name clash: Factory is also a company. Here "factory" means Forkit's feature.
Schedules
A schedule is one of every 15m, hourly, daily 06:30 or weekly mon 09:00, in UTC. Forkit's once-a-minute sweep asks for a run when a slot comes, once per slot. A missed slot is run once, and at most 25 runs wait per factory, so a runner that was off for a weekend comes back to a bounded queue. Schedules need Pro or Team; the Free plan allows one factory without a schedule.
Runs can also be asked for through the factory's webhook address or the API, and they queue the same way (at most 25 waiting per factory). From a GitHub or Linear issue to a run of agents covers the webhook.
Step 2: prepare the machine for unattended agents
Nobody is at this machine's terminal, so set the agents up to never wait for one:
npx forkit-cli init --sandbox
This installs Claude Code's hooks with no sign-in, no key and no questions, and sets on_timeout: deny: a permission request nobody answers in time is recorded as denied rather than left waiting at a prompt no one will see. For a fan-out's agents, that is the rule anyway: with no terminal, silence is a denial. Production, secrets and money still reach a person, who can answer from the web inbox, the Mac app or forkit watch.
For Cursor, Gemini CLI or Copilot, add --project --agents cursor,gemini,copilot to write their hook files into the repository. That support is new (26 Nov 2026) and has been tested with each agent's documented payloads, not yet run against the real agents. Agents with no hooks can be started under forkit run --, which watches the checkout instead.
Step 3: start the self-hosted coding agent runner
forkit daemon --exec "/opt/agents/run-claude.sh" --repo-from /srv/app
forkit daemon --exec CMD is the same as forkit factory work --all: it looks at every factory of the workspace in turn and starts a run as soon as one waits. For each run it:
- Starts the run, which creates the fan-out and returns each agent's key, prompt and title, once.
- Pushes the repository from
--repo-fromwhen the factory uses a pushed repository. - Runs your command once per agent, through the shell, in an empty folder, with
FORKIT_API_KEY,FORKIT_URL,FORKIT_PROMPT,FORKIT_TITLEandFORKIT_AGENTset. - Finishes the run, which stops its agents and keeps its cost.
A minimal agent script:
#!/bin/sh
# /opt/agents/run-claude.sh
set -e
forkit repo clone work && cd work
claude -p "$FORKIT_PROMPT"
Use the script's full path. Each agent starts in its own empty folder, so a relative ./agent.sh is not found. This came up while recording Forkit's model-comparison demo on staging (21 Nov 2026), where twelve Claude Code agents ran from one factory run in 63 seconds for about $1.25.
To serve only one factory, use forkit factory work NAME --exec CMD; add --once to take one run and exit, which suits a cron job or a CI step better than a long-running process. Run the daemon under your init system (systemd, launchd) so it restarts after a reboot.
Step 4: stopping
A runner on your machine has to stop when the run is stopped elsewhere. Forkit stops a fan-out's agents in five ways:
- the starting agent's person or a workspace owner presses Stop on the fan-out page;
- the agent that started it stops it;
- its time limit ends (1 hour by default, at most 24);
- its estimated cost reaches
--max-cost(a warning at 80%); - its agents reach
--max-tool-calls(counted in steps, so it can overshoot by a few).
A stopped key still resolves, but every request is answered with a stop and a reason; the agent's hook tells it not to continue and refuses the tool in hand. An agent under forkit run is killed when its fan-out stops. Cost figures are estimates from list prices; agents that report no usage are not seen by the dollar budget, which is why the tool-call cap exists. How to stop a runaway agent covers the details.
Step 5: judge the runs
A schedule that nobody looks at drifts. Mark runs good or bad (forkit factory verdict, or from a person's app), and forkit factory show NAME gives the number of runs, the pass rate among judged runs, cost in all and per run, and seconds per run. A factory whose pass rate falls is telling you the prompt or the repository changed.
Before a new schedule goes live, run it once as a shadow run (--shadow): agents work as usual, but anything that would have reached a person is refused and listed, grouped, with the rule that would allow it.
Where this fits
| You want | Use |
|---|---|
| Nightly dependency upgrades, weekly clean-ups | A scheduled factory and a runner |
| Agents on every pull request | Your CI (background agents in CI) |
| No machines to look after | A hosted background agent |
| A mix | Hosted for some factories, a runner for the code that must stay in |
Cloud agents vs local agents compares the two sides, and scheduled factory dependency upgrades is a worked example.
Checklist
- A factory with a budget, a tool-call cap and a time limit.
- A schedule in UTC (Pro or Team).
-
forkit init --sandboxon the runner machine. -
forkit daemon --execwith a full path, under systemd or launchd. - One shadow run before the schedule goes live.
- Verdicts recorded,
forkit factory showchecked weekly.
Forkit has a Free plan; Pro is $20 a month and Team $40 per seat a month, billed per person, never per agent. More at forkit-mcp.com.
Sources
Read on 27 Nov 2026:
- Upstash, "How to Build a Background Coding Agent: 7 Infrastructure Layers", 7 Aug 2026: https://upstash.com/blog/how-background-coding-agents-keep-working
- Cognition, "Devin can now Schedule Devins", 20 Mar 2026: https://cognition.com/blog/devin-can-now-schedule-devins
- Factory, "Automate the work that keeps coming back", 30 Sep 2026: https://factory.com/news/automations