1
+name: Issue Triage
2
+
3
+on:
4
+ issues:
5
+ types: [opened, reopened, edited]
6
+ workflow_dispatch:
7
+ inputs:
8
+ issue_number:
9
+ description: "Issue number to triage retrospectively"
10
+ required: true
11
+ type: string
12
+
13
+permissions:
14
+ contents: read
15
+ issues: write
16
+
17
+jobs:
18
+ classify:
19
+ runs-on: ubuntu-latest
20
+
21
+ steps:
22
+ - name: Checkout repository
23
+ uses: actions/checkout@v6
24
+
25
+ - name: Load issue context for dispatch runs
26
+ if: github.event_name == 'workflow_dispatch'
27
+ id: issue-context
28
+ uses: actions/github-script@v8
29
+ env:
30
+ ISSUE_NUMBER: ${{ inputs.issue_number }}
31
+ with:
32
+ script: |
33
+ const issue_number = Number(process.env.ISSUE_NUMBER);
34
+ if (!Number.isInteger(issue_number) || issue_number <= 0) {
35
+ core.setFailed(`Invalid issue_number: ${process.env.ISSUE_NUMBER}`);
36
+ return;
37
+ }
38
+
39
+ const { data: issue } = await github.rest.issues.get({
40
+ owner: context.repo.owner,
41
+ repo: context.repo.repo,
42
+ issue_number,
43
+ });
44
+
45
+ if (issue.pull_request) {
46
+ core.setFailed(`Issue #${issue_number} is a pull request, not an issue.`);
47
+ return;
48
+ }
49
+
50
+ core.setOutput("issue_number", String(issue.number));
51
+ core.setOutput("issue_title", issue.title || "");
52
+ core.setOutput("issue_body", issue.body || "");
53
+ core.setOutput("issue_state", issue.state || "open");
54
+
55
+ - name: Write triage schema
56
+ run: |
57
+ cat > /tmp/issue-triage-schema.json <<'EOF'
58
+ {
59
+ "type": "object",
60
+ "additionalProperties": false,
61
+ "properties": {
62
+ "category": {
63
+ "type": "string",
64
+ "enum": ["docs", "py", "ts", "cli", "tool-request", "feature-request", "other"]
65
+ },
66
+ "is_bug": {
67
+ "type": "boolean"
68
+ },
69
+ "reason": {
70
+ "type": "string"
71
+ },
72
+ "should_comment": {
73
+ "type": "boolean"
74
+ },
75
+ "comment_body": {
76
+ "type": "string"
77
+ }
78
+ },
79
+ "required": ["category", "is_bug", "reason", "should_comment", "comment_body"]
80
+ }
81
+ EOF
82
+
83
+ - name: Classify issue with Claude Sonnet
84
+ id: classify
85
+ uses: anthropics/claude-code-action@v1
86
+ env:
87
+ ISSUE_TITLE: ${{ github.event_name == 'workflow_dispatch' && steps.issue-context.outputs.issue_title || github.event.issue.title }}
88
+ ISSUE_BODY: ${{ github.event_name == 'workflow_dispatch' && steps.issue-context.outputs.issue_body || github.event.issue.body }}
89
+ with:
90
+ anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
91
+ prompt: |
92
+ Read the issue title and body from the ISSUE_TITLE and ISSUE_BODY environment variables.
93
+
94
+ Classify the issue for routing and determine whether it is a bug report.
95
+
96
+ Allowed categories:
97
+ - docs
98
+ - py
99
+ - ts
100
+ - cli
101
+ - tool-request
102
+ - feature-request
103
+ - other
104
+
105
+ Use semantic meaning, not only keywords.
106
+ Choose tool-request when the issue is primarily asking for a new integration, toolkit, app, or tool.
107
+ Choose feature-request when the issue is asking for a product, SDK, docs, or CLI improvement that is not a tool request.
108
+ Choose cli only when the issue is specifically about the CLI experience or ts/packages/cli.
109
+ Choose py only when the issue is primarily about the Python SDK.
110
+ Choose ts only when the issue is primarily about the TypeScript SDK or TS packages other than the CLI.
111
+ Choose docs only when the issue is primarily about documentation.
112
+ Set is_bug to true when the issue is primarily reporting broken behavior, a defect, an error, a regression, or unexpected behavior.
113
+ Set is_bug to false for feature requests, questions, maintenance, cleanup, and tool requests.
114
+ Set should_comment to true only when the issue appears incorrect, non-actionable, or missing the information needed to reproduce or investigate.
115
+ Set should_comment to false otherwise.
116
+
117
+ If should_comment is true, provide comment_body as a short issue comment addressed to the reporter.
118
+ The comment must:
119
+ - clearly say it is an automated Claude triage note
120
+ - clearly say Claude cannot reply back in a conversation
121
+ - ask for the specific missing details needed to investigate, especially repro steps, expected behavior, actual behavior, environment, logs, or screenshots when relevant
122
+ - stay concise and professional
123
+
124
+ If should_comment is false, set comment_body to an empty string.
125
+ claude_args: |
126
+ --model claude-sonnet-4-6
127
+ --json-schema /tmp/issue-triage-schema.json
128
+
129
+ - name: Apply labels, assignees, and tool-request handling
130
+ uses: actions/github-script@v8
131
+ env:
132
+ STRUCTURED_OUTPUT: ${{ steps.classify.outputs.structured_output }}
133
+ with:
134
+ script: |
135
+ const text = process.env.STRUCTURED_OUTPUT || "";
136
+ let parsed;
137
+
138
+ try {
139
+ parsed = JSON.parse(text);
140
+ } catch (error) {
141
+ core.setFailed(`Could not parse structured_output as JSON: ${text}`);
142
+ return;
143
+ }
144
+
145
+ const allowed = new Set(["docs", "py", "ts", "cli", "tool-request", "feature-request", "other"]);
146
+ if (!allowed.has(parsed.category)) {
147
+ core.setFailed(`Unexpected category: ${parsed.category}`);
148
+ return;
149
+ }
150
+
151
+ const category = parsed.category;
152
+ const isBug = Boolean(parsed.is_bug);
153
+ const reason = parsed.reason || "";
154
+ const shouldComment = Boolean(parsed.should_comment);
155
+ const commentBody = parsed.comment_body || "";
156
+ const issue_number = context.eventName === "workflow_dispatch"
157
+ ? Number("${{ steps.issue-context.outputs.issue_number }}")
158
+ : context.payload.issue.number;
159
+ const owner = context.repo.owner;
160
+ const repo = context.repo.repo;
161
+ const issueState = context.eventName === "workflow_dispatch"
162
+ ? "${{ steps.issue-context.outputs.issue_state }}"
163
+ : context.payload.issue.state;
164
+
165
+ const labels = [];
166
+ const assignees = [];
167
+
168
+ if (isBug) {
169
+ labels.push("bug");
170
+ }
171
+
172
+ if (category === "docs") {
173
+ labels.push("docs");
174
+ assignees.push("shawnesquivel", "Sushmithamallesh");
175
+ } else if (category === "py") {
176
+ labels.push("py");
177
+ assignees.push("jkomyno");
178
+ } else if (category === "ts") {
179
+ labels.push("ts");
180
+ assignees.push("jkomyno");
181
+ } else if (category === "cli") {
182
+ labels.push("cli");
183
+ assignees.push("CryogenicPlanet");
184
+ } else if (category === "feature-request") {
185
+ labels.push("feature-request");
186
+ } else if (category === "tool-request") {
187
+ labels.push("tool-request");
188
+ }
189
+
190
+ if (labels.length > 0) {
191
+ await github.rest.issues.addLabels({
192
+ owner,
193
+ repo,
194
+ issue_number,
195
+ labels,
196
+ });
197
+ }
198
+
199
+ if (assignees.length > 0) {
200
+ await github.rest.issues.addAssignees({
201
+ owner,
202
+ repo,
203
+ issue_number,
204
+ assignees,
205
+ });
206
+ }
207
+
208
+ if (category !== "tool-request" && shouldComment && commentBody.trim().length > 0) {
209
+ await github.rest.issues.createComment({
210
+ owner,
211
+ repo,
212
+ issue_number,
213
+ body: commentBody.trim(),
214
+ });
215
+ }
216
+
217
+ if (category === "tool-request" && issueState === "open") {
218
+ await github.rest.issues.createComment({
219
+ owner,
220
+ repo,
221
+ issue_number,
222
+ body: [
223
+ "Hey, please ask for tool requests here https://request.composio.dev/boards/tool-requests",
224
+ "",
225
+ "I've tagged this as `tool-request` and I'm closing it here.",
226
+ "",
227
+ `Classifier note: ${reason}`
228
+ ].join("\n"),
229
+ });
230
+
231
+ await github.rest.issues.update({
232
+ owner,
233
+ repo,
234
+ issue_number,
235
+ state: "closed",
236
+ });
237
+ }