Class Settings
java.lang.Object
com.example.adkprtriaging.Settings
Configuration read from environment variables. Mirrors
settings.py in the Python ADK PR
triaging agent, and matches the lazy-accessor style of the sibling ADK Issue Triaging Agent
sample.
Values are exposed as accessor methods (read lazily on each call) rather than
static final fields. This keeps the class loadable in unit tests and adk web agent
loaders without a GITHUB_TOKEN present — only githubToken() throws when
the token is actually required (i.e. right before a network call).
Required variables:
GITHUB_TOKEN— GitHub Personal Access Token withpull_requests:writepermission. Required for both interactive and workflow modes.GOOGLE_API_KEY— Gemini API key. Required for both modes (or set up Vertex AI credentials andGOOGLE_GENAI_USE_VERTEXAI=TRUE).
Optional variables:
OWNER— defaults togoogle.REPO— defaults toadk-java.MODEL— Gemini model used for triaging. Defaults togemini-pro-latest; a Pro model favors classification quality over latency, which suits this low-volume, accuracy-sensitive task. Overridable without a code change.INTERACTIVE—1/truefor interactive mode (asks for confirmation before labeling/commenting),0/falsefor unattended workflow mode. Defaults to interactive when unset.DRY_RUN—1/trueto log intended label/comment changes without calling the GitHub mutation endpoints. Lets you verify the full pipeline (incl. Gemini) without modifying any real pull request. Defaults to off.PULL_REQUEST_NUMBER— the pull request to triage in workflow mode. Populated by the GitHub Actions workflow from the triggering PR.EVENT_NAME— the GitHub event that triggered the workflow (pull_request_target,workflow_dispatch, ...). Logged for diagnostics.CONTRIBUTING_MD_PATH— path to the repository'sCONTRIBUTING.md(defaultCONTRIBUTING.md, resolved against the working directory, which is the repo root in the workflow). Its content is embedded in the agent instruction so the guideline check stays in sync with the repo. Missing file is tolerated (empty content).
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringReads the repository'sCONTRIBUTING.md(path overridable viaCONTRIBUTING_MD_PATH) so the agent can check pull requests against the real contribution guidelines, mirroring the Python agent'sread_file(CONTRIBUTING.md).static @Nullable Stringstatic StringReturns the GitHub token, throwing a clear error if it is not configured.static booleanReturns true if aGITHUB_TOKENis configured, without throwing.static booleanisDryRun()static booleanstatic Stringmodel()Returns the Gemini model used for triaging.static Stringowner()static intparseNumberString(@Nullable String value, int defaultValue) Parses a number from a string, falling back todefaultValueon null/blank/invalid input.static @Nullable Stringstatic Stringrepo()
-
Method Details
-
githubToken
Returns the GitHub token, throwing a clear error if it is not configured. -
hasGithubToken
public static boolean hasGithubToken()Returns true if aGITHUB_TOKENis configured, without throwing. -
owner
-
repo
-
model
Returns the Gemini model used for triaging. Defaults togemini-pro-latest(a Pro model favors classification quality over latency for this low-volume, accuracy-sensitive task) and is overridable via theMODELenvironment variable, so it can be changed without editing source. -
eventName
-
pullRequestNumber
-
isInteractive
public static boolean isInteractive() -
isDryRun
public static boolean isDryRun() -
contributingGuidelines
Reads the repository'sCONTRIBUTING.md(path overridable viaCONTRIBUTING_MD_PATH) so the agent can check pull requests against the real contribution guidelines, mirroring the Python agent'sread_file(CONTRIBUTING.md). Returns an empty string if the file cannot be read (e.g. in unit tests or when the working directory is not the repo root), so callers never need to handle an exception. -
parseNumberString
Parses a number from a string, falling back todefaultValueon null/blank/invalid input. Mirrorsparse_number_stringin the Python utils.
-