[PR #12724] ci: add pr-triage workflow for automatic PR labeling #14340

Open
opened 2026-02-16 18:19:08 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/12724

State: open
Merged: No


What does this PR do?

Adds scope labels to PR's, similar to how it is currently done for issues. This allows for PR filtering / easier search based on scope.

image

A test workflow (.github/workflows/test-pr-triage.yml) is included to run a manual label assignment on a specific PR (input number) via the same agent, pr-triage

How did you verify your code works?

  1. Tests via the test workflow (.yml).
  2. Tests via actual PR's in a fork (copied PR's title, description from opencode repo for testing)

How it works

copied from existing "triage" workflow :

  1. PR opened → GitHub Actions triggers workflow
  2. Workflow runs opencode run --agent pr-triage with the PR title and body
  3. Agent picks labels based on conventional commit scope and content
  4. Tool calls GitHub API to apply labels

How the agent picks labels

Modeled after "triage" agent, with an addition to respect the scope title:

  • Scope in title (strong) — fix(app):web, docs:docs. Prompt says "always add" for known scopes.
  • Body content (weaker) — reads text, matches keywords.

Example: fix(app): crash on startup → agent adds web label.

Files added

File What
.github/workflows/pr-triage.yml Workflow — triggers on pull_request_target: [opened], runs opencode run --agent pr-triage with PR title and body
.github/workflows/test-pr-triage.yml Test workflow — workflow_dispatch, accepts a PR number, fetches PR info via gh, runs same agent
.opencode/agent/pr-triage.md Agent config — haiku model, restricted to only the github-pr-triage tool, with label definitions and scope-to-label mapping
.opencode/tool/github-pr-triage.ts Custom tool — calls POST /repos/{owner}/{repo}/issues/{pr}/labels via GitHub API
.opencode/tool/github-pr-triage.txt Tool description — label definitions, scope-to-label table
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/12724 **State:** open **Merged:** No --- ### What does this PR do? Adds scope labels to PR's, similar to how it is currently done for issues. This allows for PR filtering / easier search based on scope. <img width="538" height="44" alt="image" src="https://github.com/user-attachments/assets/81293e12-edfd-4646-bc3a-f4da6ac006ac" /> A test workflow (.github/workflows/test-pr-triage.yml) is included to run a manual label assignment on a specific PR (input number) via the same agent, pr-triage ### How did you verify your code works? 1. Tests via the test workflow (.yml). 2. Tests via actual PR's in a fork (copied PR's title, description from opencode repo for testing) ### How it works copied from existing "triage" workflow : 1. PR opened → GitHub Actions triggers workflow 2. Workflow runs `opencode run --agent pr-triage` with the PR title and body 3. Agent picks labels based on conventional commit scope and content 4. Tool calls GitHub API to apply labels ## How the agent picks labels Modeled after "triage" agent, with an addition to respect the scope title: - **Scope in title** (strong) — `fix(app):` → `web`, `docs:` → `docs`. Prompt says "always add" for known scopes. - **Body content** (weaker) — reads text, matches keywords. Example: `fix(app): crash on startup` → agent adds `web` label. ### Files added | File | What | |---|---| | `.github/workflows/pr-triage.yml` | Workflow — triggers on `pull_request_target: [opened]`, runs `opencode run --agent pr-triage` with PR title and body | | `.github/workflows/test-pr-triage.yml` | Test workflow — `workflow_dispatch`, accepts a PR number, fetches PR info via `gh`, runs same agent | | `.opencode/agent/pr-triage.md` | Agent config — haiku model, restricted to only the `github-pr-triage` tool, with label definitions and scope-to-label mapping | | `.opencode/tool/github-pr-triage.ts` | Custom tool — calls `POST /repos/{owner}/{repo}/issues/{pr}/labels` via GitHub API | | `.opencode/tool/github-pr-triage.txt` | Tool description — label definitions, scope-to-label table |
yindo added the pull-request label 2026-02-16 18:19:08 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14340