Skip to content

perf: orchestrator should batch PR state queries into single GraphQL call #131

@microsasa

Description

@microsasa

Problem

The pipeline orchestrator makes 5-6 serial API calls per PR (merge state, review decision, reviews list, CI status, thread query), each requiring an LLM round-trip. A single run takes 10+ minutes for one PR.

Fix

Add a single batched GraphQL query to the orchestrator instructions that fetches everything in one call:

query($owner: String!, $name: String!, $label: String!) {
  repository(owner: $owner, name: $name) {
    pullRequests(first: 10, states: OPEN, labels: [$label]) {
      nodes {
        number
        headRefName
        mergeStateStatus
        reviewDecision
        autoMergeRequest { enabledAt }
        labels(first: 10) { nodes { name } }
        reviews(first: 10) { nodes { author { login } state } }
        reviewThreads(first: 100) {
          nodes {
            id
            isResolved
            comments(last: 1) { nodes { author { login } } }
          }
        }
        commits(last: 1) {
          nodes {
            commit {
              statusCheckRollup {
                contexts(first: 20) {
                  nodes {
                    ... on CheckRun { name conclusion }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

One call, all data. The agent reasons about the result instead of making serial tool calls.

Impact

Should reduce orchestrator runtime from 10+ minutes to 2-3 minutes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    backlogLow priority — not planned for immediate work

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions