diff --git a/pr-review/README.md b/pr-review/README.md
index 3c46dad..ba2b874 100644
--- a/pr-review/README.md
+++ b/pr-review/README.md
@@ -98,6 +98,7 @@ Input parameters for the action:
| `prompt` | The base prompt that is used to generate the review.
Default: See [action.yml](action.yml#L36-L43) |
| `prompt-addition` | The addition to the base prompt that is used to generate the review. |
| `disclaimer-prompt` | The prompt that is used to generate the disclaimer.
Default: See [action.yml](action.yml#L51-L53) |
+| `summary-prompt` | The prompt that is used to generate the summary shown in the review body.
Default: `Append a brief summary of the key review findings. No lists, no headings.` |
| `header-text` | Text to be inserted before the review. |
| `footer-text` | Text to be inserted after the review. |
| `previous-results` | Define what to do with previous results. Possible values are `keep` or `hide`.
Default: `keep` |
@@ -114,11 +115,12 @@ Input parameters for the action:
Output parameters for the action:
-| Name | Description |
-| ---------- | --------------------------------------- |
-| `comments` | An array of review comments for the PR. |
-| `reviewId` | The ID of the created GitHub PR review. |
-| `review` | The created GitHub PR review. |
+| Name | Description |
+| ---------- | --------------------------------------------------------- |
+| `comments` | The AI-generated review comments as a JSON array. |
+| `reviewId` | The ID of the created GitHub PR review. |
+| `review` | The full GitHub PR review object returned by the API. |
+| `summary` | The AI-generated summary text used in the PR review body. |
## Advanced Examples
@@ -206,6 +208,20 @@ jobs:
### Influence the Display Mode
+#### Customize the review summary:
+
+The `summary-prompt` parameter controls how the review body text is generated. The action runs a separate AI call with this prompt and the review findings as input.
+
+To add static content around it, see [Add a header or footer](#add-a-header-or-footer).
+
+```yaml
+- uses: ai-assisted-actions/pr-review@v2
+ with:
+ model: gpt-5.4
+ summary-prompt: |
+ Summarize the findings in bullet points, grouped by severity.
+```
+
#### Add a header or footer:
```yaml
@@ -254,7 +270,7 @@ jobs:
```yaml
- uses: SAP/ai-assisted-github-actions/pr-review@v3
with:
- model: anthropic--claude-3.5-sonnet
+ model: anthropic--claude-4.6-opus
```
- The `model` parameter can be set to the executable ID of the [available generative AI models](https://me.sap.com/notes/3437766/E).
diff --git a/pr-review/action.yml b/pr-review/action.yml
index 30a89c5..9c264ee 100644
--- a/pr-review/action.yml
+++ b/pr-review/action.yml
@@ -50,6 +50,9 @@ inputs:
default: |
Create a kind alternative for the following term: Here's a helpful review of your code with support from AI. Some insights are predictions, not guaranteed facts, so feel free to use what works best for you. Your decisions lead the way—AI is just here to assist.
Do not use more than 80 words. Do not use quotation marks.
+ summary-prompt:
+ description: "Prompt used to generate a summary of review findings in the review body. When not set, the LLM is called with only the disclaimer prompt (no review comments are sent)."
+ required: false
display-mode:
description: "Defines where the review will be posted (`review-comment`, `review-comment-delta`, or `none`)."
@@ -105,8 +108,14 @@ inputs:
default: "${{ github.api_url }}"
outputs:
+ comments:
+ description: "The AI-generated review comments as a JSON array."
reviewId:
description: "The ID of the created GitHub PR review."
+ review:
+ description: "The full GitHub PR review object returned by the API."
+ summary:
+ description: "The AI-generated summary text used in the PR review body."
runs:
using: node20
diff --git a/pr-review/src/config.ts b/pr-review/src/config.ts
index 7f486c3..cfbc57e 100644
--- a/pr-review/src/config.ts
+++ b/pr-review/src/config.ts
@@ -137,6 +137,9 @@ export const config = {
/** The prompt to use for the disclaimer. */
disclaimerPrompt: parseInput(z.string(), "disclaimer-prompt"),
+ /** The prompt to use for the summary. When empty, review comments are not sent to the LLM. */
+ summaryPrompt: parseInput(z.string(), "summary-prompt"),
+
/** The text that is placed before the review. */
headerText: parseInput(z.string(), "header-text"),
diff --git a/pr-review/src/main.ts b/pr-review/src/main.ts
index 96dfb61..0d4444a 100644
--- a/pr-review/src/main.ts
+++ b/pr-review/src/main.ts
@@ -165,10 +165,16 @@ export async function run(config: Config): Promise {
)
}
- core.startGroup(`Ask LLM for a disclaimer text to add to the review description`)
- const disclaimer = await aiCoreClient.chatCompletion([{ role: "user", content: config.disclaimerPrompt }])
- core.info(inspect(disclaimer, { depth: undefined, colors: true }))
- core.setOutput("disclaimer", disclaimer)
+ core.startGroup(`Ask LLM for a summary to add to the review description`)
+ const summary = await aiCoreClient.chatCompletion([
+ {
+ role: "system",
+ content: [config.disclaimerPrompt, config.summaryPrompt].join("\n\n"),
+ },
+ ...(config.summaryPrompt ? [{ role: "user" as const, content: `Review findings:\n${JSON.stringify(comments.map(({ path, body }) => ({ path, body })))}` }] : []),
+ ])
+ core.info(inspect(summary, { depth: undefined, colors: true }))
+ core.setOutput("summary", summary)
core.startGroup(`Create a PR review as comment with the generated comments`)
const baseheadMaker = ``
@@ -180,8 +186,8 @@ export async function run(config: Config): Promise {
`Completion Tokens: ${aiCoreClient.getCompletionTokens()}`,
base !== pullRequest.base.sha || head !== pullRequest.head.sha ? `Diff Range: ${base.slice(0, 7)}...${head.slice(0, 7)}` : "",
]
- const modelMetadataFooter = config.showModelMetadataFooter ? `${metadata.filter(Boolean).join(" | ")}` : ""
- const displayText = [markerStart, baseheadMaker, header, disclaimer, footer, modelMetadataFooter, markerEnd].filter(Boolean).join("\n")
+ const modelMetadataFooter = config.showModelMetadataFooter ? `\n${metadata.filter(Boolean).join(" | ")}` : ""
+ const displayText = [markerStart, baseheadMaker, header, summary, footer, modelMetadataFooter, markerEnd].filter(Boolean).join("\n")
type CreateReviewParameter = Parameters[0]
const review: CreateReviewParameter = { ...repoRef, pull_number: config.prNumber, commit_id: head, event: "COMMENT", body: displayText, comments }