Skip to content

feat: let comments, failed checks and merges bring agents back - #228

Merged
kalaspuff merged 10 commits into
mainfrom
fctl/161-it-should-be-possible-to-configure-proje
Oct 23, 2026
Merged

kalaspuff merged 10 commits into
mainfrom
fctl/161-it-should-be-possible-to-configure-proje

Conversation

@fctl-sh

@fctl-sh fctl-sh Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Projects can now bring their agents back to the pull requests they opened (follow-ups): a comment that mentions the agent, a failed check, a merge. Each reaches the session that opened the pull request in a message from fctl, which resumes the session if it stopped, on the Claude subscription it ran on, as a person's message would. Fixes #8, as the session refined it: comments count only from people the repository trusts, only when they address the agent, and only from people, not apps.

What it does

  • A project setting, three switches, all off (Settings → Pull requests, fctl projects set --follow-ups comments,checks,closed / all / none, ProjectSettings.follow_ups). fctl projects show says which are on. An update that leaves the field out (an older tab or CLI) keeps what was stored.
  • Comments that address the agent: a new comment on the conversation, a review, or a comment on lines, that mentions @fctl or @agent anywhere, or starts with fctl:, agent:, fctl, or agent, (any case). Quotes (>), code (backticks, fenced blocks) and HTML comments don't count, so people can quote a request or write `@fctl` to explain it; edits don't count either. A review that addresses the agent brings its comments on lines.
  • Only people the repository trusts: the commenter must be a person (GitHub's User, not a [bot], so not fctl's own review agents, whose findings already come back on their own path), with an author_association of OWNER, MEMBER or COLLABORATOR, and GitHub's permission endpoint must say they may write to the repository (admin, maintain or write). A member of an organization who may only read a public repository can't steer an agent that pushes. Everyone else costs no GitHub call.
  • Failed checks: after a check_run/check_suite/status delivery, the lookup names the newest commit's failed checks (failed, timed out or couldn't start, by each check's latest run, and failed or errored statuses; cancelled runs and runs waiting for approval don't count).
  • Merged or closed: who merged or closed it (a merge queue's bot counts as nobody) and into which branch.
  • Only fctl's own pull requests, to the session that opened them, chosen as for review findings (ADR 0041). Archived and failed sessions, archived projects and agents that only read on GitHub get nothing.
  • How the agent hears of it: the session gathers what comes for ten seconds, so a review and its comments, which arrive as separate deliveries, or checks that fail together, make one message per pull request. The control plane writes it: who wrote what and where, quoted, how to answer each where it was made (gh pr comment, or gh api …/comments/{id}/replies in a thread); which checks failed, what still runs, and how to look into them; after a merge, what may be left to do. It says that only people who can write to the repository reach the agent this way.
  • Failed checks don't nag: they wait while a turn runs (the agent may already be on them) and ten seconds more once it ends, then go only while GitHub still says they are the newest commit's and failed. A newer commit (the agent's or anyone's push) or a passing re-run drops them. After three in a row while nobody messaged the agent, or wrote to it on GitHub, the transcript says what failed instead, until someone does.
  • On GitHub: an 👀 reaction on the comment once its session has it, with a token for that repository alone, revoked right away. The workspace's audit log records each comment passed on (follow_up.comment).
  • In the app: the transcript shows a follow-up as GitHub has it: the commenter's avatar and login, what they wrote as Markdown (pictures as links, since the app only loads images from where it trusts), a review's verdict and its comments under their files, failed checks by name, a merge, with What fctl told the agent a click away. Held checks show muted, with why. A session's page says under its pull requests what brings its agent back ("Mention @fctl or @agent on GitHub to bring the agent back; failed checks and merges do too."). Settings say when the instance takes no webhooks.

Decisions worth a look

  • "Trusted users in the GitHub organization" became write access, checked with GitHub. The association alone would let read-only org members of a public repository steer an agent that pushes and holds the project's secrets. Write access is the bar the repository already sets for changing its code.
  • Only deliveries bring agents back. The hourly sweep that repairs missed deliveries keeps pull requests current without waking anyone, so turning follow-ups on, or a delivery that went missing, never wakes sessions for what happened long ago.
  • Staleness is GitHub's word, not the sandbox's. An earlier version dropped failed checks when the agent had another commit checked out; a person's push to the agent's branch makes that true too, so it now goes by the pull request's head as GitHub reports it.
  • Merge conflicts don't bring agents back: no delivery says when a pull request starts to conflict with its base. It's in the roadmap.
  • ADR 0043 records the reasoning.

What instance admins need to do

Subscribe the GitHub App to Issue comment, Pull request review and Pull request review comment (Permissions & events). No new permission: the app reads and writes issues and pull requests already, so installations accept nothing. app.fctl.sh's app needs this change for comments; failed checks and merges work with the events it has. Recent Deliveries answers {"ok":true,"follow_ups":1} for a comment that reached an agent.

Compatibility

All additive: ProjectSettings.follow_ups, UserMessage.follow_up, Notice.follow_up (older clients show the message's text), Features.github_webhook, and the internal /follow-up and PullRequestsSeen.follow_ups. FollowUpEvent reads kinds a newer control plane adds as other instead of failing the event. No migration: the session object's follow_ups table is created IF NOT EXISTS. Older hosts and agents take follow-ups as any message; fake-claude answers them on its own, so their words set off none of its behaviors.

A bug this found on the way

GitHub's GraphQL API names an app's bot without [bot] (fctl-sh, type Bot), where REST says fctl-sh[bot]. The webhook lookups now ask for the author's type and spell bots as REST does; without that, failed checks of fctl's own pull requests would never have matched. I checked it against #225 with the sandbox's token.

How I verified it

  • Unit tests: fctl_domain::follow_ups (16 tests: addressing, with quotes, code spans, fences, HTML comments, emails, @fctl-sh, team mentions; payload parsing of the three comment events; trust and write access; keys; grouping; every message; the cap), webhook lookups (failed check names, bot authors), settings that keep unsent follow-ups, the proto wire format (and an unknown kind), the CLI flag, fake-claude, and the web helpers and component (follow-ups.test.ts, follow-up.test.tsx). cargo xtask check passes.
  • End to end in cargo xtask dev, against a local stand-in for GitHub's API and a bare repository standing in for acme/web (not committed; the Worker pointed at it by a local patch I reverted), with signed deliveries:
    • Ignored, each for its reason: a bot (renovate[bot]), a CONTRIBUTOR, a MEMBER GitHub says may only read (the only one that cost a call), a comment without a mention, @fctl in backticks, a quoted request; an archived session; a project with comments off.
    • A comment from a member who can write: one message, the agent answered, 👀 on the comment (token for web alone, issues/pull_requests write, revoked).
    • A review with two comments on lines, sent as GitHub does (three deliveries): one message with the comments under the review; the comments' own deliveries added nothing.
    • Failed checks: two deliveries made one message naming "Rust tests and Clippy, 1 still running, 4 passed".
    • During a turn: checks that failed while the agent worked reached it ten seconds after the turn ended; those of a commit the agent had already replaced were dropped.
    • A person's pushes to the agent's branch, each failing: three reached the agent, the fourth only left the muted note.
    • A merge: one message ("merged into main by @ada") from two deliveries; a comment on the merged pull request told the agent to put changes in a new pull request from the updated main.
    • A stopped session resumed for a comment, and its agent answered it.
    • An older client's settings update kept the stored follow-ups.

Screenshots

From cargo xtask dev with the runs above, at f66ec00. GitHub avatars are generated stand-ins.

Settings → Pull requests (light, dark, 390 px):

The Pull requests section of a project's settings, light

The Pull requests section, dark

The Pull requests section on a phone

A session brought back by a comment, with what brings its agent back under its pull request:

A session page with a comment from GitHub in its transcript, and the hint under its pull request

A review with its comments on lines (light, dark):

A review that requested changes, with two comments on lines, light

The same review, dark

Failed checks, then a merge, and what fctl told the agent, opened:

Two failed checks named, the agent's answer, then the merge

A comment with What fctl told the agent opened

Held back after three in a row:

A failed check shown muted, with why the agent didn't hear of it

On a phone (390 px):

A comment and a review in the transcript on a phone

Other repositories

Session: https://app.fctl.sh/s/ses_01M5M5MN1ME75KPJSE74983JEE

fctl-sh Bot added 8 commits October 23, 2026 11:14
…failed checks and merges

Projects can turn on follow-ups (ProjectSettings.follow_ups): comments that
address the agent (@fctl, @agent, or fctl:/agent: at the start) from people
who can write to the repository, failed checks of the newest commit, and
merges or closes of pull requests fctl's app opened reach the session that
opened them, in a message from fctl that resumes it if it stopped.

The session gathers what comes together (a review and its comments) for
ten seconds, holds failed checks while a turn runs and drops those a newer
commit made old news, and passes on at most three failed checks in a row
while nobody messages the agent.
fctl projects set --follow-ups comments,checks,closed (or all, none), and
fctl projects show says which. fake-claude answers fctl's follow-up
messages on its own, so that their words set off none of its behaviors.
…in transcripts

A project's Settings get a Pull requests section with three switches:
comments that mention the agent, failed checks, and merges or closes. The
transcript shows what brought the agent back as GitHub has it: people's
comments with their avatars and a review's comments on lines under it,
failed checks by name, a merge or close, with what fctl told the agent a
click away. A session's pull requests say what brings its agent back.
…cks by GitHub's head

GitHub's GraphQL API names an app's bot without [bot] (fctl-sh where REST
says fctl-sh[bot]), so lookups now ask for the author's type and spell
bots as REST does: otherwise failed checks of fctl's own pull requests
never reached their agents.

Failed checks are old news once GitHub says the pull request's head is
another commit, whoever pushed it, rather than when the agent has another
commit checked out, which a person's push to its branch also makes true.
Held checks wait ten seconds once the turn ends, for what the agent
pushed then. Conversation comments look the pull request up for its
branches, and the agent hears where changes go once it merged.
…gent didn't hear

A follow_up_held notice carries the follow-up fctl kept from the agent
(Notice.follow_up; clients from before it show the message), which the
transcript shows as the failed check, muted, with why it wasn't passed on.
The settings' copy says what each switch does in fewer words, and a
follow-up's hover-only time takes no line of its own on phones.
The architecture (Follow-ups), ADR 0042, self-hosting (the three events
the GitHub App subscribes to), the CLI and automation guides, fake-claude's
answer in the development guide, the roadmap, and what this repository's
agents may count on after they open a pull request.
…ivery once

A comment GitHub delivers twice while the first copy still gathers counts
as taken once, so that its reaction and audit entry come once.
A comment's delivery is matched to the sessions that list its pull request,
and their projects' follow-ups, before any GitHub call, and a comment on
the conversation looks its pull request up (with the lighter query reviews
use) only where several sessions list it or it merged. Follow-ups that a
session couldn't be told of with its pull requests go once more on their
own; a delivery without GitHub's ids routes none; Enterprise Managed Users'
logins (ada_acme) pass; and grouping returns each follow-up's keys.
kalaspuff pushed a commit to hyperstructure/fctl-site that referenced this pull request Oct 23, 2026
The privacy policy says what follow-ups receive, keep and send, for
hyperstructure/fctl#228, which lets projects bring their agents back to
the pull requests they opened: when someone who can write to the
repository mentions `@fctl` or `@agent` in a comment, when a check
fails, when a pull request merges or closes.

With follow-ups on in a project, app.fctl.sh:

- **receives** comments and reviews on pull requests through the GitHub
App's webhook (the app subscribes to Issue comment, Pull request review
and Pull request review comment), and asks GitHub whether a comment's
author may write to the repository;
- **keeps** the comments it passes on to an agent (their text, link, and
their author's GitHub login and picture), with failed checks and merges,
in the session's transcript, and records each comment it passes on in
the workspace's audit log, with its author's login and link;
- **sends** them to the session's agent, and so to the Claude account it
runs on, and **posts** an 👀 reaction on each comment it passes on, which
everyone who can read the repository sees.

The changes:

- **Projects and sessions**: the messages fctl sends agents include,
where follow-ups are on, the comments that mention the agent (text,
link, author's login and picture), failed checks and merges.
- **GitHub**: the webhook also tells us about comments and reviews;
which of them we keep and why.
- **Audit logs**: each comment passed on, with its author's login and
link.
- **Why we use it**: a row for passing people's comments to agents and
asking GitHub about their access (legitimate interests: letting the
people a repository trusts direct its agents from GitHub, and nobody
else).
- **GitHub** (services you connect): the reaction on comments passed on.
- **Anthropic**: what follow-ups pass on goes to the Claude account the
session runs on.

Retention needs no change: follow-ups are part of the session's
transcript, which goes with the project.

Session: https://app.fctl.sh/s/ses_01M5M5MN1ME75KPJSE74983JEE

Co-authored-by: fctl-sh[bot] <343971779+fctl-sh[bot]@users.noreply.github.com>
@kalaspuff
kalaspuff merged commit aeacccc into main Oct 23, 2026
11 checks passed
@kalaspuff
kalaspuff deleted the fctl/161-it-should-be-possible-to-configure-proje branch October 23, 2026 12:34
fctl-sh Bot added a commit that referenced this pull request Oct 23, 2026
#228 gave UserMessage an optional follow_up, which a schedule's first
message never carries.
kalaspuff pushed a commit that referenced this pull request Oct 23, 2026
The deploy of #228 to app.fctl.sh
[failed](https://github.com/hyperstructure/fctl/actions/runs/39954400672/job/120417687330#step:8:1)
on its first request to Cloudflare's API. `wrangler d1 migrations apply`
got a 429 (`Please wait and consider throttling your request speed
[code: 971]`, with a `Retry-After` of 40 s) and gave up. Rerunning the
job 45 minutes later deployed it.

## Why it failed

Cloudflare throttles a token, an account or an address once it has made
too many requests (the documented limit is 1,200 per 5 minutes per
user). It then answers 429 with a `Retry-After` for up to five minutes,
even to a client's first request. That is what happened here, so the
requests that used up the limit came from somewhere else: other use of
the account's API, or the runner's address. Nothing in a run's logs
tells which. fctl.sh's own deploy, about 40 s earlier, made only a dozen
or so requests.

Wrangler 4.151.1 retries a 429 only in some of `wrangler deploy`'s
requests (`retryOnAPIFailure`, waits of up to 60 s). Its D1, KV and
secret commands send each request once and fail at the first 429. The
newest wrangler, 4.152.0, does the same, so upgrading wouldn't help.

## What changes

- `util::retry_throttled` runs a wrangler command that calls the API,
and runs it again when the API throttled it. It gives wrangler a
`WRANGLER_OUTPUT_FILE_PATH` and reads the `command-failed` entry
wrangler writes there (`"code": 971, "retry_after_ms": 40000`), so
wrangler keeps its terminal, its prompts and its colours. It waits what
the API asks plus a second (a minute for a 971 without a `Retry-After`),
at most four attempts in all. It gives up at once on a wait over five
minutes, and runs any other failure only once.
- Running a command again from the start is safe: a throttled request
never ran, `migrations apply` applies only the migrations not applied
yet, and the deploy, secret and KV writes end the same way when
repeated.
- Every wrangler command xtask runs against the API goes through it:
`cargo xtask deploy` (migrations, deploy, the secret list after it, `d1
create`), `cargo xtask secrets` and `cargo xtask publish`. That last one
covers the Release workflow's KV writes to fctl.sh/releases, which had
the same exposure.
- docs/self-hosting.md and docs/development.md (Deploying) say so.

## Verification

- Unit tests in `xtask/src/util.rs`. They parse the entries wrangler
writes, and drive `retry_throttled` with a stand-in `wrangler` script:
throttled once then done, throttled every time (it gives up after 4
runs), a failure that isn't throttling (1 run) and a wait over five
minutes (1 run).
- End to end against a local stand-in for Cloudflare's API (wrangler's
`CLOUDFLARE_API_BASE_URL`, a dummy token, telemetry off). It answers the
first request of each kind with exactly what Cloudflare sent (429, code
971, `Retry-After: 2`):
- Without the fix, `wrangler d1 migrations apply DB --remote` failed
with the same output as CI.
- `cargo xtask deploy fctl-sh --skip-build` printed `Cloudflare's API
throttled wrangler: running it again in 3 s (attempt 2 of 4)`, ran the
migrations again and applied the pending one. `wrangler deploy` then
failed because no Worker was built here, and that failure was not
retried.
- `cargo xtask secrets fctl-sh` (the secret list) and `cargo xtask
publish` (KV puts) each recovered from a throttled first request.
- Against an API that throttles every request: four runs, then `Error:
Cloudflare's API throttled wrangler 4 times in a row`.
- `cargo xtask check lint` and `cargo xtask check test` pass.

Session: https://app.fctl.sh/s/ses_01M5MEKPMFJDMW1AX89Y9N5G6Q

Co-authored-by: fctl-sh[bot] <fctl-sh[bot]@users.noreply.github.com>
kalaspuff pushed a commit that referenced this pull request Oct 23, 2026
When fctl's review agent posts findings on a pull request that one of
fctl's agents opened, fctl passes them on to that agent in a message
(#225). The session's transcript showed that message whole: each
finding's explanation, then the instructions for the agent and the `gh
api` command it answers with. A single finding took most of a page, and
several took more. People rarely need to read all of that, so the
transcript now shows the review in a few lines, with the whole message a
click away.

## What changed

- **The message carries the review it is about** (`UserMessage.review`,
a new `PassedOnReview`), as follow-ups carry theirs
(`UserMessage.follow_up`, #228). It holds the pull request, the commit,
the review's summary and session, and for each finding its severity,
title, file and lines, and its comment on GitHub.
`fctl_domain::reviews::passed_on_review` builds it from the same `Found`
as the message's text, in the same order (most severe first, through a
shared `order`). The agent gets the same text as before.
- **The transcript shows it in a few lines**, styled like a follow-up's
failed checks: "fctl's review agent found 2 issues in web#12 at
3f2a1c9", then one line per finding (its title, then its severity and
`path:lines`). Each finding's title opens its comment on GitHub, or the
review's summary for a finding on lines the diff doesn't show. **What
fctl told the agent** opens the whole message. The agent's name opens
the review's session, the pull request opens the review's summary, and
the commit opens the commit.
- **Findings messages sent before this change** have no review in them.
They show their first five lines with a **Show all** button. Only these
get cut: they are recognized by the words `passed_on` starts them with.
Other messages from fctl stay whole, including a scheduled run's task
(#229, which sends it as a message from fctl), and so do people's
messages.

## Compatibility

All additive, no migration. `UserMessage.review` is optional, and
clients without it show the message's text as before. The internal
`/review-findings` body's new `shown` field defaults to nothing. Neither
hosts nor agents read the field.

## How I verified it

- **Unit tests** cover the proto wire format, including a message
without a review. In the domain, they check that `passed_on_review`
lists findings in the message's order and links each by where it is on
GitHub: its comment, the summary, or nothing known. Web tests check the
findings view (lines, links, one issue, no summary, the message a click
away), the transcript (a review goes to the new view, old findings
messages get cut, and a short task, a long scheduled task and people's
long messages stay whole), and that the builder keeps the review on its
item.
- `cargo xtask check` passes. One run failed in xtask's
`runs_a_throttled_command_again`, an intermittent race in tests from
#230 that this branch doesn't touch (#232); the rerun passed.
- **End to end in `cargo xtask dev`**, through a temporary route I
didn't commit. It hands made-up findings to SessionObject's
`/review-findings` as `pass_on` does: the real `passed_on`, `held_back`
and `passed_on_review`, the internal call, and the stored event. A
session got the finding from the screenshot in the request, and the
message's text came out identical to it. fake-claude answered it, and
the page showed the review in a few lines. The stored event carried the
review (`GET …/events`). An `fctl` binary built from main printed the
same event with `fctl logs --json`, without the field, so older clients
read it as before. A message sent without the review, like one from
before this change, showed its first lines and opened with Show all. I
didn't run posting on GitHub, `spots` or `pass_on`'s choice of session
against a GitHub stand-in. This change leaves them as they were, and
their tests cover them.

## Screenshots

From `cargo xtask dev` at 444dfee (the views haven't changed since),
with fake-claude's answer after each message. The pull request and
finding are the ones from the screenshot in the request.

**The message from the request**, light, 1440 px wide:

| Before | After |
|---|---|
| ![Before: fctl's findings message in full, taking most of the
page](https://app.fctl.sh/api/v1/published/hj84xS95c5bvmd2utgEMY1qGp14QCmlXFJobpNa4dDQ/before-light.png)
| ![After: one header line, one line for the finding, and What fctl told
the
agent](https://app.fctl.sh/api/v1/published/Sv7KaTlWWLrrhz4G976yvEcixZECIG8ndKWSCGrPtR0/after-light.png)
|

**On a phone** (390 px):

| Before | After |
|---|---|
| ![Before: the message runs over several screens on a
phone](https://app.fctl.sh/api/v1/published/QwKoh1y4GzNuWodKc1DapBit9LSGjcV3KFbCcL0XM6j/before-light-390.png)
| ![After: the review in a few lines on a
phone](https://app.fctl.sh/api/v1/published/x95nhqGSdlfia0sjaxY7yRVoAGLXnkSSp3j7Fip5h6k/after-light-390.png)
|

**Dark:**

![After, dark: the review in a few
lines](https://app.fctl.sh/api/v1/published/NXNIRQW3qFYiiyykOl45CcB0c6O2zBpiauPCQ3PRQRv/after-dark.png)

**Three findings**, most severe first: one on lines the pull request
deletes ("old version"), and one in the review's summary:

![A review with three findings, one line each, on the session
page](https://app.fctl.sh/api/v1/published/Wpu8NTZ1NEUmdbBgC2gBQYUgJR9o3QNvLrHneAoBbZJ/three-light.png)

**What fctl told the agent**, opened:

![What fctl told the agent opened under the review, showing the whole
message](https://app.fctl.sh/api/v1/published/MKyPEc1MV1SonBnMLzskBYoG4UpvnQ0vxw9otdMncZR/one-told-dark.png)

**A findings message sent before this change**, which has no review in
it:

![The older message's first five lines, ending at the first finding's
title, with Show
all](https://app.fctl.sh/api/v1/published/cXussMeSJ3b0XIILwM3Ktg3cxyEkG9rxs7gKiWjc8vP/older-light.png)

Session: https://app.fctl.sh/s/ses_01M5MFGRENHK8PHRFQXJ53360Z

---------

Co-authored-by: fctl-sh[bot] <343971779+fctl-sh[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

React to CI failures and review comments

1 participant