Skip to documentation
Rat Things
Browse documentation
Documentation/Connect a GitHub webhook

Connect a GitHub webhook#

A signed GitHub event starts a Session only when it matches an owned Agent/environment binding. Rat Things keeps webhook verification, repository checkout and terminal Turn notification as separate stages.

Prerequisites#

Deploy the Agents API and execution backend, configure an admitted model, and authenticate the Rat Things CLI as the operator who will own the Sessions. The selected environment must support repository commands. Keep the GitHub webhook, clone and comment credentials separate.

Configure the webhook#

Store a high-entropy signing secret, a repository-read token and a comment-write token in Secrets Manager. Set these Terraform inputs to their ARNs:

  • github_webhook_secret_arn
  • github_clone_token_secret_arn
  • github_notify_token_secret_arn

Set github_comment_trigger to a distinct non-empty trigger for this deployment. Keep repository hosts allowlisted. Apply the deployment configuration using the normal Terraform workflow; secret values must not enter Terraform variables or state.

In the repository's webhook settings, use the deployed webhook_urls.github output, application/json, and the matching signing secret. Select pull-request and issue-comment events. Keep separate hooks, secrets and destinations for development and production.

Bind the repository to an Agent#

Create an Agent with the model, instructions and tools appropriate for repository review. Create an environment template with the required packages and network access. Save a binding with those returned IDs as github-binding.json:

{
  "version": "1",
  "sourceKind": "github",
  "selector": { "repository": "OWNER/REPOSITORY" },
  "eventPolicy": {
    "mode": "explicit",
    "actors": { "allow": ["github:YOUR_LOGIN", "github:dependabot[bot]"] }
  },
  "agentId": "agent_example",
  "environment": {
    "type": "openai_hosted",
    "environment_template_id": "envtpl_example"
  }
}
rat-things bind-source --file github-binding.json
rat-things source-bindings

openai_hosted is the standard wire name for a managed environment. On this endpoint, Rat Things provisions that environment in your AWS account. The authenticated operator owns the binding and resulting Sessions. Generic repository selectors are trusted operator configuration; they do not independently prove repository ownership.

Replace the allowlist with the people and bots allowed to submit work. It restricts both review events and comments. Comments require an allowlist even when they contain the trigger or continue a subscribed thread. Omitting the allowlist keeps automatic reviews enabled but disables comments. Bot comments are always ignored; bot-authored PRs can still trigger reviews. For an existing binding, replace its event policy without recreating subscriptions.

A notification destination does not give the Agent GitHub write tools. Declare any desired agent-callable operations separately on the Agent, with their own credentials and grants.

Trigger the first response#

Opening, reopening or updating a pull request, or marking it ready for review, submits a review. A newly created pull-request comment containing the configured trigger starts a question when its author is allowlisted. Once the thread has an active subscription, allowlisted authors can continue it without repeating the trigger. Other signed event types are acknowledged and ignored. See event policies to filter unsolicited comments before starting work.

The accepted receipt contains a Session ID. Inspect that Session's Turns and Items with the standard API or CLI. The saved terminal root Turn supplies the result comment; worker exit alone does not trigger another reply. Repeated delivery IDs are deduplicated. Comments on the same pull request continue its active Session. A changed head starts a new review Session with the new checkout and transfers the thread subscription. Releasing the thread, deleting its Session, or reaching the input limit also makes the next accepted event start a new Session. See thread ownership.

Credential handling#

The verifier reads only the signing secret. Trusted checkout uses the repository-read token; terminal Turn delivery uses the notification token. Tokens never belong in clone URLs, bindings, Agent instructions or webhook bodies. The current clone adapter consumes a configured token; it does not mint GitHub App installation tokens from the event's installation ID.

Troubleshooting#

  • A signed ping returns 202 with ignored: true; it does not execute an Agent.
  • source_not_bound means no verified source selector matched an Agent/environment binding.
  • event_policy means the binding rejected the input. For comments, check the author's exact github:<login> allowlist entry and any deny rule.
  • 401 means signature verification failed. Check the configured secret and exact raw body.
  • A failed Turn needs inspection through Session Items and worker diagnostics. A completed Turn with no comment needs delivery-fence and notification-credential inspection.
  • An ambiguous comment outcome needs provider reconciliation before another write is attempted.

See channel adapters for accepted event shapes and deployment controls.