Who may trigger what

kōjō decides who may trigger what before anything is queued. Every request is marked trusted or untrusted, and that mark follows the session to its end. The rules apply to every kind of surface: code platforms, chat platforms, issue trackers, error trackers and tools.

Rules per trigger

Trigger Trusted when Otherwise
Mention on a forge The author has at least the repository’s trigger_permission on the forge. The request is rejected. Nothing is queued and nothing is posted. The rejection is written to the audit log as request.reject.
Failed check on an open pull request kōjō opened, with follow_up.checks on Whoever asked for the pull request still may: see follow-ups. Nothing is queued; request.reject in the audit log.
Failed check on a person’s pull request with the kojo:commit label, with follow_up.checks on Whoever added the label still has trigger_permission: see commits on a person’s pull request. Nothing is queued; request.reject in the audit log.
Failed check on the head of the default branch, with follow_up.default_branch on Always: the operator’s setting is the trust. The session changes code in its repository and nothing more, and its pull request is always a draft that kōjō never merges. See a red default branch. A fix already open, a stale commit or a fix declined in the last day starts nothing; request.reject in the audit log.
Automatic trigger (issue_opened, pr_opened, pr_updated, check_failed) The user who caused the event has at least trigger_permission. The configured skill still runs, as an untrusted session.
Push to the default branch Not applicable. It starts no session. Pushes to other branches are ignored.
Chat DM or mention (Slack, Mattermost, Discord, Microsoft Teams) The sender has the operator or admin role in kōjō. The session runs untrusted.
Ticket assigned to kōjō, labelled for it, or a comment that mentions it (Linear, Jira, Asana) The person has the operator or admin role in kōjō, looked up by an email the tracker’s adapter vouches for: on Linear the address Linear reports for the user, on Jira and Asana only the one users in kojo.yaml maps the account to. A ticket must also map to exactly one enabled repository. The session runs untrusted. A ticket that maps to no repository or to several starts nothing, and kōjō says so on the ticket.
Production alert from Sentry or Datadog The alert maps to exactly one enabled repository whose alerts entry has mode: fix (the default). Its pull request is always a draft that kōjō never merges, whatever the merge policy: whoever can make the application fail chooses the error’s message. With mode: report, the session runs untrusted. An alert that maps to no repository, or several, starts nothing and is written to the audit log as request.reject. See Sentry and Datadog.
Approval button in chat The user has the operator or admin role. The click changes nothing and is written to the audit log.
kojo run, kojo_run, dashboard Always. The API only lets a token or user with the operator role or higher start a session. A lower role gets 403.
Schedule Always. Schedules are created by operators, or by maintainers in git. Not applicable.

trigger_permission is part of the merge policy. It is read, triage, write, maintain or admin, and defaults to write. A repository’s .factory/factory.yaml cannot change it: a value there is ignored and the organization’s applies.

On Forgejo, Gitea and Bitbucket, kōjō can only read a user’s permission when the bot is an administrator of the repository. Without that, the lookup fails and no mention on that repository can be authorized. kojo doctor reports it per enabled repository as trigger permissions <repo>.

What an untrusted session may do

An untrusted session is answered, but it cannot change code:

  • Only skills that cannot change the workspace are available to the orchestrator. A skill counts as such when its goals set no_changes, or when it has no tool that writes.
  • If the skill that was asked for by name, or configured for an automatic trigger, can change code, the session fails with a message that says so.
  • No pull request is opened.
  • Team memory is read-only.
  • It cannot propose a schedule.

Trust decides what a session may do. It does not make the text of an issue or comment into instructions: that text is always treated as data. See Security.

Talking to a session at work

While a session is queued or running, people can correct its course without cancelling it and asking again. What they write goes to the session, instead of starting another one, in these cases:

Where it is written Goes to the session when
A mention of kōjō on a forge It is on the issue or pull request the session is about, and its author has the repository’s trigger_permission.
A comment that mentions kōjō on an issue tracker It is on the ticket the session came from, and its author has the operator or admin role, looked up as for a ticket.
A message to kōjō in chat It is in the session’s thread, and its sender has the operator or admin role. In a channel the message mentions kōjō, as every message to kōjō does. On Discord, which has no threads, the session’s thread is a reply to the message that started it, or to one of kōjō’s messages that answer it. A Teams personal or group chat has no threads, so there every message is a request of its own.
The dashboard, kojo sessions message, POST /api/v1/sessions/{id}/messages, kojo_session_message Always. These need the operator role.

A session takes messages while it is queued or running and still has model steps ahead of it, and when it was asked for by someone trusted. It takes none, and a mention or a chat message is a request of its own as before, when:

  • It is waiting for an approval or for a pull request’s checks, or is publishing its result. Its work is done, so no model would read the message, and an approval may wait for days: a new request is not held up behind it. A session waiting for the go-ahead on its plan is the exception: see Answering a plan.
  • It is read-only, because it answers someone who may not change code. A maintainer who writes there usually wants something that session cannot do, so the maintainer’s request starts a session of its own.
  • It is a dry run (a skill test or an eval), a feedback session or a skill proposal: these measure or learn, and nobody steers them.
  • It is over, or being cancelled.

Anyone else who writes there gets what they got before: an outsider’s mention is rejected, with nothing posted and a request.reject entry in the audit log; a chat message or a ticket comment from someone without the operator role is a read-only request of its own. None of them reaches the session.

What the session does with a message

At its next model call, the agent at work reads the messages that came in since its last one: the subagent running at that moment, or the orchestrator between subagents. The orchestrator also reads, at its next call, the messages a subagent read while it worked, marked as such. A subagent that starts later gets its task from the orchestrator, which has read them.

Each message reaches the model with who sent it, from where and when, and its text inside the same fence as the request’s own text: it is data, not instructions. It is framed as guidance from a maintainer that cannot change a skill’s goals, acceptance criteria, constraints, tools or limits. The goal critic is not given the messages and judges the work against the skill’s goals, and the session stays as trusted as its request was.

Each message is read once. Messages are kept in Postgres, so the worker that reads one may run on another replica. The session’s checkpoint holds a message before it is marked read, so a session resumed after a restart neither loses one nor reads it twice.

Acknowledgement, replay and unread messages

A message that reaches a session is answered where it was written: a comment on the issue or pull request, or a reply in the chat thread, that names the session, says that its next step reads the message, and says how to cancel. A message sent from the dashboard, the API, MCP or the CLI is answered by the API. Every message is written to the audit log as session.message. When a model reads it, the replay records a message step, under the subagent that read it.

A message that no model read before the session’s work ended is marked unread, and when it was written on a forge or in chat its author is told there. The session page in the dashboard and GET /api/v1/sessions/{id}/messages show every message with its state: waiting to be read, read (by the orchestrator or by which subagent, and when), or unread.

Limits

A message has at most 4000 characters, and a session takes at most 20 messages, read or not. A longer message, an empty one, or one past the twentieth is not passed on: its author is told why where they wrote it, or gets 400 from the API, and the refusal is audited as request.reject. To change course further than that, cancel the session and start a new one.

Answering a plan

A session that waits for the go-ahead on its plan takes messages from the same people, in the same places. A message whose whole text, besides mentions of the bot, is the word go (for example @kojo go) approves the plan and the work starts. Any other message asks for a revised plan: it is stored as a message, the session writes and posts a revised plan, and the message is guidance for the work afterwards. After settings/plan.max_revisions revisions (default 3), one more request declines the plan, and the session ends without changing anything. Chat also has Approve and Deny buttons; the dashboard, kojo sessions approve and kojo sessions decline decide too.

An outsider’s @kojo go is rejected like any mention of theirs: it approves nothing, and the plan keeps waiting.

Cancelling

A message never stops a session, whatever it says: kōjō does not take “stop” or “cancel” in a message as a request to cancel. The only word kōjō acts on is go, alone, to a session waiting on its plan. Cancel a session explicitly: with the Cancel button on its page in the dashboard, kojo sessions cancel <session>, POST /api/v1/sessions/{id}/cancel or kojo_cancel. The worker stops at its next step.

Follow-ups

A pull request kōjō opened is continued, not stacked on. kōjō knows its own pull requests from its store, which records each one it opens, never from the branch name. While one of them is open:

  • A mention from someone with trigger_permission starts a follow-up: a session that works on the pull request’s branch at its current head, commits people pushed included, and adds a commit to the same branch. No pull request is opened. On a person’s pull request, a mention by its author, or by anyone once someone with trigger_permission added the kojo:commit label, commits to that pull request’s branch when kōjō may write there; any other mention opens a pull request of kōjō’s own on top of it, as before, and when the author or the label asked, kōjō says on the pull request why it did not commit to the branch (see commits on a person’s pull request).
  • A failed check starts a follow-up only where the repository opts in with follow_up.checks (below). Without it, the event goes the way of auto.check_failed, as on any pull request. A failed check on a person’s pull request that carries the label starts a round on its branch the same way; one on the default branch’s head can start a draft fix: both are in Fixing red CI.
  • Review comments and reviews without a mention stay what they were: material for lessons. Nothing is pushed that nobody asked for.

A mention while a session is working on the pull request and takes messages is a message to that session. When a session on the pull request is open but no longer listens (it waits for an approval or is publishing), the mention is answered with that, and nothing is queued: mention kōjō again once that session is over.

Trust

A follow-up from a mention runs with the trust of the mention’s author, which intake has just checked: at least trigger_permission.

A follow-up from a failed check is an event nobody asked for. It borrows the trust of whoever asked for the pull request, read again when the check fails:

  • An account on the same forge (a mention, an issue, an automatic trigger, an on_merge follow-up) must still have the repository’s trigger_permission.
  • A person who asked in chat, the dashboard, the API, MCP or the CLI must still have the operator role in the rbac object, by email. A role a chat surface vouched for at the time cannot be read again and does not count.
  • A schedule, an API token without an email, or an account on another forge cannot be checked again: such a pull request gets no follow-up from a check.

When the trust cannot be borrowed, nothing runs: an untrusted follow-up could not change code, and a comment about a check nobody asked about would only be noise. The session records the person it borrowed from as its requester.

A check is followed up only when it is about the pull request’s current head (a check of an earlier commit is left to the later commit’s checks), at most once per commit however many of its checks fail, and not while any session on the pull request is open. It is matched to the pull request by the event’s pull request number, or by its branch among the open pull requests kōjō recorded. When the repository sets auto.check_failed, the follow-up runs that skill, the first one when it lists several; otherwise the orchestrator chooses.

Rounds

repos:
  github/acme/api:
    enabled: true
    follow_up:
      checks: true      # a failed check on kōjō's pull request starts a follow-up
      max_rounds: 3     # follow-ups per pull request; 0 or unset is 3, at most 20

In the dashboard, the same two settings are under Follow-ups and failed checks of a repository in Settings, Repositories, next to the label and the red default branch of Fixing red CI.

max_rounds caps the follow-ups of one pull request, counted across sessions in the store: every follow-up session of the pull request counts, whatever it ended with, except one refused because the rounds were used up. The last round’s comment says it was the last. After it, a mention is answered on the pull request that kōjō makes no more changes there, and a failed check is ignored, both written to the audit log as request.reject. When two follow-ups were queued for the last round at once, the later one finds it taken when it starts, says so, and ends with the outcome round_limit.

What a follow-up sees

Its agents are told which pull request they continue, its round, and what started it; a failed check’s name and what the forge reported with it are in the request. Every subagent of a follow-up gets two read-only tools on top of its skill’s: get_review_comments reads the pull request’s review (comments on lines of the diff, with the file, line and diff hunk, and the text of each review with its verdict), and get_check_runs reads the checks of the commit the session started from, with their output where the forge keeps it (see the tool catalog for their bounds, and each forge’s page for what it keeps). What they return is data, like every forge text.

How the round is published, and how the merge policy decides on the whole pull request, is in Merge policy. The session page in the dashboard lists the rounds of the pull request.

Automatic triggers per repository

By default kōjō acts on a repository only when it is mentioned. To run a skill on an event without a mention, set auto on the repository. The keys are the event kinds. The values are a skill name or a list of skill names. Each skill starts its own session:

repos:
  github/acme/api:
    enabled: true
    auto:
      issue_opened: triage
      pr_opened: [review-pr, docs-sync]
      pr_updated: review-pr
      check_failed: fix-bug

This is the repos object of the runtime configuration. Change it in the dashboard, or with kojo config export and kojo config apply. See Config as code.

Event kind Fires when
issue_opened A new issue is opened and its body does not mention kōjō.
pr_opened A pull request is opened, reopened or marked ready, and it is not a mention.
pr_updated New commits arrive on a pull request.
check_failed A check run, check suite, pipeline or commit status fails.

The keys are validated when the object is saved: any other key is refused, and so is an event with an empty list, an empty skill name or a skill named twice. The skill names themselves are not checked against the skills that exist.

An event with no skill configured is ignored. An issue or pull request whose body mentions kōjō is handled as a mention instead, under the mention rule. When a list names several skills, a redelivered event starts none of them again.

New commits that kōjō’s own account pushed to a pull request start nothing, so pr_updated: docs-sync cannot loop on the commit docs-sync itself pushed, and such a push does not count as a person’s edit of the pull request.

A skill that changes code, such as fix-bug on check_failed, only runs when the user the forge names as the cause of the event has trigger_permission. When a failed check is attributed to a bot or to a user without that permission, the session fails instead of writing. A failed check on an open pull request kōjō opened, in a repository with follow_up.checks on, is a follow-up instead, whoever the forge names as its cause. So is one on a person’s pull request that carries the kojo:commit label, and a failed check on the head of the default branch, with follow_up.default_branch on, starts a draft fix instead of auto.check_failed: see Fixing red CI.

Two more keys on a repository narrow what it may do: skills limits the repository to the listed skills (empty means all), and allow_auto_merge lets it use the auto_merge policy. follow_up says how kōjō continues its own pull requests (see follow-ups), a person’s pull request when asked, and a red default branch (see Fixing red CI).

How forge permissions map

kōjō asks the forge for the author’s access level and maps it onto one scale, weakest first: none, read, triage, write, maintain, admin.

Level GitHub GitLab Forgejo, Gitea Bitbucket
admin Admin Owner (50) Owner, admin Admin
maintain Maintain Maintainer (40) n/a n/a
write Write Developer (30) Write Write
triage Triage Access level 15 to 29 n/a n/a
read Read Guest (10), or anyone on a public project Read Read
none Not a collaborator Not a member of a private project, or an inactive member Not a collaborator No permission of their own or through a group

On GitHub a custom repository role falls back to the base permission GitHub reports for it.

Roles in kōjō

The chat surfaces, the CLI, MCP and the dashboard use kōjō’s own roles, weakest first: viewer, skill:edit, operator, admin. People get roles in the dashboard under Settings → Access, directly or through a team, and a chat surface matches a person to their roles by the email it reports for them. Discord gives a bot no email, so there the roles come from the person’s server roles, mapped in kojo.yaml. API tokens carry the role set in kojo.yaml.

Action Role needed
List and read sessions, steps and skills viewer
Start a session, send it a message, cancel it operator
Talk to a session at work from a chat surface operator
Trigger code changes from a chat surface operator
Decide an approval in a chat surface operator

A person who signs in with OIDC and is not named in the access settings gets the viewer role only when server.auth.oidc.allowed_domains is set. Without it they get no role and are refused with 403.

Managing kōjō covers roles in full.

Scroll to move. + - zoom, 0 fit, Esc close.100%