Skip to content

[Bug]: watch_pull_request notices check changes only on the 2-minute sweep unless GitHub event streams are enabled #37477

Description

@PedroNavHur

Note

Claude Opus 5.5 writing on behalf of Pedro.

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Summary

A watched GitHub PR only finds out its checks changed on the next PullRequestWatchReactor sweep, which runs every 2 minutes. The real-time path from #33548 and #35709 needs both the T3 Code for GitHub app sign-in (off unless the server has T3CODE_GITHUB_APP_CLIENT_ID) and an account GitHub has enabled for its event-streams preview. For an account without that, POST /event-subscriptions returns 403 Event subscriptions are not enabled for this account, even with a repo-scoped token. So most users get the sweep only.

The delay comes after every change in check status, whatever the CI's length: up to ~2 minutes, about 1 minute on average. If a 5-minute CI fails at 5:30, the agent hears at up to 7:30. Failures, passes, and new remarks all wait for the same sweep. In a fix loop (fail, push, rerun, pass), the agent pays it once per round, so a few rounds lose several minutes of agent time for no reason. On short CI the wait can be longer than the CI itself.

The watch itself works: it notices, records, and wakes correctly. This is only about how soon it notices.

Steps to reproduce

  1. On 0.1.10-nightly.20261114, sign in to GitHub with gh or a saved token, without the app sign-in.
  2. Open a draft PR whose CI takes about a minute. Rerun the workflow and have an agent call watch_pull_request right away.
  3. Compare when the last check completes on GitHub with when the wake is recorded.

Observed timeline (UTC)

  • 02:27:43: workflow rerun, watch started
  • 02:28:39.5: PullRequestWatchReactor.sweep (checks still pending)
  • 02:28:41: GitHub finishes the last check
  • 02:30:39.5: next sweep; readGroup sees the PR green
  • 02:30:41: wake recorded (lag ≈ 2 min)

server.trace.ndjson shows sweeps every ~120 s, with no PullRequestWatchReactor.readOnChange and no GitHubPullRequestEvents.subscribe spans. Switching the background activity profile to Performance changes nothing; that setting doesn't touch this path.

Code pointers (main @ 6b7027b)

  • apps/server/src/orchestration-v2/PullRequestWatchReactor.ts:48: SWEEP_MINUTES = 2; :866-871 sweep, then follow feeds, then wait 2 min.
  • :858-862: follow attaches pullRequests.changes(...) to readOnChange.
  • apps/server/src/pullRequest/PullRequestService.ts:1132-1148: changes is Stream.empty when the provider has no feed, or on error.
  • packages/source-control-github/src/server/gitHubPullRequestEvents.ts:276-281: the feed is empty unless the app sign-in returns a token; :97-98: a 403 pauses feeds for all of github.com for an hour.
  • packages/source-control-github/src/server/GitHubAppSignIn.ts:110-118: the app sign-in is off unless T3CODE_GITHUB_APP_CLIENT_ID is set.

Ruled out: wake delivery (recorded ~1.5 s after the sweep's read), placeholder-check suppression (pullRequestWatch.ts:126), and fingerprint skipping in planRead (pending checks force a read, and the cached fingerprint expires after 15 s).

Requested change

For now: let users choose the sweep interval. A setting with 30 seconds, 1 minute, and 2 minutes (the default) would let people on small CI trade quota for faster wakes. The SWEEP_MINUTES comment is right that faster sweeps spend the account's shared quota. Each sweep costs about one fingerprint point per watched PR, so 30 s is roughly 4× the sweep cost of today, and a user choice makes that tradeoff explicit. This could be its own setting, or follow the existing background activity profile (Performance 30 s, Balanced 1 min, Battery saver 2 min).

Longer term: re-check PRs with pending checks more often, cheaply. When a watched PR has no live event feed and its last read saw pending checks, poll its head commit's check suites (GET /repos/{owner}/{repo}/commits/{sha}/check-suites with If-None-Match) every ~15–30 s. GitHub answers 304 Not Modified when nothing changed, and that doesn't count against the rate limit; #26310 uses the same trick with notifications. Do the full read only when the response changes. Quiet or settled PRs stay on the normal sweep, so quota barely moves.

It would also help to log once per watch when the event feed ends immediately, so sweep-only mode is visible in traces.

Related: #33548, #35709, #36463.


Posted by Claude Code (claude-opus-5-5) via T3 Code triage.

Activity

  1. gdlambda commented on Nov 16, 2026

    @gdlambda

    Confirmed another occurrence on Windows on 2026-11-16: the PR badge changed from checking to green while the thread still showed “Waiting · Watching pull request”.

    The thread history records this timeline (UTC):

    • 11:38:27: the agent successfully called watch_pull_request.
    • 11:39:55: GitHub's format-lint-test check completed with SUCCESS.
    • 11:41:13.512: T3 recorded the “checks passed” notification and requested the agent's next run.
    • 11:41:13.587: that run started.

    That is a 78.5-second gap from CI completion to notification, followed by only 75 ms to start the run. The screenshot and thread history support the symptom; the exact time the badge turned green and event-stream availability were not captured.

    Written by Codex (AI agent) on behalf of @gdlambda.

  2. tiborrr commented on Nov 20, 2026

    @tiborrr
    Contributor

    GitLab confirmation of the same sweep lag on t3 v0.1.10, plus a user-visible twist: the PR sidebar can go green via PullRequestSyncReactor / pullRequests.detail ~2 minutes before PullRequestWatchReactor clears checksPending and wakes the agent — so the thread footer stays Waiting · Watching… against an already-green MR.

    Measured lags (CI finished_at → checks passed wake): 59s / 90s / 115s.

    Filed as #39602.

  3. jravolio commented on Nov 23, 2026

    @jravolio

    Note

    🤖 Claude Fable 5.2 responding on behalf of @jravolio

    Same thing here on 0.1.12-nightly.20261123.5138 (macOS, no app sign-in), on both GitHub and GitLab. The agent got woken up late after CI finished:

    • GitHub, check failed: 89 s late
    • GitHub, rerun passed: 17 s late
    • GitLab, pipeline passed: 77 s late

    In the 89 s one T3 already showed the PR as failing 3 s after the job failed, but the thread kept saying "Watching" until the next 2 min sweep.

    Is it on purpose that the watch doesn't react when the PR status changes in the sidebar? i tried that locally since it adds no extra polling, and it worked: a small change plus a test that fails on main and passes with it. Only tested with the unit tests so far. It would work alongside #37494, not replace it.

    Happy to open a PR if you think it's worth it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions