Repository navigation
Run the PR risk classifier with pi instead of Claude Code - #29
Merged
Merged
Conversation
Contributor
Author
|
Picked tnsardesai to review: touched the changed code in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Moves the reusable
pr-risk.ymlclassifier from Claude Code CLI to pi (@earendil-works/pi-coding-agent), following the org pattern: Node 22,PI_PREFERRED_MODEL, and Anthropic/OpenAI keys.This is a read-only workflow (it only comments), so the credential split stays the same. Only the agent invocation changes.
--no-tools --no-mcp --no-extensions --no-skills --no-prompt-templates --no-context-files --no-approve --no-session. Its only credentials are the LLM keys. The kernel-internal token is still minted after the model finishes.--json-schema, so the prompt now asks for one JSON object with exactly the five keys. A newpr_risk.py verdictstep reads pi's--mode jsonevent stream and writes the sameresult.jsonenvelope Claude Code produced (is_error/result/structured_output). It checks the reply strictly againstVERDICT_SCHEMA: required keys, types, enums, and no extra keys. Provider errors, truncated replies, non-JSON and off-schema replies all becomeis_error: true, which the unchangedparse_verdict/commentpath already renders as "Not assessed". The comment format and thepr-risk:v1marker do not change.modelinput, defaulting to${{ vars.PI_PREFERRED_MODEL }}. It replacesvars.CLAUDE_CODE_PREFERRED_MODEL. An empty model fails the step with a clear message instead of falling back to a CLI default.OPENAI_API_KEYis added, and both LLM keys are now optional, so callers pass the key for their model's provider. MakingANTHROPIC_API_KEYoptional keeps existing callers valid.--max-budget-usd 1has no pi equivalent. Thinking is set tohighrather thanmaxto keep a one-shot classification of a PR under 50 lines cheap. A local run cost about $0.02.Caller changes required
PI_PREFERRED_MODELcurrently resolves to an OpenAI model. Until callers passOPENAI_API_KEY, eligible PRs will get "Not assessed" or a failed classify job. These callers need a one-line addition, merged after this PR. Before then, passing an undeclared secret is a workflow error..github/workflows/pr-risk.yml.github/workflows/pr-risk.yml.github/workflows/pr-risk.yml.github/workflows/pr-risk.ymlValidation
actionlint(v1.7.7) onpr-risk.ymlandpr-risk-tests.yml: clean, includingvarsin theworkflow_callinput default.python -m unittestforscripts/test_pr_risk.py: 18 tests pass. New tests cover:lengthstop, missing reply, non-JSON, extra/missing keys, wrong types, bad enums;comment;Classifystep script against a fakepi: stdin, cwd,--model, system prompt,result.json, and the empty-model failure.--no-tools, disabling the extra-key check, or breaking the events path each fails a test.test_breakglass.pyandtest_vuln_remediation.pystill pass.openai/gpt-5.6-sol, using a fresh HOME, on two real small merged infra PRs gathered withpr_risk.py gather. Both produced valid verdicts, and both were denied, consistent with the existing comments on those PRs. A bad API key producedis_error: truewith the provider's 401 message.Not run:
workflow_callonly, triggered by caller PRs.Unverified: org secret/variable visibility for the four caller repos. I couldn't list org secrets/variables with the available permissions.
PI_PREFERRED_MODEL's value was read from another repo's workflow log.