Save a review when a label is added
Use a verified webhook to queue an agent review when a label is added.
Save the script next to the configuration from Installation and run it with Node.js. It receives verified label events and publishes review jobs; the worker runs the agent separately.
This example produces a JSON report in <repository>/.outpost/reviews/, not a GitHub comment. Prepare a local clone containing the pull request’s base and head commits. Set REVIEW_REPOSITORY to its owner/repository name, update the allowed actor in webhook-source.ts, then configure the webhook and start both processes. The worker prints the report path. Add GitHub publication later with its own persistent deduplication.
Download all files. Extract into a dedicated directory, run npm install, then adapt outpost.config.ts using Installation. The commands below identify the scripts to run.
Write the script
Section titled “Write the script”Save the files shown in the tabs in the same directory, next to the outpost.config.ts from Installation. Start the HTTP server with server.ts and the worker with worker.ts. The configuration’s repository is a local clone of the reviewed GitHub repository.
Validate the queue input and verdict, and provide the GitHub operations for your application.
The explicit schema in verdict-schema.ts describes the input JSON injected into the prompt; verdict.ts validates the returned answer.
Import this schema in verdict.ts so automatic instructions describe the expected answer; the existing validation function continues to check its content.
Run the reviewer on the requested commit and save its verdict through a dependent task.
Save the workflow state and run the queue worker.
Run the script
Section titled “Run the script”Start the HTTP server and the queue worker in separate terminals. Give the server the webhook secret configured in GitHub; the worker consumes the review jobs it publishes.
Point the repository’s webhook at the server’s /github path through an HTTPS proxy, with the same secret and the “Pull requests” event.
Understand the steps
Section titled “Understand the steps”The runId names the head commit. Adding the label again on the same commit restores the finished run from its checkpoint, so the completed tasks are reused; a new commit starts a new review. The local receipt also detects a conflicting repeated write.
review returns only .value: checkpoints hold JSON, not the methods of a dispatch result (From a task to a workflow).
Adapt the example
Section titled “Adapt the example”GitLab merge requests
Section titled “GitLab merge requests”For GitLab, use createGitlabWebhook({ signingToken }) and authorize gitlab:<username> actors. Adapt the input resolver: the event names a target branch, while this example requires a verified base commit ID available in the local clone. Passing the branch name to requireCommits is rejected.
A Slack command
Section titled “A Slack command”Add a /slack route with createSlackSource({ signingSecret }) and commandIssued(event, "/review"), whose text names the pull request. Slack carries no commits: add a trusted resolver for { repository, number }, obtain and prepare the base and head commits, then build the review input. The existing requireCommits only checks local commits.
A Redis queue
Section titled “A Redis queue”Replace createSqliteTaskQueue() in the queue configuration with createBullMQTaskQueue() to run the server and workers on separate machines. Several worker machines also need a shared checkpoint store (S3 and R2).
Approve before saving or publishing
Section titled “Approve before saving or publishing”Insert an approval gate between review and post. The job then completes as paused, with the pending gate in its value; submit the decision to the same run as shown in Job queues and workers.
Limits
Section titled “Limits”- The worker reviews the clone named by
repository; mappull.repositoryto a clone to serve several repositories. - “Do not edit files” is an instruction to the agent. Its review branch is never merged or pushed; delete
outpost/review-*branches when you no longer need them. - A crashed worker can run
postagain: the providedsaveVerdictdeduplicates on its key (Job queues and workers).
API: serveTriggers · createGithubWebhook · labelAdded · createSqliteTaskQueue · runQueueWorker · defineWorkflowJob · defineIsolatedTask · defineJsonResponse.

