25
25
from google .adk import Agent
26
26
import requests
27
27
28
- ALLOWED_LABELS = [
29
- "documentation" ,
30
- "services" ,
31
- "question" ,
32
- "tools" ,
33
- "eval" ,
34
- "live" ,
35
- "models" ,
36
- "tracing" ,
37
- "core" ,
38
- "web" ,
39
- ]
28
+ LABEL_TO_OWNER = {
29
+ "documentation" : "polong" ,
30
+ "services" : "DeanChensj" ,
31
+ "question" : "" ,
32
+ "tools" : "seanzhou1023" ,
33
+ "eval" : "ankursharmas" ,
34
+ "live" : "hangfei" ,
35
+ "models" : "selcukgun" ,
36
+ "tracing" : "Jacksunwei" ,
37
+ "core" : "Jacksunwei" ,
38
+ "web" : "wyf7107" ,
39
+ }
40
40
41
41
APPROVAL_INSTRUCTION = (
42
42
"Do not ask for user approval for labeling! If you can't find appropriate"
@@ -78,33 +78,61 @@ def list_unlabeled_issues(issue_count: int) -> dict[str, Any]:
78
78
return {"status" : "success" , "issues" : unlabeled_issues }
79
79
80
80
81
- def add_label_to_issue (issue_number : int , label : str ) -> dict [str , Any ]:
82
- """Add the specified label to the given issue number.
81
+ def add_label_and_owner_to_issue (
82
+ issue_number : int , label : str
83
+ ) -> dict [str , Any ]:
84
+ """Add the specified label and owner to the given issue number.
83
85
84
86
Args:
85
87
issue_number: issue number of the Github issue.
86
88
label: label to assign
87
89
88
90
Returns:
89
- The the status of this request, with the applied label when successful.
91
+ The the status of this request, with the applied label and assigned owner
92
+ when successful.
90
93
"""
91
94
print (f"Attempting to add label '{ label } ' to issue #{ issue_number } " )
92
- if label not in ALLOWED_LABELS :
95
+ if label not in LABEL_TO_OWNER :
93
96
return error_response (
94
97
f"Error: Label '{ label } ' is not an allowed label. Will not apply."
95
98
)
96
99
97
- url = f"{ GITHUB_BASE_URL } /repos/{ OWNER } /{ REPO } /issues/{ issue_number } /labels"
98
- payload = [label , BOT_LABEL ]
100
+ label_url = (
101
+ f"{ GITHUB_BASE_URL } /repos/{ OWNER } /{ REPO } /issues/{ issue_number } /labels"
102
+ )
103
+ label_payload = [label , BOT_LABEL ]
99
104
100
105
try :
101
- response = post_request (url , payload )
106
+ response = post_request (label_url , label_payload )
102
107
except requests .exceptions .RequestException as e :
103
108
return error_response (f"Error: { e } " )
109
+
110
+ owner = LABEL_TO_OWNER .get (label , None )
111
+ if not owner :
112
+ return {
113
+ "status" : "warning" ,
114
+ "message" : (
115
+ f"{ response } \n \n Label '{ label } ' does not have an owner. Will not"
116
+ " assign."
117
+ ),
118
+ "applied_label" : label ,
119
+ }
120
+
121
+ assignee_url = (
122
+ f"{ GITHUB_BASE_URL } /repos/{ OWNER } /{ REPO } /issues/{ issue_number } /assignees"
123
+ )
124
+ assignee_payload = {"assignees" : [owner ]}
125
+
126
+ try :
127
+ response = post_request (assignee_url , assignee_payload )
128
+ except requests .exceptions .RequestException as e :
129
+ return error_response (f"Error: { e } " )
130
+
104
131
return {
105
132
"status" : "success" ,
106
133
"message" : response ,
107
134
"applied_label" : label ,
135
+ "assigned_owner" : owner ,
108
136
}
109
137
110
138
@@ -128,9 +156,12 @@ def add_label_to_issue(issue_number: int, label: str) -> dict[str, Any]:
128
156
- If it's agent orchestration, agent definition, label it with "core".
129
157
- If you can't find a appropriate labels for the issue, follow the previous instruction that starts with "IMPORTANT:".
130
158
159
+ Call the `add_label_and_owner_to_issue` tool to label the issue, which will also assign the issue to the owner of the label.
160
+
131
161
Present the followings in an easy to read format highlighting issue number and your label.
132
162
- the issue summary in a few sentence
133
163
- your label recommendation and justification
164
+ - the owner of the label if you assign the issue to an owner
134
165
""" ,
135
- tools = [list_unlabeled_issues , add_label_to_issue ],
166
+ tools = [list_unlabeled_issues , add_label_and_owner_to_issue ],
136
167
)
0 commit comments