Skip to content

Add AI policy label actions - #722

Open
zanieb wants to merge 6 commits into
python:mainfrom
zanieb:ai-policy-labels
Open

zanieb wants to merge 6 commits into
python:mainfrom
zanieb:ai-policy-labels

Conversation

@zanieb

@zanieb zanieb commented Oct 23, 2026 •

Copy link
Copy Markdown

Give triagers and core developers a consistent way to direct contributors to Python's AI guidelines via labels. Applying ai policy comment posts a reminder on an issue or pull request; ai policy close posts a closure message and closes it, but doesn't lock it / intentionally leaves the conversation open for clarification and questions.

I wrote some starting copy, though I imagine we'll iterate on it.

ai policy comment on pull requests:

Thank you for your interest in contributing to Python. This is a community-driven project, and we want it to be a welcoming place to learn and collaborate.

Contributors are responsible for reviewing and understanding what they submit, checking its claims, and being able to explain changes in their own words. This helps reviewers focus on the contribution and leaves more time to support other contributors.

This contribution appears to have been authored with AI assistance. Please explain your contribution in your own words and describe how you checked its correctness.

Please read our guidelines for using AI tools.

ai policy close on pull requests:

Thank you for your interest in contributing to Python. This is a community-driven project, and we want it to be a welcoming place to learn and collaborate.

Contributors are responsible for reviewing and understanding what they submit, checking its claims, and being able to explain changes in their own words. This helps reviewers focus on the contribution and leaves more time to support other contributors.

We believe this contribution does not meet our guidelines for using AI tools, so we're closing it. If you think we've misunderstood your contribution, please let us know. You're welcome to explain your approach or ask questions about the guidelines.

Please read our guidelines for using AI tools.

ai policy comment on issues:

Thank you for taking the time to open this issue. Python is a community-driven project, and we want it to be a welcoming place to learn and collaborate.

This issue appears to have been written with AI assistance. Please explain your issue in your own words and describe how you checked the information you provided. This helps us understand your issue and leaves more time to address other issues.

Please read our guidelines for using AI tools.

ai policy close on issues:

Thank you for taking the time to open this issue. Python is a community-driven project, and we want it to be a welcoming place to learn and collaborate.

We expect issues to be explained in your own words. We believe this issue does not meet our guidelines for using AI tools, so we're closing it. If you think we've misunderstood, you're welcome to clarify the issue or ask questions about the guidelines.

Please read our guidelines for using AI tools.

@python-cla-bot

python-cla-bot Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

Give triagers and core developers a consistent way to direct contributors to the AI guidelines and close contributions that fall short. Handle `ai policy comment` and `ai policy close` on issues and pull requests, keeping conversations open for clarification and questions.
@codecov

codecov Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (ead995a) to head (ab2f578).

Impacted file tree graph

@@            Coverage Diff             @@
##              main      #722    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files           18        20     +2     
  Lines         2182      2366   +184     
  Branches       100       117    +17     
==========================================
+ Hits          2182      2366   +184     
Flag Coverage Δ
Python_3.14.8 100.00% <100.00%> (ø)
Python_3.15.1 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
bedevere/__main__.py 100.00% <100.00%> (ø)
bedevere/policy.py 100.00% <100.00%> (ø)
tests/test_policy.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@zanieb
zanieb marked this pull request as ready for review October 23, 2026 18:11
@zanieb

zanieb commented Oct 23, 2026 •

Copy link
Copy Markdown
Author

It's plausible we might want to have a slightly different message for issues instead of pull requests, i.e., less of a focus on "contributors" for issues.

e.g. zanieb/bedevere@ai-policy-labels...ai-policy-issue-messages

@savannahostrowski savannahostrowski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this looks great. Thanks so much for implementing this, Zanie! 💜

@Mariatta

Copy link
Copy Markdown
Member

What is the intention on how the comment vs closed label meant to be used? When do you comment and when do you close? Is there rules about it on the devguide?

@zanieb

zanieb commented Oct 23, 2026

Copy link
Copy Markdown
Author

In my experience, it depends on the quality of the content. I use "close" when it seems likely it's in bad faith or is particularly low effort, and "comment" when it seems likely that they will engage. I'll pull some numbers and gather some feedback from other people on my team. We started with just the "close" action in June then split it into a "comment" action in August following some feedback from @AlexWaygood

it seems like a majority of the times we've used this label over in Ruff/ty we've actually just wanted the comment linking to the AI policy (we usually want to give the author time to respond and amend their PR/issue), and maintainers have immediately reopened the PR/issue after the PR/issue is auto-closed by the bot.

It might make sense to see what usage looks like before adding it to the devguide? but I don't have strong feelings about that.

@AlexWaygood

Copy link
Copy Markdown
Member

Yeah, I think it probably depends on whether you think the PR is salvageable or not? I'm not sure I've ever actually used the label to just insta-close the PR, but I can see a use for it if you can see that the PR comes from a completely unmonitored agent, or if it's something that you don't even want a PR for. Usually, in practice, I tend to want to give the contributor a chance to rectify or fix their error, so I usually just add the label that adds a comment without closing the PR.

@zanieb

zanieb commented Oct 23, 2026

Copy link
Copy Markdown
Author

I pulled some data. In ruff and uv, we've used "close" 104 times and "comment" 9 times. Of the 9 commented on, 6 were subsequently closed by maintainers, 1 was closed by its author, 1 merged, and 2 remain open. Of the 104 closed, 3 were reopened and 1 merged.

As another guiding use-case, you can see we also use the "close" action for cases where someone opens a bunch of pull requests https://github.com/astral-sh/ruff/issues?q=state%3Aclosed+label%3Abot%3Aai-policy-close

@hugovk hugovk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We'll obviously also need to add the labels to the CPython repo:

https://github.com/python/cpython/labels

And also to the devguide with brief instructions for use:

https://devguide.python.org/triage/labels/

Comment thread bedevere/policy.py Outdated
Comment thread bedevere/policy.py Outdated
Comment thread bedevere/policy.py Outdated
Comment thread bedevere/policy.py
)


@router.register("issues", action="labeled")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is Bedevere's first handler for issues.

@Mariatta Is the GH app already subscribed to issues, or do we need to add that in the app settings?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Wow! That's a good catch.

We could also just do pull requests to start if you prefer, but I've found it useful in issues too.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Agreed, issues and PRs makes sense.

Co-authored-by: Hugo van Kemenade <[email protected]>
@zware

zware commented Oct 23, 2026

Copy link
Copy Markdown
Member

We'll obviously also need to add the labels to the CPython repo:

See python/core-workflow#611 for that. Not entirely sure the process on that; we all have GH permission to add them, but I'm not sure if there needs to be more formal approval (SC?).

@zanieb

zanieb commented Oct 23, 2026

Copy link
Copy Markdown
Author

I'll draft a devguide change

@Mariatta

Copy link
Copy Markdown
Member

Could we start with just the comment label, and we can close it ourselves if we find the pr author did not follow through?

Eg we default to 'commenting' first.
If we also think it is worth closing after the initial comment, then we close it ourselves.

@zanieb

zanieb commented Oct 23, 2026

Copy link
Copy Markdown
Author

Given the data from our experience I'm a bit wary to drop a "close" action, but am certainly happy to do whatever people prefer here. We could always add a "close" action in the future if data in the CPython repository / feedback from maintainers indicates it is useful. I'm not sure what it costs us to add it now though (a bit of complexity in the devguide?).

@hugovk

hugovk commented Oct 23, 2026

Copy link
Copy Markdown
Member

I think having an automated way to post a comment and close would be useful, it feels less personal.

(And when dealing with unsalvageable LLM content, it's already not personal on their side, so let's make it easier on us.)

@hugovk

hugovk commented Oct 23, 2026

Copy link
Copy Markdown
Member

We'll obviously also need to add the labels to the CPython repo:

See python/core-workflow#611 for that. Not entirely sure the process on that; we all have GH permission to add them, but I'm not sure if there needs to be more formal approval (SC?).

I think the usual process is: open issue, wait a bit that there's consensus or no objections, create the labels. A merge here is good consensus to go ahead and create.

@zanieb

zanieb commented Oct 23, 2026

Copy link
Copy Markdown
Author

Created python/devguide#1933

@StanFromIreland

Copy link
Copy Markdown
Member

more formal approval (SC?).

I don't think we've ever needed that before, things like type-refactor were added based on consensus of the core team.

@willingc willingc left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks @zanieb. I love the spirit of this PR. I would recommend being a bit firmer on closing messages.

Comment thread bedevere/policy.py Outdated
Comment thread bedevere/policy.py
Comment thread bedevere/policy.py
Comment thread bedevere/policy.py Outdated
@willingc

Copy link
Copy Markdown

@Mariatta @zanieb I added some suggestions to this PR and the devguide PR.

I agree with Zanie that having "comment" and "close" makes sense.

Mariatta, I hope my suggestions help new contributors by thoughtful use of "comment". For clear cases, "close" signals the need for respect of maintainers'/triagers' time.

@zanieb

zanieb commented Oct 23, 2026

Copy link
Copy Markdown
Author

Note as I was looking at Carol's feedback I realized I didn't like the repetition in the issue comments and have edited them in 5069951

@willingc willingc left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks @zanieb.

Comment thread bedevere/policy.py Outdated
Comment thread README.md Outdated
Co-authored-by: Hugo van Kemenade <[email protected]>

This branch has not been deployed

No deployments
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.

8 participants