Skip to content

ci: auto-merge provider-info-sync PRs when CI, Greptile and Bugbot are clean - #41494

Merged
kerry-berri merged 4 commits into
mainfrom
litellm_auto_merge_price_sync
Sep 17, 2026
Merged

kerry-berri merged 4 commits into
mainfrom
litellm_auto_merge_price_sync

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • Price-sync PRs from berriai-litellm-provider-info-sync[bot] wait for a human to approve and merge
  • Every one of them is the same mechanical review: CI green, Greptile happy, Bugbot clean

How it solves it:

  • New auto-merge-price-sync workflow evaluates open sync-bot PRs and merges the clean ones
  • Merges only when the diff is cost-map files plus tests, every check is green, Greptile says 5/5, Bugbot says no new issues on the head commit, and nobody requested changes
  • Anything else is logged as a hold reason and left for a human

User Flow

Before: the sync bot opens a price PR and it sits until someone on the team reviews it

  1. The bot pushes litellm-providers/price-sync and opens a PR against main
  2. CI, Greptile and Bugbot run and come back clean within about 20 minutes
  3. The PR stays open until a maintainer notices it at https://github.com/BerriAI/litellm/pulls, approves it and clicks merge

After: a clean sync PR merges on its own within half an hour of the last bot result

  1. The bot pushes litellm-providers/price-sync and opens a PR against main
  2. CI, Greptile and Bugbot run and come back clean
  3. The auto-merge-price-sync run triggered by the last comment, check suite, status or scheduled tick merges the PR with a merge commit as the sync App, and the run log lists the gates it checked
  4. If any gate holds (Greptile 4/5, a red shard, a pending Buildkite status, a file outside the cost map set), the run log says why and the PR waits for a maintainer exactly as today

Design

The workflow runs on issue_comment, check_suite, status, a 30 minute schedule and workflow_dispatch. All of those run the workflow file and checkout from main, never the PR branch, so the App credentials are never exposed to PR code. There is deliberately no pull_request_review trigger: that event runs the workflow from the PR merge ref, which would let a same-repo PR execute its own copy of the script with the App token. A Bugbot review is picked up by its check suite completing or by the next scheduled tick. The workflow's own token is read-only and the merge uses a short-lived token minted from PROVIDER_INFO_SYNC_APP_ID and PROVIDER_INFO_SYNC_APP_PRIVATE_KEY; when those secrets are absent the run logs "app credentials not configured" and exits green, so the workflow can land before the secrets exist

