Add AI policy label actions #722
All commit authors signed the Contributor License Agreement.
<!-- CLA BOT SIGNING COMMENT DO NOT EDIT -->
Codecov Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 100.00%. Comparing base (
ead995a) to head (b52c2ee).
@@ Coverage Diff @@
## main #722 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 18 20 +2
Lines 2182 2370 +188
Branches 100 117 +17
==========================================
+ Hits 2182 2370 +188
| Flag | Coverage Δ | |
|---|---|---|
| Python_3.14.8 | 100.00% <100.00%> (ø) | |
| Python_3.15.1 | ? | |
| Python_3.15.2 | 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%> (ø) | |
<details><summary> :rocket: New features to boost your workflow: </summary>
</details>
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. https://github.com/zanieb/bedevere/compare/ai-policy-labels...ai-policy-issue-messages
Approved these changes.
I think this looks great. Thanks so much for implementing this, Zanie! 💜
Approved these changes.
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?
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.
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.
"""Respond to AI policy labels applied by triage and core teams."""
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.
Thank you for taking the time to open this issue. Python is a community-driven \
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
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?
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:
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.
We'll obviously also need to add the labels to the CPython repo:
See https://github.com/python/core-workflow/issues/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'll draft a devguide change
Agreed, issues and PRs makes sense.
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.
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?).
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.)
> 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.
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.
"We're closing this contribution because it does not meet our "
"guidelines for using AI tools. "
"Please review our guidelines. "
"You're welcome to explain your approach or ask questions after reviewing them."
I would recommend swapping the paragraph on reading the guidelines and the {action}.
Again I would swap the paragraphs on reading the guidelines and the action.
"We're closing this issue because it does not meet our "
"guidelines for using AI tools. "
"After reviewing the guidelines, you're welcome to clarify the issue."
Thanks @zanieb. I love the spirit of this PR. I would recommend being a bit firmer on closing messages.
hm I think "we believe" is important there. We don't _know_ if it meets our guidelines or not. I don't think being firmer is worth the risk of being off-putting to someone that wants to genuinely engage. I think the average fully autonomous contributor won't respond at all (from our experience / data thus far).
I like having a call to action at the end, but am not sure I feel strongly otherwise.
See also https://github.com/python/bedevere/pull/722#discussion_r4365070028
Why do you think including "If you think we've misunderstood your contribution, please let us know." is not appropriate?
@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.
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 https://github.com/python/bedevere/pull/722/commits/50699512230b74c9de95a4aeb906caeefc42daa8
It's appropriate if we think a human will respond to the comment.
I think it opens the door for a debate. In practice, I've seen some pretty hostile responses IRL when the agent responds instead of a human. At the point that we are applying "close", I think we are pretty convinced that it should be closed. The burden should be on the contributor to respond respectfully. I think the more direct approach increases that likelihood.
My personal preference is to start with something a bit softer as we're exploring something new and if hostile responses are common we can adjust accordingly. (though I don't think the wording will save us from a bad faith / hostile actor and thus would rather focus my responses with the assumption someone is acting in good faith)
I think reading the guideline should be part of the call to action prior to commenting/questioning. We can't enforce that, but I think it signals that mutual respect is the culture that we want to foster.
@zanieb How about cause followed by effect?
We believe this contribution does not meet our guidelines for using AI tools, so we're closing it.
That's fair. How about: https://github.com/python/bedevere/pull/722#discussion_r4365230991
In other words, I think we agree.
It seems arbitrary to me, I don't mind either ordering
I guess I see "going to another page" as the kind of call to action I'd have at the end :) I think it's actually more likely that someone does it when it's at the end of a message rather than in the middle.
You've convinced me @zanieb. Thanks for iterating. I'm happy with the PR in its current state. Thanks so much for doing this.
Thanks @zanieb.
Little nit, we do capitalise initials like OS, C API, IDLE, IO, JIT, SSL, XML: https://github.com/python/cpython/labels
COMMENT_LABEL = "AI policy comment"
CLOSE_LABEL = "AI policy close"
`AI policy comment`. The `AI policy close` label also closes the contribution.
Approved these changes.
Coding style nit. Could this be more like in the following pattern (matches more to the existing codebase pattern)
if "pull_request" in event.data:
target = event.data["pull_request"]
issue_url = target["issue_url"]
comment_message, close_message = PR_COMMENT_MESSAGE, PR_CLOSE_MESSAGE
close_data = {"state": "closed"}
else:
target = event.data["issue"]
issue_url = target["url"]
comment_message, close_message = ISSUE_COMMENT_MESSAGE, ISSUE_CLOSE_MESSAGE
close_data = {"state": "closed", "state_reason": "not_planned"}
- ### Remind Contributors about AI policy
Not a big deal, but in other place we use os.environ.get("GH_APP_ID").
I checked the setting, and the issues event is already subscribed now.
If someone could own merging this (and the related pulls) that'd be great :)
I'd like to give @Mariatta at least a few more hours to register agreement with the response to her comments, but if it's still sitting here in my morning I'll be happy to merge :)
Just an FYI that @Mariatta is returning from a conference. As a courtesy, I would give her a full day to respond (Tuesday end of day).
Thanks everyone. I think the technical implementation here is good.
But I just find the labels themselves to sound odd.
What about the following:
ai policy comment with AI-needs-explanation (it means we're requesting follow up)
ai policy close with AI-not-acceptable (so it will automatically be closed)
These would match more with existing label patterns like needs backport to which signifies this pr/issue is pending some follow up action. or stale label which explains the state of the pr/issue.
If we agree with the new labels, then I can go ahead to create these labels, merge, and deploy. (Auto deployment to cabotage still seem broken, so I'll have to do it manually).
Also, I think this update is worth announcing on Discourse, so you might want to prepare such announcement @zanieb
Oh I'm afraid of Discourse, would you like to? :D
I'm going to start creating the labels using the AI-... prefix on the CPython repo, and deploy this. I might have follow up PR on this to make it work on other repos as well, eg on the devguide because we seem to start receiving more llm-assisted contributions there. That needs a larger refactoring, but we can start with the CPython repo for today.
Thank you for the work.
Approved these changes.
I ended up with the labels AI-needs-explanation and AI-guidelines-not-met (as opposed to `AI-not-acceptable).
zware
zanieb
Give triagers and core developers a consistent way to direct contributors to Python's AI guidelines via labels. Applying
ai policy commentposts a reminder on an issue or pull request;ai policy closeposts 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 commenton pull requests:ai policy closeon pull requests:ai policy commenton issues:ai policy closeon issues: