Class AdkPrTriagingAgent

java.lang.Object
com.example.adkprtriaging.AdkPrTriagingAgent

public final class AdkPrTriagingAgent extends Object
ADK Pull Request (PR) Triaging Agent for google/adk-java.

This is the Java port of the Python adk_pr_triaging_agent/agent.py, adapted to the actual label taxonomy of google/adk-java. The Python agent applies one of ten adk-python component labels (e.g. services, models, mcp); those labels do not exist in adk-java, so — exactly as the sibling ADK Issue Triaging Agent does — this port classifies PRs with adk-java's own labels (see ALLOWED_LABELS).

The agent uses Gemini to:

  • recommend a single topic/kind label for each open pull request (e.g. bug, enhancement, documentation),
  • check the PR against the repository's contribution guidelines and, when it falls short, post a single, polite comment asking the author for the missing context.

All GitHub access goes through the shared GitHubTools (backed by the org.kohsuke:github-api client) that this sample reuses with the ADK Issue Triaging Agent and the ADK Docs Release Analyzer. Tool methods are exposed as FunctionTools and use snake_case via Annotations.Schema so the function declarations seen by the model match the Python implementation. Each tool returns an ImmutableMap envelope — {"status": "success", ...} on success, {"status": "error", "message": "..."} on failure — matching the Python contract.

  • Field Details

    • ALLOWED_LABELS

      public static final com.google.common.collect.ImmutableSet<String> ALLOWED_LABELS
      The set of labels the agent is allowed to apply to a pull request. These are real labels in google/adk-java. adk-python uses ten per-component labels that do not exist in adk-java, so this is a flat allowlist of topic/kind labels adapted to adk-java's taxonomy (the same approach the ADK Issue Triaging Agent takes).

      Insertion order is preserved (via ImmutableSet) for deterministic enumeration.

    • LABEL_GUIDELINES

      public static final String LABEL_GUIDELINES
      Label rubric used in the agent's system instruction. Describes the real google/adk-java labels so the model classifies PRs using labels that exist in the repo.
      See Also:
    • ROOT_AGENT

      public static final LlmAgent ROOT_AGENT
      Exposed for adk web / dev-UI agent loaders that look up a public static final BaseAgent ROOT_AGENT field on the class.
  • Method Details

    • rootAgent

      public static LlmAgent rootAgent()
      Builds the LlmAgent. Safe to call at class-init time: it only reads Settings accessors that never throw (no GITHUB_TOKEN is required to construct the agent), so the ROOT_AGENT field and adk web agent loaders work without a token configured.
    • getPullRequestDetails

      public static com.google.common.collect.ImmutableMap<String,Object> getPullRequestDetails(int prNumber)
      Fetches the details of the specified pull request via the shared GitHubTools. Returns the {"status": "success", "pull_request": {...}} envelope on success.
    • addLabelToPr

      public static com.google.common.collect.ImmutableMap<String,Object> addLabelToPr(int prNumber, String label)
      Adds the specified label to a pull request, validating it is on the allowlist.
    • addCommentToPr

      public static com.google.common.collect.ImmutableMap<String,Object> addCommentToPr(int prNumber, String comment)
      Posts the specified comment on a pull request.