.github/scripts/auto_merge_price_sync.py is stdlib only. A pure evaluate(EvaluationInputs) -> Verdict collects every hold reason so a run log shows all of them at once. The gates, in order: author in PR_AUTHOR_ALLOWLIST; PR open, not draft, mergeable and not dirty; changed files classify as cost-map-only (new category in classify_changes.sh: at least one of the three cost map files and nothing outside them and tests/test_litellm/, tests/proxy_unit_tests/); every context required by the main rulesets is green as a check run or commit status; every other check run on the head sha is completed with success, skipped or neutral (this workflow's own run excluded); every commit status is success; the latest Greptile Confidence Score: N/5 comment is 5 and not older than the head commit; the latest non-stale cursor[bot] review whose commit_id is the head sha contains "found no new issues"; no human reviewer's latest review is CHANGES_REQUESTED. The merge uses merge_method: merge because main-merge only allows merge commits and pins sha to the head that was evaluated, so a commit pushed between evaluation and the merge call makes GitHub return 409 instead of merging unreviewed code. A 405 or 409 from the merge call is logged and the run stays green so the next tick re-evaluates

Setup outside this PR, already done: add the sync App as a bypass actor in "pull requests only" mode on guard-main, main-merge, Protect Sensitive Files and Protect dot directories so its token can merge without a team approval, and add the two App secrets. Until the bypass is in place the merge call returns 405 and the run logs it

Overlaps with #39845 (LIT-6995), which reconciles a different App's litellm_cost_map_sync_* PRs inside its own sync workflow. This one gates on Greptile and Bugbot and works for any App login in the allowlist, so the two could be unified later by adding that App's login here

Relevant issues

Affected release

Linear ticket

Resolves LIT-7920

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. uv run pytest tests/test_litellm/<your_test_file>.py -v. Leave the suites (make test-unit-*, make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review (Greptile reviews automatically once the PR is opened; only comment @greptileai to re-request a review after pushing changes)

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

Screenshots / Proof of Fix

Read-only dry run of the script against the already merged sync PR #41457, using a personal token and DRY_RUN=1 so no merge call is made. It shows the evaluation collecting every hold reason rather than stopping at the first one:

$ REPO=BerriAI/litellm PR_NUMBER=41457 DRY_RUN=1 PR_AUTHOR_ALLOWLIST='berriai-litellm-provider-info-sync[bot]' GH_TOKEN=$(gh auth token) python3 .github/scripts/auto_merge_price_sync.py
auto-merge-price-sync: PR #41457 hold: pr not open
auto-merge-price-sync: PR #41457 hold: mergeability unknown
auto-merge-price-sync: PR #41457 hold: greptile score older than head commit
auto-merge-price-sync: PR #41457 hold: bugbot review not available

The last two holds are real for that PR: Greptile scored it 4/5 on the first commit and did not re-review the last push, and Bugbot never reviewed it, so under this workflow it would have waited for a human, which is what happened

Link to Devin session: https://app.devin.ai/sessions/bbfced756d18415d85c92948ab0de8f4
Open in Devin Desktop: https://app.devin.ai/desktop/session/bbfced756d18415d85c92948ab0de8f4?variant=devin


Note

Medium Risk
Introduces automated merges via a GitHub App, but scope is limited to allowlisted bot PRs, cost-map-only diffs, and strict CI/Greptile/Bugbot gates with pinned head SHA.

Overview
Adds automated merging for open price-sync PRs from berriai-litellm-provider-info-sync[bot] when every safety gate passes, instead of waiting for a maintainer.

classify_changes.sh gains a cost-map-only mode: the diff must touch at least one of the three model price JSON/schema files and must not include changes outside that set (with exceptions for tests/test_litellm/ and tests/proxy_unit_tests/). Docs and other paths still fail the check.

.github/scripts/auto_merge_price_sync.py loads PR metadata from GitHub, runs the classifier, and returns a merge verdict only if the author is allowlisted, the PR is mergeable, required branch checks and all other check runs/statuses are green, Greptile’s latest score is 5/5 on the head commit, Bugbot’s head-commit review reports no new issues, and no human has CHANGES_REQUESTED. Holds are logged; DRY_RUN=1 skips the merge API call. Merges use a merge commit with sha pinned to the evaluated head.

auto-merge-price-sync workflow runs on comments, completed check suites, commit statuses, a 30-minute cron, and manual dispatch—always from main, with a short-lived App token for the merge step when secrets are set.

Unit tests cover each gate in test_auto_merge_price_sync.py and the new classifier cases in test_circleci_path_filter.py.

Reviewed by Cursor Bugbot for commit 9e84d8a. Bugbot is set up for automated code reviews on this repo. Configure here.

…e clean

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration
devin-ai-integration Bot requested a review from a team September 16, 2026 21:50
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@greptile-apps

greptile-apps Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds a GitHub Actions workflow and supporting Python evaluator that automatically merges eligible provider price-sync pull requests after validating their author, changed-file scope, CI results, Greptile score, Bugbot review, and human review state.

  • Adds a cost-map-only classification for price-map files and associated tests.
  • Uses short-lived GitHub App credentials and pins each merge request to the evaluated head SHA.
  • Removes the pull_request_review trigger so privileged execution always uses the trusted default-branch workflow.
  • Adds focused tests for merge gates, file classification, and head-SHA pinning.

Confidence Score: 5/5

The PR appears safe to merge; no blocking or independently actionable issue remains in the current changes.

The prior head-SHA race is fully fixed by including the evaluated pr.head_sha in the merge request, and its thread is resolved. The prior HTTP-handler finding was correctly withdrawn after establishing that this is an isolated stdlib-only CI script. The changes since the previous review remove an unsafe workflow trigger without weakening the remaining periodic and check-driven reevaluation paths.

Important Files Changed
Filename Overview
.github/scripts/auto_merge_price_sync.py Implements fail-closed eligibility evaluation, GitHub data collection, and SHA-pinned merge requests.
.github/workflows/auto-merge-price-sync.yml Runs the evaluator from trusted workflow contexts using a short-lived provider-sync App token.
.circleci/scripts/classify_changes.sh Adds a strict cost-map-only category requiring a recognized price-map file and rejecting files outside the permitted test directories.
tests/test_litellm/test_auto_merge_price_sync.py Covers each merge hold condition, the successful path, classifier integration, and evaluated-head pinning.
tests/test_litellm/test_circleci_path_filter.py Extends path-classifier coverage for allowed and disallowed cost-map-only change sets.

Reviews (3): Last reviewed commit: "fix(ci): drop the pull_request_review tr..." | Re-trigger Greptile

@codecov

codecov Bot commented Sep 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

kerry-berri and others added 2 commits September 16, 2026 23:56
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@CLAassistant

CLAassistant commented Sep 16, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@kerry-berri

Copy link
Copy Markdown
Contributor

@greptileai

@kerry-berri

Copy link
Copy Markdown
Contributor

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

…low only runs from main

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@kerry-berri

Copy link
Copy Markdown
Contributor

@greptileai

@kerry-berri

Copy link
Copy Markdown
Contributor

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 9e84d8a. Configure here.

@kerry-berri kerry-berri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@kerry-berri
kerry-berri merged commit db408f6 into main Sep 17, 2026
87 checks passed
@kerry-berri
kerry-berri deleted the litellm_auto_merge_price_sync branch September 17, 2026 00:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants