~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
ci(ai-review): auto-run on every push to non-draft PRs (#4554)
LearningCircuit61f4b9cdaa8a
diff --git a/.github/workflows/ai-code-reviewer.yml b/.github/workflows/ai-code-reviewer.ymlindex a658f35b54..9c9680762b 100644--- a/.github/workflows/ai-code-reviewer.yml+++ b/.github/workflows/ai-code-reviewer.yml@@ -2,13 +2,16 @@ name: AI Code Revieweron:pull_request:- types: [opened, labeled]+ types: [opened, synchronize, ready_for_review, labeled]-# No concurrency group — intentionally omitted.-# Previous attempt (#3554, reverted #3599) used cancel-in-progress which-# killed in-progress PR runs before they produced useful results.-# Future iteration could safely add concurrency for scheduled/push-only-# triggers (where head_ref is empty and runs get unique groups).+# Per-PR concurrency with cancel-in-progress: a new push (synchronize) cancels+# the now-stale review of the previous commit, which also bounds token spend on+# rapid pushes. Keyed on the PR number so runs for *different* PRs never cancel+# each other — that repo-wide cancellation was the problem in the earlier+# attempt (#3554, reverted #3599), not per-PR cancellation.+concurrency:+ group: ai-code-review-${{ github.event.pull_request.number }}+ cancel-in-progress: truepermissions: {} # Minimal top-level for OSSF Scorecard Token-Permissions@@ -18,7 +21,12 @@ jobs:runs-on: ubuntu-latesttimeout-minutes: 30environment: ci- if: github.event.action == 'opened' || (github.event.action == 'labeled' && github.event.label.name == 'ai_code_review')+ # Auto-review on open / push / ready-for-review, but only for non-draft PRs+ # so work-in-progress drafts don't burn a review on every WIP push.+ # The ai_code_review label stays a manual override that works even on drafts.+ if: >-+ (github.event.action == 'labeled' && github.event.label.name == 'ai_code_review') ||+ (github.event.action != 'labeled' && github.event.pull_request.draft == false)permissions:contents: readpull-requests: write@@ -65,6 +73,7 @@ jobs:EXCLUDE_FILE_PATTERNS: ${{ vars.EXCLUDE_FILE_PATTERNS || '*.lock,*.min.js,*.min.css,package-lock.json,yarn.lock' }}PR_NUMBER: ${{ github.event.pull_request.number }}REPO_FULL_NAME: ${{ github.repository }}+ HEAD_SHA: ${{ github.event.pull_request.head.sha }}FAIL_ON_REQUESTED_CHANGES: ${{ vars.FAIL_ON_REQUESTED_CHANGES || 'false' }}DEBUG_MODE: ${{ vars.DEBUG_MODE || 'false' }}run: |@@ -133,8 +142,32 @@ jobs:DECISION=$(echo "$AI_RESPONSE" | jq -r '.fail_pass_workflow // "uncertain"' | tr -d '\n\r' | xargs)LABELS=$(echo "$AI_RESPONSE" | jq -r '.labels_added[]? // empty')- # Post the review as PR comment- echo "$REVIEW" | gh pr comment ${{ github.event.pull_request.number }} --repo ${{ github.repository }} -F -+ # Post (or update) the review as a single sticky PR comment. On each+ # push we edit the same comment in place instead of stacking a new one+ # per push. The hidden marker identifies our comment specifically, so+ # we never touch comments from humans or other bots. (Review comments+ # made before this change lack the marker and are left as-is.)+ # A commit-sha line lets reviewers tell which push the (edited-in-place)+ # comment reflects, since GitHub only shows a vague "edited" marker.+ STICKY_MARKER="<!-- ai-code-review:sticky -->"+ COMMENT_BODY=$(printf "%s\n\n%s\n\n_Last reviewed at commit \`%s\`_" "$STICKY_MARKER" "$REVIEW" "${HEAD_SHA:0:7}")+ # STICKY_MARKER is interpolated into the jq program below, so it must+ # stay free of `"` and `\`. gh api's --jq takes no --arg, so we can't+ # pass it as a jq variable; keeping the marker a literal constant is+ # what keeps this safe. The filter yields a single id (we maintain+ # exactly one sticky comment), so no post-filtering is needed.+ EXISTING_COMMENT_ID=$(gh api "repos/$REPO_FULL_NAME/issues/$PR_NUMBER/comments" \+ --paginate \+ --jq "[.[] | select(.body | contains(\"$STICKY_MARKER\"))] | last | .id // empty")+ if [ -n "$EXISTING_COMMENT_ID" ]; then+ echo "Updating existing AI review comment ($EXISTING_COMMENT_ID)"+ printf '%s' "$COMMENT_BODY" | gh api \+ "repos/$REPO_FULL_NAME/issues/comments/$EXISTING_COMMENT_ID" \+ --method PATCH -F body=@- >/dev/null+ else+ echo "Posting new AI review comment"+ printf '%s' "$COMMENT_BODY" | gh pr comment "$PR_NUMBER" --repo "$REPO_FULL_NAME" -F -+ fi# Add labels to PRecho "Labels to add: $LABELS"@@ -158,12 +191,16 @@ jobs:# Store the decision for later useecho "DECISION=$DECISION" >> "$GITHUB_ENV"- # Remove the ai_code_review label to make re-triggering easier- echo "Removing ai_code_review label to allow easy re-triggering"- if gh issue edit ${{ github.event.pull_request.number }} --remove-label "ai_code_review" 2>/dev/null; then- echo "Successfully removed ai_code_review label"- else- echo "Failed to remove ai_code_review label (may have been already removed)"+ # Remove the ai_code_review label so re-adding it re-triggers a review.+ # Only relevant when this run was triggered by that label; on+ # opened/synchronize/ready_for_review there is no such label to remove.+ if [ "${{ github.event.action }}" = "labeled" ]; then+ echo "Removing ai_code_review label to allow easy re-triggering"+ if gh issue edit "$PR_NUMBER" --remove-label "ai_code_review" 2>/dev/null; then+ echo "Successfully removed ai_code_review label"+ else+ echo "Failed to remove ai_code_review label (may have been already removed)"+ fifiecho "✅ AI review completed successfully"