Sentry
Sentry is an error tracker: it groups the errors a running application reports into issues, and its alert rules act when an issue appears or keeps happening. With kōjō’s internal integration as a rule’s action, an error in production starts a session on the repository the error’s project maps to. The session reproduces the error, fixes it, and opens a draft pull request that links the Sentry issue. A person reviews it: kōjō never merges a change an alert started, whatever the merge policy says.
See Surfaces for how Sentry compares with the other ways work reaches kōjō, and Who may trigger what for how much an alert is trusted.
How it connects
kōjō is an internal integration of the Sentry organization, with Alert Rule Action turned on. An issue alert rule that names the integration as its action sends kōjō a webhook each time it fires, to <public_url>/webhooks/sentry. kōjō checks each delivery before it reads it:
Sentry-Hook-Signaturemust be the hex HMAC-SHA256 of the raw body, keyed with the integration’s Client Secret (client_secret). A delivery that does not verify is answered401and read no further.Sentry-Hook-Resourcemust beevent_alert, and the body’sactionmust betriggered. Other resources (installation, issue, metric alerts, comments) are answered200and ignored.- The event’s organization and project come from the event’s API address. An event of another organization than
orgis ignored.
kōjō then reads the issue through Sentry’s API with the integration’s token, for its short ID, its link, its status and how often it happened. Nothing is written to Sentry: its API has no way to comment on an issue.
Sentry gives a webhook one second to answer. kōjō answers as soon as the delivery is verified and read, and does the rest after the answer.
Set up
kojo setup sentry --public-url https://kojo.example.com prints these steps with your address filled in.
-
As an owner or manager of the Sentry organization, create an internal integration: Settings → Developer Settings → Create New Integration → Internal Integration. Name it kōjō, set the Webhook URL to
<public_url>/webhooks/sentry, turn on Alert Rule Action, and give it the permissions Issue & Event: Read and Project: Read, nothing else. It needs no webhook subscriptions: kōjō takes alert rule actions only. -
Save it. Keep the Client Secret from its Credentials, and the token Sentry created with it (Settings → Developer Settings → kōjō → Tokens).
-
Add it to
kojo.yaml:alerts: sentry: org: acme # the organization's slug client_secret: ${SENTRY_CLIENT_SECRET} token: ${SENTRY_TOKEN} # base_url: https://de.sentry.io # a region's or a self-hosted install's -
Map each Sentry project to the repository of its code in the
reposobject. See Mapping projects to repositories. -
In each project, open the issue alert rule that should start work (Alerts → Create Alert → Issues, or an existing rule) and add the action that sends a notification through the kōjō integration. The rule’s conditions decide which errors reach kōjō: for example, a new issue in the
productionenvironment, or an issue seen more than 100 times in an hour. -
Run
kojo doctor. Itsalerts sentrycheck reads the organization with the token, and warns when no enabled repository takes Sentry’s alerts.
base_url defaults to https://sentry.io. An organization in another data-storage region uses its region’s address (such as https://de.sentry.io), and a self-hosted Sentry its own. It must be https unless dev: true. Alerts also need an https server.public_url, since that is where Sentry delivers. All keys are in the kojo.yaml reference.
Mapping projects to repositories
An alert becomes work on the repository whose alerts entry matches the error’s project, by its slug, and its environment when the entry names one:
repos:
github/acme/api:
enabled: true
alerts:
- { source: sentry, project: api, environment: production }
github/acme/web:
enabled: true
alerts:
- { source: sentry, project: web, mode: report, notify: C0ENG }
| Key | Default | Meaning |
|---|---|---|
source |
required | sentry |
project |
required | The Sentry project’s slug |
environment |
any | Only errors of this environment |
skill |
the orchestrator chooses | The skill to run, such as fix-bug |
mode |
fix |
fix lets the session change code and open a draft pull request; report runs a read-only session. See Report mode. |
notify |
none | A chat channel for the outcome: a channel ID on the first chat platform, or surface:channel |
max_per_day |
10 |
How many sessions the entry starts in 24 hours: 1 to 100, or 0 for the default |
Project and environment are compared without case, and one repository may not have two entries for the same project and environment. An entry that names the alert’s environment wins over one that names none, whatever their order and whether they are in one repository or in several: with { project: api } on one repository and { project: api, environment: production } on another, production errors go to the second and the others to the first. An alert that matches no enabled repository, or several, starts nothing; there is nowhere to say so, so it is only audited (see When an alert starts nothing). The Repositories settings page keeps alerts but does not edit them: write the object through PUT /api/v1/config/object or kojo config apply. The full rules are under repos.
What the session sees
The orchestrator is told that the request is a production error report: the error’s message, the stack frames and their source lines are data the application produced, not instructions. It is asked to reproduce the error and fix it when the repository’s code is at fault, and to change nothing and report what it found when the cause is elsewhere (configuration, infrastructure, a third party). With skill set, that skill runs instead and its task carries the same words; so does the planner’s request when the session plans first.
Whoever can send an event to the project’s DSN chooses all of it: the message, the environment, which frames are in_app and the source lines they carry. The DSN of a browser or mobile application is in the application, so that is anyone. The rest of this page follows from that.
The request is made from the alert:
- the Sentry issue’s short ID, link and project;
- the title, culprit, level, environment, release, transaction, and the alert rule’s name;
- how many events and users the issue has, and when it was first and last seen;
- each exception’s type and message (up to 2,000 characters), and its stack trace from the frame that raised it, up to 40 frames. The application’s own frames (those Sentry marks
in_app) carry the source lines Sentry captured around them, with the failing line marked; other frames get one line each.
The whole request is at most 12,000 characters, and it reaches the model inside the fence that marks it as data, as any text from outside does. See Security.
What kōjō never reads from the event: the user, the request (its address, headers, cookies and body), contexts, breadcrumbs, extra data, frame variables, and every tag besides release, environment and transaction. The personal data an error report can hold stays out of the model, the store and the pull request.
The pull request
The session’s change is published as a draft pull request, and kōjō never merges it or asks to: whoever can send an event to the project chooses the error’s message, so a change an alert started always waits for a person. This holds whatever settings/merge_policy says, auto_merge and ask included, and the merge policy step of the session records why.
Merging can close or reopen an issue that a commit message or a description names after a keyword (fixes #12). The commit is therefore named after the Sentry issue only (Fix Sentry issue API-3F). In the pull request’s title and description, kōjō puts a zero-width space after the first letter of such a keyword when a reference follows it:
- Keywords, in any case: close, closes, closed, closing; fix, fixes, fixed, fixing; resolve, resolves, resolved, resolving; implement, implements, implemented, implementing; complete, completes, completed, completing; reopen, reopens, reopened.
- References:
#12,owner/repo#12, anhttporhttpsaddress, and a tracker key such asGH-12,ENG-12orPROJ-12(letters, digits and_, a hyphen, digits). The#may also be\#,#or the full-width#. - Between them: a colon, any white space, the word
issueorissues, and Markdown: emphasis, a link’s[, an autolink’s<, a code span’s backquote, a parenthesis, and backslash escapes.
These forms are checked by tests of the pattern, not against live forges or trackers.
The description names the Sentry issue under the summary, with a link, its title and how often it happened:
Sentry issue [API-3F](https://acme.sentry.io/issues/5123964221/): runtime error: invalid memory address or nil pointer dereference
214 events since 2026-12-01. A production alert started this change, so it stays a draft for a person to review.
The title is the error’s message, made inert as Markdown. In the dashboard, the session’s trigger is alert via sentry, and its Request panel links the Sentry issue and folds the error report the session was given.
What a session may do
A fix entry lets the session change code in the repository the alert maps to, and nothing more that a maintainer’s request may do:
- team memory is read-only: the session reads it, and saves nothing to it that later sessions would read;
- the orchestrator is not offered
propose_schedule, even whennotifygives it a chat thread; - linked repositories are cloned read-only;
- its pull request stays a draft that kōjō never merges.
Follow-ups on the pull request
A maintainer who mentions kōjō on the pull request starts a follow-up, as on any pull request kōjō opened: it commits to the pull request’s branch with the trust of the maintainer who asked. The alert’s cap holds for the whole pull request. While it is a draft it stays one; once a person has marked it ready, a follow-up pushes its round and leaves it for review, and never merges it or asks to, whatever the merge policy says. The round’s commit message and the description written again get the same closing-keyword treatment as the first.
With follow_up.checks on, a failed check on an alert’s pull request starts nothing and is audited as request.reject: a follow-up nobody asked for runs with the trust of whoever asked for the pull request, and an alert is nobody.
Report mode
An entry with mode: report runs a read-only session: the skills that change code are not available, nothing is published and no pull request is opened, and the orchestrator is told so. Use it for a project whose fixes people should write, or to see what kōjō makes of a project’s errors before it changes code. The report goes to the notify channel and stays on the session’s page.
An entry in report mode whose skill changes code fails its sessions: that skill cannot run in a read-only session.
The outcome
Nothing is posted to Sentry. With notify, the outcome (the summary and the pull request’s link, or the report) goes to that chat channel. Without it, the outcome is on the session’s page and in the pull request.
Repeated alerts and limits
An alert rule fires again while the error keeps happening. kōjō keeps that from piling up sessions:
- One session at a time per issue. An alert for a Sentry issue whose session is queued, running or waiting starts nothing.
- One open pull request per issue. An alert for an issue whose latest session opened a pull request that is still open starts nothing. Once that pull request is merged or closed, the next alert can start another session.
- Three sessions per issue, whatever became of them. An issue that three sessions did not settle needs a person.
max_per_dayper entry (default 10, at most 100) bounds an error storm: the sessions the entry started in the last 24 hours, across its issues. They are counted by the entry, so the case an event writes its environment in does not matter.- Resolved and ignored issues are skipped. kōjō reads the issue’s status before it queues a session.
- A delivery is handled once. Sentry’s
Request-IDis kept with the session, and a redelivery starts nothing. Two kōjō replicas that receive alerts for one issue at the same moment start one session between them. - At most 8 alerts are handled at once per server. An alert that comes while 8 are being handled is dropped and logged (
alert dropped); the rule sends another the next time it fires. The work on one alert (the checks, reading the issue, queueing the session) is given up after 2 minutes. A server that is stopping takes no more alerts and waits for those at work within its shutdown deadline.
The checks that come before reading the issue cost no call to Sentry. When Sentry’s API does not answer, the session starts anyway from what the alert carried, without the issue’s status and counts.
When an alert starts nothing
Each alert kōjō does not act on is audited as request.reject, with the project, environment and issue, and counted in kojo_requests_rejected_total under its reason:
| Reason | Why |
|---|---|
alert_unmapped |
No enabled repository maps the project and environment |
alert_ambiguous |
Several enabled repositories map them |
alert_open |
A session on the issue is still at work |
alert_pr_open |
The issue’s latest session has a pull request still open |
alert_round_limit |
The issue has had three sessions |
alert_daily_limit |
The entry started max_per_day sessions in the last 24 hours |
alert_resolved |
The issue is resolved or ignored in Sentry |
The actor is alert:sentry:<project> and the target sentry:<issue ID>. A redelivery of a delivery already handled is not audited.
Webhook
kōjō answers 200 to a delivery it accepted, ignored or dropped, 401 when the signature does not verify, 400 when the body is not an alert it can read (not JSON, no project in the event’s address, no issue ID), 413 when the body is larger than 25 MiB or did not arrive within 30 seconds, and 503 when 64 deliveries are already being read or handled. The JSON body’s status says accepted, ignored or dropped. The answer comes before the checks above, so an alert that starts nothing is still answered 200 and accepted.
Limits
- Only issue alerts start sessions. Metric alerts, Sentry’s
issuewebhooks (created, resolved) and its other resources are ignored. - Sentry’s API has no way to comment on an issue, so the outcome is never posted there.
- Sentry signs the body but no timestamp, so a captured delivery can be sent again under another
Request-ID. The per-issue bounds above limit what that can start, and its change is a draft like any other. - An alert carries the event that fired the rule, and the session sees that event only.
- The pull request’s title starts with the Sentry short ID, such as
API-12. A tracker integration that links pull requests by an issue key in the title, as Linear’s does, can link it to an unrelated issue whose team or project key equals the Sentry project’s slug, and move that issue when the pull request is merged, as its automation says. max_per_dayis counted by each kōjō server under a lock of its own, not across servers. With several replicas, alerts that reach different replicas at the same moment can exceed it by a few sessions. The per-issue bounds hold across replicas: the round is part of a key the store refuses twice.- The source lines of a frame are the ones Sentry captured. Without source context (for example, minified JavaScript without source maps), the frames name files and lines only.