feat: give context on previous reviews for successive review requests #263

Merged
davide merged 6 commits from feat/successive-review-context into main 2026-09-12 12:45:44 +00:00
Member

Closes #165

When the agent is assigned as a reviewer again on a pull request it has already reviewed, it now gets the full history of its previous reviews in the prompt:

  • Previous reviews — author, verdict (state), reviewed commit, and summary body.
  • Inline review comments — path, line, author, and body for each comment.

The prompt also instructs the agent to check the current code against each previously raised issue: acknowledge the ones that are fixed, re-raise the ones still open, and look for new issues introduced since the last review.

Changes

  • src/schemas.ts — extended prReviewSchema and prReviewCommentSchema with author, verdict, commit, timestamps, path and line; added prReviewWithCommentsSchema.
  • src/forgejo/index.ts — added getPrReviewsWithComments() which fetches all PR reviews together with their inline comments.
  • src/context.ts — fetches previous reviews (with comments) on pull_request_review_requested events and exposes them in the event context.
  • src/prompt.ts — renders the previous reviews section and adds successive-review guidance when previous reviews exist.
Closes #165 When the agent is assigned as a reviewer again on a pull request it has already reviewed, it now gets the full history of its previous reviews in the prompt: - **Previous reviews** — author, verdict (`state`), reviewed commit, and summary body. - **Inline review comments** — path, line, author, and body for each comment. The prompt also instructs the agent to check the current code against each previously raised issue: acknowledge the ones that are fixed, re-raise the ones still open, and look for new issues introduced since the last review. ## Changes - `src/schemas.ts` — extended `prReviewSchema` and `prReviewCommentSchema` with author, verdict, commit, timestamps, path and line; added `prReviewWithCommentsSchema`. - `src/forgejo/index.ts` — added `getPrReviewsWithComments()` which fetches all PR reviews together with their inline comments. - `src/context.ts` — fetches previous reviews (with comments) on `pull_request_review_requested` events and exposes them in the event context. - `src/prompt.ts` — renders the previous reviews section and adds successive-review guidance when previous reviews exist.
feat: give context on previous reviews for successive review requests
All checks were successful
check-commitizen.yaml / Check the PR title (pull_request) Successful in 2s
check-formatter.yaml / Checks with formatters (pull_request) Successful in 9s
check-linter.yaml / Checks with linters (pull_request) Successful in 9s
check-prettier.yaml / Check files formatting (pull_request) Successful in 3s
check-yamllint.yaml / Lint yaml files (pull_request) Successful in 3s
check-syntax.yaml / Checks with static tools (pull_request) Successful in 8s
forgejo-agent / LLM Bot response generation (pull_request) Successful in 2s
b2071e632b
Owner

TODO: getPrReviews should skip reviews that are pending, since they don't add value.

TODO: getPrReviews should skip reviews that are pending, since they don't add value.
Owner

@ci-bot in the main branch there was some work and now there's a testing infrastrucure that has been set up. Can you get this up to date with its own tests?

For integration tests, you can write, but not run them since you don't have access to a testing forgejo instance. I will verify them in a following review.

@ci-bot in the main branch there was some work and now there's a testing infrastrucure that has been set up. Can you get this up to date with its own tests? For integration tests, you can write, but not run them since you don't have access to a testing forgejo instance. I will verify them in a following review.
feat: skip pending reviews and add tests for successive review context
All checks were successful
check-formatter.yaml / Checks with formatters (pull_request) Successful in 5s
check-linter.yaml / Checks with linters (pull_request) Successful in 10s
check-prettier.yaml / Check files formatting (pull_request) Successful in 3s
check-yamllint.yaml / Lint yaml files (pull_request) Successful in 3s
check-syntax.yaml / Checks with static tools (pull_request) Successful in 8s
92b3c9e704
- getPrReviews now filters out PENDING reviews (drafts carry no verdict)
- add unit tests for the review schemas, prompt rendering, context
  assembly and the pending-review filtering
- add integration tests for getPrReviewsWithComments and the review
  context (to be run against a real Forgejo instance)
Author
Member

Done — the branch is now up to date with main and has its own tests.

Changes

1. Pending reviews skipped (TODO from review)
getPrReviews now filters out reviews with state === "PENDING" — drafts carry no verdict, so they add no value to the review history. getPrReviewsWithComments inherits this, so it never fetches comments for pending reviews.

2. Merged main and adapted the feature
The branch was rebased onto the current main (ApiContext refactor, search tools, vitest infrastructure). The feature was adapted to the new structure:

  • getPrReviewsWithComments(apiCtx, repo, prId) follows the new client signature
  • extended prReviewSchema / prReviewCommentSchema and prReviewWithCommentsSchema kept
  • context fetches reviews only on pull_request_review_requested events

