# I Built gh-lookout to Wait for GitHub Actions CI Without Hitting API Limits

Date: 2026-12-06
Updated: 2026-12-06
Tags: rust, lean, github-actions, ci, ai-agent, cloudflare, formal-verification, release, gh-lookout, lean-leanfran, lean-leanassay
URL: https://s.conao3.com/blog/2026/abbc02
Author: conao3 (Naoya Yamashita)

Multiple AI agents working in parallel stack up `gh run watch` calls after each push.
As shown in its [source](https://github.com/cli/cli/blob/v2.105.0/pkg/cmd/run/watch/watch.go#L231-L241), `gh run watch` makes two API requests at 3-second intervals by default, consuming 2,400 requests per hour per agent.

Three agents waiting at once reach 7,200 requests per hour, passing the [5,000-request hourly REST API limit](https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api) for signed-in users.
I built gh-lookout, a `gh` extension that receives GitHub webhooks on the public service [lookout.conao3.com](https://lookout.conao3.com/) and notifies your CLI.

You run no local daemon and make zero API requests while waiting.
Even on external open-source repositories where you cannot install the GitHub App, the same `gh lookout wait` command works.

The source lives at [conao3/gh-lookout](https://github.com/conao3/gh-lookout) under the [Apache-2.0](https://github.com/conao3/gh-lookout/blob/v0.2.0/LICENSE) license.
This post walks through usage and architecture based on [v0.2.0](https://github.com/conao3/gh-lookout/releases/tag/v0.2.0).

[conao3/gh-lookout](https://github.com/conao3/gh-lookout): Wait for GitHub Actions from the command line

# Zero API Requests While Waiting

Three agents waiting for CI for one hour make 7,200 REST API requests with `gh run watch` versus 0 with `gh lookout wait`.
The chart below comes from the [lookout.conao3.com](https://lookout.conao3.com/) home page.

![img](https://s.conao3.com/img/bc0993-relay-chart.png)

gh-lookout runs on three parts: GitHub, the hosted service [lookout.conao3.com](https://lookout.conao3.com/), and the local `gh lookout` CLI.

![img](https://s.conao3.com/img/abbc02-architecture.svg)

# Usage

Install gh-lookout as a `gh` CLI extension.
On Nix, you can also run `nix run github:conao3/gh-lookout -- --help`.

```sh
gh extension install conao3/gh-lookout
gh lookout login
```

Running `gh lookout login` prints a URL and verification code for you to approve in your browser.
Because authentication opens no local port, it works over SSH sessions and inside containers.

For your own repositories or organizations, install the public [gh-lookout](https://github.com/apps/gh-lookout/installations/new) GitHub App on that account.
After that, pass a repository and commit SHA to wait.

```sh
gh lookout wait conao3/gh-lookout 5f15b63
```

Once CI finishes, the command prints each workflow's conclusion and URL.

    conao3/gh-lookout 5f15b63 success
      CI success https://github.com/conao3/gh-lookout/actions/runs/47608418024

The command exits with 0 if all workflows pass, 1 on failure, and 3 when the commit has no CI.
Pass `--json` if a script needs structured output.

Run `gh lookout status` to list recent commits.

```sh
gh lookout status conao3/gh-lookout
```

# How It Works

The hosted service [lookout.conao3.com](https://lookout.conao3.com/) runs on Cloudflare Workers and Durable Objects.
For repositories with the public [gh-lookout](https://github.com/apps/gh-lookout) GitHub App installed, Lookout receives `workflow_run` webhooks from GitHub and saves the run state.

Lookout tracks commits by SHA instead of pull requests, so direct pushes to `master` work the same way.

Running `gh lookout wait` opens a WebSocket connection that sleeps through the Durable Objects WebSocket Hibernation API.
Idle connections incur zero duration charges and wake the moment the next webhook arrives.

If a network blip drops the socket, the CLI reconnects with the remaining timeout.
Before returning results for a private repository, Lookout verifies read access with your GitHub OAuth token so unauthorized accounts see nothing.

# External OSS Repositories

You can install the GitHub App on your own account, not on third-party open-source repositories where you contribute.
gh-lookout detects whether the App is installed on the target repository and switches uninstalled public repositories to server-side polling.

```sh
gh lookout wait clojure-lsp/clojure-lsp 2ecf241
```

    clojure-lsp/clojure-lsp 2ecf241 success
      CI success https://github.com/clojure-lsp/clojure-lsp/actions/runs/47556737140

Server-side polling keeps rate-limit usage low:

-   Concurrent clients waiting on the same commit share a single server-side poll loop.
-   Lookout caches each response `ETag` so `304 Not Modified` replies consume no rate limit.
-   The poll interval steps through 15, 30, and 60 seconds and stops as soon as the last waiting CLI disconnects.

Requests use the waiting user's own GitHub OAuth token, covering public repositories.
Uninstalled private repositories remain inaccessible.

Pull requests from external forks can pause in `action_required` pending maintainer approval.
Upon seeing that state, gh-lookout returns exit code 5 instead of waiting for timeout.

After a maintainer approves the run, running `gh lookout wait` again fetches fresh state and resumes normal waiting.

# Commit Verdicts in Lean 4

Deciding commit completion across parallel workflows involves several overlapping rules.
You must ignore older rerun attempts, distinguish running jobs from approval waits, and wait 30 seconds after a workflow finishes for follow-up runs to start.

I wrote the three core functions in Lean 4 in [lean/Lookout/Model.lean](https://github.com/conao3/gh-lookout/blob/v0.2.0/lean/Lookout/Model.lean) and compiled them to TypeScript for the Cloudflare Worker with [leanfran](https://s.conao3.com/blog/2026/21ebbd).

-   `latest` keeps the newest attempt for each run ID.
-   `verdict` computes pending, succeeded, failed, action-required, or no-CI from the latest attempts and elapsed time.
-   `passedConclusion` treats `success`, `skipped`, and `neutral` as passing.

The `verdict` function takes this form:

```lean
def verdict (runs : List Run) (now waitStart lastEvent settle noCiAfter : Nat) : Verdict :=
  let rs := latest runs
  if rs.isEmpty then
    if waitStart + noCiAfter ≤ now then .noCi else .pending
  else if !(rs.all (fun r => r.completed || r.actionRequired)) then .pending
  else if rs.any (·.actionRequired) then .actionRequired
  else if now < lastEvent + settle then .pending
  else if rs.all (·.passed) then .succeeded
  else .failed
```

I proved specification theorems for each of the three functions and audited them with mutation testing in [leanassay](https://s.conao3.com/blog/2026/e3d3ca).
In `v0.2.0`, the theorems killed all 31 non-equivalent mutants out of 36 generated (5 equivalent, 0 holes).

Lean 4 proves the decision logic that turns collected runs into a commit verdict.
TypeScript and Rust handle Durable Object storage, WebSockets, GitHub API calls, and CLI reconnection, verified by unit and integration tests.

# Pricing and Scope

The hosted service [lookout.conao3.com](https://lookout.conao3.com/) gives each account 500 completed runs per week for free without delay.
Lookout counts completed runs that you wait on and avoids double-counting repeated waits on the same attempt.

To help cover Cloudflare Workers costs, I cap the free tier and invite support through [GitHub Sponsors](https://github.com/sponsors/conao3).
Runs beyond 500 in a week arrive 10 minutes late until the Monday 00:00 UTC reset, while sponsor accounts have no delay.

gh-lookout targets GitHub Actions `workflow_run` events, so repositories using external CI such as CircleCI or Buildkite report no CI.
Private repositories require installing the [gh-lookout GitHub App](https://github.com/apps/gh-lookout).

Command flags and account management are in the [README](https://github.com/conao3/gh-lookout) and on your [account page](https://lookout.conao3.com/account).
