Repository navigation
feat: pull request feedback (M4), starting with superagent's own GitHub account - #16
Merged
Merged
Conversation
M4 starts with a GitHub account for the agent. Workers push, open pull requests, comment, and resolve threads as that account, so the owner can review its work and M4 can tell the owner's comments from the agent's. On GitHub only the owner's words and installed bots' count: the owner gate's equivalent, so a stranger's comment on a public repo can't steer a worker. A merge or close ends the task from any state. Open decision 2 is closed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The first step of M4. With SUPERAGENT_GITHUB_TOKEN set, startup asks GitHub whose token it is and refuses one that belongs to SUPERAGENT_OWNER_GITHUB, and workers act on GitHub as that account: - gh through GH_TOKEN; - pushes over https with the same token, through a credential helper that follows an empty credential.helper, so the machine's own helpers, like a keychain holding another login, don't answer; - insteadOf rewrites, so an SSH remote for GitHub doesn't push with the machine's SSH key; - commits authored as the agent, with GitHub's noreply address. A new @repo/core/github module holds a small fetch-based client, resolveAgentAccount, and agentAccountEnvironment. Without a token, workers use the machine's own logins, as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The middle of M4's pull request watcher, before the loop that runs it:
- readPullRequest fetches a pull request, and only the parts the caller
says have changed: reviews and comments when its updated_at moved,
check runs for a new head commit or while checks are pending. That
keeps a poll to one or two requests.
- pullRequestFeedback is pure. It turns a snapshot into the inputs that
wake the worker, the notices for the Slack thread, whether the task
is over, and the new read position for kv:
- a pull request off agent/<task id>, or from a fork, is foreign, and
the owner is told once;
- a merge or close posts once and closes the task;
- only the owner's words and installed bots' count; the agent's own
and other people's are dropped;
- failed checks on the head commit count, once each;
- bots get three rounds;
- CI and bots never wake a failed or stopped task.
- TaskStore.withPullRequest, and done reachable from waiting, blocked,
failed, and stopped, so a merge can close a task from any state.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
createPullRequestWatcher polls each task's pull request every minute. It skips closed and foreign ones, reads only what changed, and applies pullRequestFeedback. Inputs, notices, the close, and the new read position are written in one transaction. The outbox and the runner are woken only when something new arrived, and one pull request's failure is logged without stopping the rest. A merge or close goes through the new closeTask: unread inputs dropped, the task done, and any live session ending at its next turn. stopTask shares dropUnreadInputs with it. M4 tells workers to use gh api, so the guard now looks inside it, refusing what gh pr merge, gh pr review --approve, and gh issue close are refused for: merges, including GraphQL mergePullRequest and enablePullRequestAutoMerge; approvals; and closing issues. Resolving review threads and replying to comments still pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- main starts the watcher, with the agent's client and login, after recovery alongside the task runner and the router, and stops it first on shutdown. Without SUPERAGENT_GITHUB_TOKEN it stays off, and startup says so. - recordReport refuses a pull request URL outside the task's repo, so the watcher only ever follows the task's own. - The worker learns what [github] messages are and what to do with them: fix and resolve the thread, or decline in one sentence on the comment; read a failed check's log and fix it; push; report ready again. - AGENTS.md gains a "Pull requests" section with M4's rules. The core README describes the watcher, and the roadmap marks M4 built, waiting on a live run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PR #5 in the scratch repo was opened and committed to as pakgin-agent. Its failing CI run was fixed with no Slack message, the owner's review comment was fixed and its thread resolved by the agent, and the merge posted once and closed the task. Only a stranger's comment being ignored is untested live, since that needs a third GitHub account. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From the owner's review of M4's live run: a comment on a pull request got no acknowledgement, and its answer went to Slack. The owner shouldn't have to switch places. - ack puts 👀 on the GitHub comments the worker was given, as the agent, through the new acknowledgePullRequestInputs. It's once per comment per session, and GitHub keeps one reaction per account anyway. Reviews and check runs can't take a reaction. A failure is logged, not thrown. The runner gets the agent's client. - report takes answeredOnGitHub: the state is recorded, nothing is posted in Slack. - The worker answers [github] messages on GitHub: in the review comment's thread (resolving it once fixed), with gh pr comment for a pull request comment, a review, or a fixed check. It then reports with answeredOnGitHub. - Automated reviewers such as Greptile: the worker judges each finding, fixing what's right and declining in its thread what isn't. A comment cut short says so, pointing at gh for the rest. The bot round limit keeps a reviewer that reviews every push from looping. - GitHubClient gains post. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ages A report answering a [github] message is now posted as a comment on the pull request instead of in Slack. The runner works out where it goes from the inputs the session was given since the last accepted report, less any handed back, so the worker no longer has to set answeredOnGitHub, which it forgot. A turn with Slack and GitHub messages posts in both places. When a turn that didn't fail ends, 👀 comes off each message it read and ✅ goes on in Slack, or 👍 on GitHub, which has no check mark. A message handed back is left for the router; a failed turn keeps 👀. GitHub comments and reactions now go through the outbox, like Slack's: migration 3 rebuilds the table for reaction removals and GitHub entries, the sender delivers each kind to Slack or to the agent's GitHub account, and a GitHub comment carries a hidden dedupe marker that a retry looks for before posting again. The direct-call acknowledgePullRequestInputs is gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Live, the worker replied to each of the owner's pull request comments with gh pr comment and then reported, and the report was posted there too, so every answer showed up twice. Its session had started under the earlier instructions, which told it to use gh pr comment. The instructions now say the report is the answer, and that the worker writes on GitHub itself only in a review comment's thread. AGENTS.md also records that an edited comment isn't read again: the watcher follows comment IDs, and Greptile edits its summary in place. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Greptile rewrites its summary comment in place after each review, and the watcher, which follows comment IDs, never saw it. A comment or review comment already read, and updated since, now becomes an input saying it was edited, with its new text, under its own ref (github:<kind>:<id>:edited:<updated_at>), so each edit is passed on once and gets 👀 and 👍 like a new comment. Who counts is unchanged, and a bot's edit uses one of its rounds. The edit mark is the newest updated_at among the comments read, kept in the read position, not the pull request's updated_at, so a comment written while a poll was reading isn't taken for an edit on the next one. A position saved before this falls back to its updatedAt, so no old edit is replayed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Telling the worker that its report is its answer on the pull request wasn't enough: live, after an edited comment, it still ran gh pr comment and then reported, so the answer was posted twice. The guard now refuses gh pr comment, gh pr review, and gh issue comment on the task's pull request (by number, URL, or none, meaning the current branch's), and gh api writes to its /issues/<n>/comments, saying the report is posted there. Review thread replies, reads, and other pull requests and issues still pass. The runner gives each session the task's pull request number, read when the command runs, and the session passes it to the guard. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pakgin
marked this pull request as ready for review
November 8, 2026 09:32
[High impact] The reviewed changes appear safe to merge; the remaining finding about live workers reopening closed tasks is fixed.
|
- A live worker no longer reopens a task its pull request closed. The
runner interrupts the session, as for a stop, and reopenReportedTask
refuses a task that went done under a session that didn't report done,
so a late report is turned down. The owner's next message resumes it.
- Comment edits are tracked per comment (commentVersions), not with one
mark for all, so reading the two lists in parallel, or across pages,
can't hide an edit.
- An unchanged head commit's checks are read again every five minutes,
so CI that starts late or is rerun on the same commit still counts.
- getAllPages reads every GitHub list to the end, check runs and the
outbox's comment and reaction lookups included, and throws past
GITHUB_MAX_PAGES instead of passing a cut-off list for the whole.
- The outbox sender starts no GitHub comment once it is stopping.
- The guard's comment rule names the task's repo (gh api paths,
{owner}/{repo}, --repo, and URLs), and gh api with an explicit GET is a
read even with fields.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Greptile, re-reviewing: now that a list past the page cap throws, a merged pull request with that many comments would fail every poll before pullRequestFeedback saw the merge, so its task would never close. The watcher now reads reviews, comments, and checks only for an open pull request that is the task's, the only one feedback uses them for. A first look at a foreign pull request is settled the same way. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Greptile's re-review still flagged the closed-task case, and one remained: the runner told a close apart by a done task its own session hadn't reported done, so a task whose worker had reported done before its pull request merged could still be reopened by a queued turn or a late report, and the watcher would never close it again. closeTask now marks the task closed (closed_at, migration 4), even when it was already done, and reopenReportedTask refuses a closed task. Every transition clears the mark, so the owner's next message, which resumes the task through a launch, reopens it. The live session's flag is gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
M4, pull request feedback, starting with superagent's own GitHub account. Code complete and smoke-tested live.
#15 and #14 are merged, and main is merged in here.
Roadmap: the M4 spec, with the agent's own GitHub account as its first step. Open decision 2 is closed.
The agent's own account (
@repo/core/github):SUPERAGENT_GITHUB_TOKENandSUPERAGENT_OWNER_GITHUB, with a startup check that the token isn't the owner's.GH_TOKEN, git pushes over https with that token, and commits authored with its noreply address.The pull request watcher, every minute:
readPullRequestfetches only what changed: reviews and comments whenupdated_atmoved, check runs for a new head commit or while some are pending. A quiet PR costs one request a minute.pullRequestFeedbackis pure, and holds every rule:agent/<task id>, or from a fork, is foreign, and the owner is told once;github:<kind>:<id>), notices, the close, and thekvread position in one transaction.Ownership at report time:
recordReportrefuses a PR URL outside the task's repo.closeTask: a merge or close drops unread inputs and moves the task to done from any state.stopTasksharesdropUnreadInputswith it.The guard now covers
gh api. Merges (including GraphQLmergePullRequestandenablePullRequestAutoMerge), approvals, and closing issues are refused there too. Resolving threads and replying to comments still pass.Review instructions:
Answering on GitHub, where it was asked:
ackputs 👀 on a[github]comment as the agent, as it does in Slack. Greptile's and other bots' comments count.[github]ones get a pull request comment, Slack ones a Slack post, and a turn with both gets both. This replaces anansweredOnGitHubflag the worker had to remember, and live it didn't.gh pr comment,gh pr review, andgh issue commenton the task's pull request, andgh apiwrites to its comments. Replies in review threads, reads, and other pull requests and issues pass.<!-- superagent:<key> -->marker that a retry looks for before posting again.Docs: AGENTS.md has a "Pull requests" section and the layout. The core README, CONTRIBUTING, and
.env.exampleare updated.Greptile's review (8 findings), fixed in 551d80b:
gh apiwith an explicit GET is a read.Checks
pnpm format,pnpm lint,pnpm typecheck, andpnpm testall pass: core 430, agent 20.gh apiguard;gh apiwrites but not reads, other pull requests passing, and the session and runner wiring;Verified live (2026-11-08, scratch repo with CI)
The agent account: PR feat(core): add the SQLite store and record Slack events in it #5 was opened by
pakgin-agent. Every commit was authored and pushed aspakgin-agentwith its noreply address. Startup resolved the token topakgin-agentand accepted it, since it isn't the owner's.A failing CI run fixed without Slack: CI failed on the first commit (the old
add()bug onmain). The watcher passed the failed check to the worker 22 seconds later. The worker fixed it, CI passed, and it reported ready again. The owner sent no Slack messages.The owner's comments:
pakgin-agentthroughgh api graphql.The review itself, which had no text of its own, was rightly skipped.
Merge: the owner merged PR feat(core): add the SQLite store and record Slack events in it #5. 39 seconds later the thread got one "Pull request feat(core): add the SQLite store and record Slack events in it #5 was merged, so this task is done." post, and the task became done. The watcher stopped polling it.
Not live: a stranger's comment being dropped, which needs a third GitHub account. Unit tests cover it.
🤖 Generated with Claude Code