Skip to content

Commit 0d0fb4d

Browse files
xuanyang15copybara-github
authored andcommitted
ci: Remove reviewer assignment in the PR triaging agent
PiperOrigin-RevId: 823255296
1 parent 0660779 commit 0d0fb4d

File tree

1 file changed

+21
-44
lines changed
  • contributing/samples/adk_pr_triaging_agent

1 file changed

+21
-44
lines changed

contributing/samples/adk_pr_triaging_agent/agent.py

Lines changed: 21 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,18 @@
2727
from google.adk import Agent
2828
import requests
2929

30-
LABEL_TO_OWNER = {
31-
"documentation": "polong-lin",
32-
"services": "DeanChensj",
33-
"tools": "seanzhou1023",
34-
"mcp": "seanzhou1023",
35-
"eval": "ankursharmas",
36-
"live": "hangfei",
37-
"models": "genquan9",
38-
"tracing": "Jacksunwei",
39-
"core": "Jacksunwei",
40-
"web": "wyf7107",
41-
}
30+
ALLOWED_LABELS = [
31+
"documentation",
32+
"services",
33+
"tools",
34+
"mcp",
35+
"eval",
36+
"live",
37+
"models",
38+
"tracing",
39+
"core",
40+
"web",
41+
]
4242

4343
CONTRIBUTING_MD = read_file(
4444
Path(__file__).resolve().parents[3] / "CONTRIBUTING.md"
@@ -158,19 +158,19 @@ def get_pull_request_details(pr_number: int) -> str:
158158
return error_response(str(e))
159159

160160

161-
def add_label_and_reviewer_to_pr(pr_number: int, label: str) -> dict[str, Any]:
162-
"""Adds a specified label and requests a review from a mapped reviewer on a PR.
161+
def add_label_to_pr(pr_number: int, label: str) -> dict[str, Any]:
162+
"""Adds a specified label on a pull request.
163163
164164
Args:
165165
pr_number: the number of the Github pull request
166166
label: the label to add
167167
168168
Returns:
169-
The the status of this request, with the applied label and assigned
170-
reviewer when successful.
169+
The the status of this request, with the applied label and response when
170+
successful.
171171
"""
172-
print(f"Attempting to add label '{label}' and a reviewer to PR #{pr_number}")
173-
if label not in LABEL_TO_OWNER:
172+
print(f"Attempting to add label '{label}' to PR #{pr_number}")
173+
if label not in ALLOWED_LABELS:
174174
return error_response(
175175
f"Error: Label '{label}' is not an allowed label. Will not apply."
176176
)
@@ -186,31 +186,10 @@ def add_label_and_reviewer_to_pr(pr_number: int, label: str) -> dict[str, Any]:
186186
except requests.exceptions.RequestException as e:
187187
return error_response(f"Error: {e}")
188188

189-
owner = LABEL_TO_OWNER.get(label, None)
190-
if not owner:
191-
return {
192-
"status": "warning",
193-
"message": (
194-
f"{response}\n\nLabel '{label}' does not have an owner. Will not"
195-
" assign."
196-
),
197-
"applied_label": label,
198-
}
199-
reviewer_url = f"{GITHUB_BASE_URL}/repos/{OWNER}/{REPO}/pulls/{pr_number}/requested_reviewers"
200-
reviewer_payload = {"reviewers": [owner]}
201-
try:
202-
post_request(reviewer_url, reviewer_payload)
203-
except requests.exceptions.RequestException as e:
204-
return {
205-
"status": "warning",
206-
"message": f"Reviewer not assigned: {e}",
207-
"applied_label": label,
208-
}
209-
210189
return {
211190
"status": "success",
212191
"applied_label": label,
213-
"assigned_reviewer": owner,
192+
"response": response,
214193
}
215194

216195

@@ -252,7 +231,6 @@ def add_comment_to_pr(pr_number: int, comment: str) -> dict[str, Any]:
252231
Your core responsibility includes:
253232
- Get the pull request details.
254233
- Add a label to the pull request.
255-
- Assign a reviewer to the pull request.
256234
- Check if the pull request is following the contribution guidelines.
257235
- Add a comment to the pull request if it's not following the guidelines.
258236
@@ -303,7 +281,7 @@ def add_comment_to_pr(pr_number: int, comment: str) -> dict[str, Any]:
303281
- Skip the PR (i.e. do not label or comment) if any of the following is true:
304282
- the PR is closed
305283
- the PR is labeled with "google-contributior"
306-
- the PR is already labelled with the above labels (e.g. "documentation", "services", "tools", etc.) and has a reviewer assigned.
284+
- the PR is already labelled with the above labels (e.g. "documentation", "services", "tools", etc.).
307285
- Check if the PR is following the contribution guidelines.
308286
- If it's not following the guidelines, recommend or add a comment to the PR that points to the contribution guidelines (https://github.com/google/adk-python/blob/main/CONTRIBUTING.md).
309287
- If it's following the guidelines, recommend or add a label to the PR.
@@ -312,12 +290,11 @@ def add_comment_to_pr(pr_number: int, comment: str) -> dict[str, Any]:
312290
Present the followings in an easy to read format highlighting PR number and your label.
313291
- The PR summary in a few sentence
314292
- The label you recommended or added with the justification
315-
- The owner of the label if you assigned a reviewer to the PR
316293
- The comment you recommended or added to the PR with the justification
317294
""",
318295
tools=[
319296
get_pull_request_details,
320-
add_label_and_reviewer_to_pr,
297+
add_label_to_pr,
321298
add_comment_to_pr,
322299
],
323300
)

0 commit comments

Comments
 (0)