Skip to content

feat: let merge conflicts bring agents back to their pull requests - #238

Merged
kalaspuff merged 3 commits into
mainfrom
fctl/180-it-would-be-great-if-agents-could-automa
Oct 23, 2026
Merged

kalaspuff merged 3 commits into
mainfrom
fctl/180-it-would-be-great-if-agents-could-automa

Conversation

@fctl-sh

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

Copy link
Copy Markdown
Contributor

Projects can now bring their agents back when a pull request they opened conflicts with its base branch, the fourth follow-up after comments, failed checks and merges (#228). The agent hears of it in a message from fctl, which resumes its session if it stopped, as for the others, and merges the base branch in, resolves the conflicts and pushes, so that nobody has to go to the session and tell it to. This was the open roadmap item "Follow-ups: merge conflicts with the base branch bring agents back".

What it does

  • A fourth switch, off by default: Settings → Pull requests → Merge conflicts, fctl projects set --follow-ups conflicts (and in all), FollowUps.conflicts. An update that leaves it out (an older tab or CLI) keeps what was stored.
  • fctl asks GitHub, since GitHub tells nobody. No delivery says when a pull request starts to conflict, and GitHub works mergeable out only when someone asks after either branch moved, in the background, saying UNKNOWN until then. I checked that against a busy public repository: of 30 open pull requests, GitHub knew about none at the first query and about all 30 twenty seconds later. So the lookups now read mergeable:
    • after any delivery about the pull request (pushes, checks, edits…);
    • when a session finds its pull request: one opened with conflicts gets no check deliveries, since GitHub runs none of its pull_request workflows. That's what happened in the screenshot that started this: the agent waited for CI that never came;
    • after a delivery that merged a pull request into the repository: a lookup without checks (webhooks::Fields::WithoutChecks, one point of the rate limit for up to 50) of the other pull requests sessions list there, neither merged nor closed, whose projects follow up on conflicts (pull_requests::moved_onto).
  • Asking again. While GitHub says it doesn't know, the session that opened the pull request asks again from its own alarm (its new asks table): 15 s later, then 30 s, 1, 2 and 4 minutes (ASK_AGAIN_MS), and after that leaves it to the next delivery.
  • What the agent is told (follow_ups::message): that the pull request has conflicts with main at its commit, so it can't merge and GitHub runs none of its pull_request workflows; to merge the updated base branch in (git fetch origin main && git merge origin/main), resolve each conflict so that both sides' changes still do what they were for, run the tests and push; not to rebase or force-push; and to ask on the pull request when a conflict takes a decision the code doesn't answer.
  • Not too often. Once for each head commit: after the agent pushes its merge, conflicts come again only with a later commit. Like failed checks, conflicts wait while a turn runs and for 10 s after it, and are dropped when a later lookup says the head moved (the agent's own push). At most three in a row while nobody messages the agent, counted apart from failed checks; after that the transcript shows them muted, with why.
  • In the app: a transcript line, ⚠ Conflicts with main · web#12 at 3f2a1c9, with what fctl told the agent a click away (GitHub's alert octicon, in the caution color); a muted line and a note for held ones; the switch; and the session page's hint under its pull requests ("…failed checks, merge conflicts and merges do too.").

Decisions worth a look

  • After merges, not pushes. The app doesn't subscribe to Push, and adding it would bring a delivery for every push to every branch. Merges are how the bases of agents' pull requests move. A push straight to a base branch (a release commit, say) shows at the next merge into the repository, or the next delivery about the pull request. ADR 0045 records this.
  • Lookups without checks for those after merges and for the asks: they cost the same point, take GitHub a fraction of the time for repositories with many checks, and leave the checks sessions show as they were. They also don't count as the hourly sweep's lookup, so it still refreshes checks.
  • Once per head commit, not per base commit. An agent that couldn't resolve them isn't told again at every merge, and a person sees GitHub's conflict box and the transcript.
  • A session finding its pull request brings conflicts, unlike failed checks: deliveries about a pull request that was just opened come before its session lists it. The hourly sweep still wakes nobody, so turning conflicts on doesn't wake sessions whose pull requests conflicted long ago, until one of them gets a delivery, or another pull request merges into their repository.
  • Merge, don't rebase, which matches fctl's own rule that agents never rewrite published history.
  • ADR 0045 records the reasoning.

A bug the end-to-end run found, fixed here

A session dropped conflicts as old news when its pull request's checks, from its last full lookup, were another commit's. Lookups without checks don't update those, so when the lookup after a push fails, or the push's delivery goes missing, fresh conflicts at the new head would have been dropped until the next full lookup, up to six hours later. Items now carry when their lookup asked GitHub, and only a later lookup that saw another head makes conflicts old news (follow_ups::conflicts_still, ac45793).

What instance admins need to do

Nothing: no new permission and no new event. The lookups use the Pull request events the app gets already. Projects turn the switch on.

Compatibility

All additive. FollowUps.conflicts has a serde default, and settings updates without it keep the stored value. Older clients read FollowUpEvent::Conflicts as other, and older CLIs show the message's text. The internal PullRequestsSeen.asks and follow_ups::Item.seen are new too, and the session object creates its asks table IF NOT EXISTS. No migration. Hosts and agents need nothing: they get the message as any other.

How I verified it

  • Unit tests: lookups reading mergeable, and the fragment without checks (webhooks); conflicts as news only for open pull requests with a head; when to ask again and when to stop; keys, one per commit; the message with and without a base; held text; the in-a-row count kept apart from checks; staleness by lookup time (follow_ups); settings that keep an unsent conflicts; the CLI flag and its words; the proto wire format; fake-claude's answer; 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, with a throwaway GitHub App and a local stand-in for GitHub's API whose mergeable answers I controlled. A bare repository stood in for acme/web, and a stand-in gh let fctl-agent find the pull request. A local patch, reverted, pointed the Worker at the stand-in. Signed deliveries:
    1. A session found its pull request: GitHub said unknown, the session asked again 15 s later (conflicting), and 10 s after that the agent got the message and answered.
    2. Another merge while the same commit conflicts: looked up (without checks), not passed on again.
    3. A push that resolved them (mergeable): nothing.
    4. A merge into main that GitHub needed three asks for: lookups at 0, +15 and +45 s, then the message.
    5. Three in a row reached the agent; the fourth showed only as the muted note.
    6. During a turn: conflicts found at 14:36:17 waited for the turn's end (14:36:55) and went at 14:37:05. A person's message had reset the count.
    7. During a turn, followed by the agent's push that resolved them: dropped. I ran this again after the fix.
    8. Conflicts off: no lookups after merges, no asks, nothing passed on.
    9. GitHub never knows: six asks over 465 s, then "not asking again whether acme/web#12 conflicts: GitHub didn't know after 6 asks".
    10. A stopped session resumed for conflicts that a merge brought, and its agent answered. This is the run that found the bug above.

Screenshots

From cargo xtask dev with the runs above, at acc166c.

Settings → Pull requests, before and after (light):

Before After
Before: three switches After: a fourth switch, Merge conflicts

Dark, and on a phone (390 px):

The Pull requests section, dark

The Pull requests section on a phone

A session brought back by conflicts: the agent pushed its pull request, fctl found it conflicts with main, and the agent answered. The hint under its pull request names merge conflicts (light, dark):

A session page with Conflicts with main in its transcript, light

The same session page, dark

What fctl told the agent, opened (light; dark on a phone):

The conflicts line with what fctl told the agent opened

The same on a phone, dark

Held after three in a row:

Conflicts shown muted, with why the agent didn't hear of them

Other repositories

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

fctl-sh Bot added 3 commits October 23, 2026 14:26
…se branch

Projects can turn on a fourth follow-up, merge conflicts: when GitHub says
a pull request one of fctl's agents opened conflicts with its base branch,
the session that opened it hears of it in a message from fctl, which tells
the agent to merge the base branch in, resolve the conflicts and push.

GitHub sends no delivery when a pull request starts to conflict, and works
mergeability out only when asked, so fctl asks: after a merge into a
repository, about the other pull requests sessions list there; after any
delivery's lookup; and when a session finds a pull request. While GitHub
doesn't know yet, the session that opened it asks again, 15 s, 30 s, 1, 2
and 4 minutes later.
A session dropped conflicts as old news when its pull request's checks,
from its last full lookup, were another commit's. Lookups without checks
don't update those, so when the lookup after a push failed, or the push's
delivery went missing, fresh conflicts at the new head were dropped until
the next full lookup. Items now carry when their lookup asked GitHub, and
only a later lookup that saw another head makes conflicts old news
(follow_ups::conflicts_still). Seen end to end: a stopped session now
resumes for them.

The message says "has conflicts with main", which reads better before
"until they're resolved".
Architecture, ADR 0045, self-hosting, the CLI, automation, development
and the agent instructions say what conflict follow-ups do: when fctl
asks GitHub, how often it asks again, what the agent is told, and how
often in a row.
@kalaspuff
kalaspuff merged commit 26c56fd into main Oct 23, 2026
11 of 12 checks passed
@kalaspuff
kalaspuff deleted the fctl/180-it-would-be-great-if-agents-could-automa branch October 23, 2026 17:27
@kalaspuff kalaspuff added agents Agent behavior and Claude integration and removed agents Agent behavior and Claude integration labels Oct 23, 2026
@fctl-sh fctl-sh Bot mentioned this pull request Oct 23, 2026
6 tasks done
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.

1 participant