3. Unit tests (all passing — 54 tests)

  • src/test/unit/forgejo.test.ts (new) — pending-review filtering and getPrReviewsWithComments composition (mocks forgejoFetch)
  • src/test/unit/schemas.test.ts — review/comment/with-comments schemas
  • src/test/unit/prompt.test.ts — successive-review guidance and previous-reviews rendering (incl. comment without line)
  • src/test/unit/context.test.ts — reviews fetched on review requests, not on other events
  • src/test/fixtures.ts — added mockReview and mockReviewRequestedEventCtx

4. Integration tests (written, not run — no Forgejo instance here)

  • src/test/integration/forgejo.test.ts — getPrReviewsWithComments returns reviews with their inline comments; pending reviews are skipped (posted via raw forgejoFetch since postPrReview only accepts submitted events)
  • src/test/integration/context.test.ts — getEventContext includes previous reviews with comments on a review request

5. README — documented the successive-review feature.

Verified locally: pnpm check, pnpm lint:check, pnpm format:check, pnpm test:unit, pnpm build all pass. The integration tests are ready for you to verify against the real instance.

Done — the branch is now up to date with `main` and has its own tests. ## Changes **1. Pending reviews skipped (TODO from review)** `getPrReviews` now filters out reviews with `state === "PENDING"` — drafts carry no verdict, so they add no value to the review history. `getPrReviewsWithComments` inherits this, so it never fetches comments for pending reviews. **2. Merged `main` and adapted the feature** The branch was rebased onto the current `main` (ApiContext refactor, search tools, vitest infrastructure). The feature was adapted to the new structure: - `getPrReviewsWithComments(apiCtx, repo, prId)` follows the new client signature - extended `prReviewSchema` / `prReviewCommentSchema` and `prReviewWithCommentsSchema` kept - context fetches reviews only on `pull_request_review_requested` events **3. Unit tests (all passing — 54 tests)** - `src/test/unit/forgejo.test.ts` (new) — pending-review filtering and `getPrReviewsWithComments` composition (mocks `forgejoFetch`) - `src/test/unit/schemas.test.ts` — review/comment/with-comments schemas - `src/test/unit/prompt.test.ts` — successive-review guidance and previous-reviews rendering (incl. comment without line) - `src/test/unit/context.test.ts` — reviews fetched on review requests, not on other events - `src/test/fixtures.ts` — added `mockReview` and `mockReviewRequestedEventCtx` **4. Integration tests (written, not run — no Forgejo instance here)** - `src/test/integration/forgejo.test.ts` — `getPrReviewsWithComments` returns reviews with their inline comments; pending reviews are skipped (posted via raw `forgejoFetch` since `postPrReview` only accepts submitted events) - `src/test/integration/context.test.ts` — `getEventContext` includes previous reviews with comments on a review request **5. README** — documented the successive-review feature. Verified locally: `pnpm check`, `pnpm lint:check`, `pnpm format:check`, `pnpm test:unit`, `pnpm build` all pass. The integration tests are ready for you to verify against the real instance.
chore: update prompt
All checks were successful
check-formatter.yaml / Checks with formatters (pull_request) Successful in 9s
check-linter.yaml / Checks with linters (pull_request) Successful in 13s
check-prettier.yaml / Check files formatting (pull_request) Successful in 3s
check-yamllint.yaml / Lint yaml files (pull_request) Successful in 1s
check-syntax.yaml / Checks with static tools (pull_request) Successful in 10s
c057a09241
chore: remove unnecessary schema
All checks were successful
check-formatter.yaml / Checks with formatters (pull_request) Successful in 8s
check-linter.yaml / Checks with linters (pull_request) Successful in 9s
check-prettier.yaml / Check files formatting (pull_request) Successful in 3s
check-yamllint.yaml / Lint yaml files (pull_request) Successful in 3s
check-syntax.yaml / Checks with static tools (pull_request) Successful in 8s
cdf4f3b7b0
chore: add reviewer test user
All checks were successful
check-formatter.yaml / Checks with formatters (pull_request) Successful in 5s
check-prettier.yaml / Check files formatting (pull_request) Successful in 2s
check-linter.yaml / Checks with linters (pull_request) Successful in 12s
check-syntax.yaml / Checks with static tools (pull_request) Successful in 8s
check-yamllint.yaml / Lint yaml files (pull_request) Successful in 3s
ce2f99aca0
davide scheduled this pull request to auto merge when all checks succeed 2026-09-12 12:45:33 +00:00
davide merged commit 536d464b10 into main 2026-09-12 12:45:44 +00:00
davide deleted branch feat/successive-review-context 2026-09-12 12:45:45 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
projects/forgejo-agent!263
No description provided.