Campaigns
A campaign runs one task in many repositories: the same dependency upgrade, the same CI change, the same file added everywhere. kōjō starts one session per repository, a few at a time, and stops before it can spend more than the bound a person confirmed. Each session is an ordinary session of its repository: its skill, its goal critic, its merge policy and its pull request. The campaign adds the pace, the bound, a pilot that pauses for review, and one page that shows where every repository stands.
A campaign goes through these states:
| Status | Meaning |
|---|---|
pending |
Created. Nothing has run; it waits for someone to confirm its cost bound. |
running |
Starts sessions, at most max_parallel open at a time, within the bound. |
paused |
Starts nothing until someone continues it: after its pilot (paused: pilot), because another session could pass the bound (paused: cost), or because settings/models no longer bounds what a session costs (paused: bound). Sessions already open carry on, except that bound cancels the ones still queued (the cost bound). |
done |
Every repository is over: its session ended, whatever the outcome, or it could not be started. |
cancelled |
Someone cancelled it. Repositories not started never will be. |
Creating, confirming, continuing, retrying and cancelling need the operator role; reading campaigns needs viewer.
Choose the repositories
A campaign takes its repositories from up to three sources, added together:
- A list: repository IDs as
forge/owner/name. - A team: every repository the team owns in
rbac(teams.<name>.repos, see rbac). A team rbac does not define is refused. - A pattern: every enabled repository whose ID matches, such as
github/acme/svc-*. The pattern is Go’spath.Match, so*does not cross a/:github/acme/*is every enabled repository ofacme.
A listed or team repository that is not enabled is skipped, and so is one whose repos entry does not allow the campaign’s skill, when it names one. Skipped repositories are shown with the reason, and the campaign runs in the others. A selection that leaves no repository, or more than 500, is refused.
The repositories are worked out once, when the campaign is created, and sorted by ID. A repository enabled later does not join the campaign; one disabled later is not started, and shows as failed with the reason.
A campaign needs a task, a skill or both. Its title is one line of at most 200 characters; without one it is the task’s first line, or the skill’s name.
Every session gets the campaign’s task as its request text. With a skill, every session runs that skill directly; without one, the orchestrator chooses, as for any request. A campaign may also carry inputs for the skills, as a session does; names starting with KOJO_ are refused.
The cost bound
Creating a campaign runs nothing. The answer lists the repositories, the skipped ones and the most the campaign can cost: the number of repositories times the per-session budget of settings/models. A session stops at its budget, so that is the bound, though a session’s last model call can take it a little past its budget.
The campaign starts once someone confirms a bound at least that large. The estimate is worked out again at that moment, so a budget raised in between is not confirmed by accident. A campaign cannot be confirmed when its cost cannot be bounded: with no per-session budget, or with a model tier that has no price (calls without a price cost 0 and no budget counts them). The campaign stays pending until that is fixed and it is confirmed. A pending campaign, read through the API, MCP or the dashboard, shows the estimate as it is now, so the bound the dashboard offers to start at is the one the confirmation is checked against.
While it runs, a campaign counts what its ended sessions cost and, for each open session, the most it can still cost: the largest of what it cost so far, the per-session budget now, and the budget the session started with (a session keeps the settings it started with, so lowering the budget does not lower what an open session may spend). It starts another session only when that sum plus one more per-session budget fits in the bound. When what it spent reaches the bound, or another session no longer fits and none is open, the campaign pauses at its bound (paused: cost). To go on, continue it with a higher bound, at least what it spent plus one more session.
The bound holds only while settings/models bounds each session. If the per-session budget is removed, or a tier loses its price, while a campaign runs, the campaign pauses (paused: bound) with the reason and starts nothing more. A session that has started keeps the settings it started with and carries on. A session still queued would take today’s settings when it starts, with nothing to stop it, so it is cancelled and its repository goes back to not started: it runs again, as its next attempt, when the campaign continues. The campaign cannot be continued until settings/models bounds a session again.
The pilot and the pace
max_parallel (default 5, 1 to 50) bounds the campaign’s open sessions: queued, running or waiting. When one ends, the next repository starts.
pilot (default 3; 0 for none) is how many repositories run first. Once the pilot’s sessions are all over, the campaign pauses (paused: pilot) so someone can look at their pull requests before the change goes everywhere. Continuing it starts the rest. A pilot as large as the campaign is no pilot.
The campaign moves on when one of its sessions ends and every 30 seconds on every replica. The worker that ran the session does not wait for that: it hands the campaign to the replica’s campaign loop and goes on. Each move holds the campaign’s row; a replica that finds it held leaves the campaign to the holder and looks again 30 seconds later. Each repository’s session has a key of its own, so two replicas never start the same repository twice, and a restart picks up where the campaign was.
Campaign sessions are ordinary sessions for limits: they count against their repository’s and team’s spend and running caps, against the limits of the person who created the campaign, against the skill’s spend limit when the campaign names a skill, against the daily and monthly budgets, and against settings/limits triggers.campaign.max_running. A session a limit holds back stays queued and counts as open in the campaign, so a limit also slows the campaign down.
Operate a campaign
Dashboard
Campaigns lists campaigns, newest first, with their status, how many repositories are over, and what they spent against their bound.
New campaign takes a title, the task, an optional skill, the repositories (ticked, by team and by pattern), the pilot and how many run at once. Creating it opens its page.
A pending campaign’s page shows what it will cost and the button that confirms it, then the repositories it will run in and the ones it skipped.
Once it runs, the page has one row per repository: the status of its newest session, the session, its outcome, its pull request with the pull request’s state (open, merged or closed, as the forge last reported it), what it cost and how many attempts it took. It refreshes while sessions are open.
Retry failed runs again the repositories whose session failed or could not be started, each as a new session within the bound. Cancel campaign stops it: no session starts after that, the open ones are asked to stop, and pull requests already opened stay open. A session that cannot be asked (the database did not answer, say) does not keep the others from being asked: the cancel reports an error (the server log names the session), and cancelling the cancelled campaign again asks its open sessions once more. A session’s page names its campaign.
A campaign paused because its cost is not bounded shows the reason in a banner, with a Continue button that works once settings/models is fixed.
CLI
kojo campaigns does the same from a terminal. create prints the repositories, the skipped ones and the bound, and asks before starting:
kojo campaigns create --title "Logger v3" \
--task "Replace github.com/acme/log v2 with v3. Keep the log format and the field names." \
--match 'github/acme/svc-*' --pilot 3 --max-parallel 4
kojo campaigns show <campaign>
kojo campaigns continue <campaign>
kojo campaigns continue <campaign> --max-cost-usd 120
kojo campaigns retry <campaign>
kojo campaigns cancel <campaign>
MCP and the API
The MCP server has a tool per operation (kojo_campaign_create, kojo_campaign_confirm, kojo_campaigns, kojo_campaign, kojo_campaign_continue, kojo_campaign_retry, kojo_campaign_cancel; see MCP), and the API has the endpoints under /api/v1/campaigns. An agent that creates a campaign gets the estimate back and confirms it with the bound in a second call, so a person can be asked in between.
What the sessions do
Each session runs as a request of the person who created the campaign, with the trust of an operator’s request, so it may change code and open a pull request. Its trigger is campaign. Like a run that person started by hand, it reads and saves their personal memory. The merge policy of its repository applies as for any session: with the default draft_only, every pull request is a draft.
Near its end, above the line that says who requested it, the description of each pull request names the campaign, linked to its page in the dashboard (server.public_url); it is never cut when the description is shortened:
Part of campaign [Logger v3](https://kojo.example.com/campaigns/cmp_01m9…).
When settings/plan asks for a plan before the skill a campaign runs, each session writes its plan and waits. A campaign session has no issue or chat thread to post it to, so approve each plan on its session page, with kojo sessions approve or with MCP kojo_plan_approve. A waiting session counts as open, so unapproved plans hold the campaign’s pace.
Every step is in the audit log: campaign.create, campaign.confirm, campaign.continue, campaign.retry and campaign.cancel by the person who did it, campaign.pause (with its reason: pilot, cost or bound) and campaign.done by kojo.