Skip to content

Commit 48484af

Browse files
david-fraleyclaude
andauthored
fix: use structured output for classify-issue-severity workflow (#21240)
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 6fa58c9 commit 48484af

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

.github/workflows/classify-issue-severity.yml

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ jobs:
3131
uses: anthropics/claude-code-action@f0c8eb29807907de7f5412d04afceb5e24817127 # v1.0.23
3232
with:
3333
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
34+
claude_args: --json-schema '{"type":"object","properties":{"status":{"type":"string","enum":["classified","insufficient_info"]},"severity":{"type":"string","enum":["s0","s1","s2","s3","s4"]},"reasoning":{"type":"string"},"next_steps":{"type":"array","items":{"type":"string"}}},"required":["status","reasoning"],"allOf":[{"if":{"properties":{"status":{"const":"classified"}}},"then":{"required":["severity"]}},{"if":{"properties":{"status":{"const":"insufficient_info"}}},"then":{"required":["next_steps"]}}]}'
3435
prompt: |
3536
You are an expert software engineer triaging customer-reported issues for Coder, a cloud development environment platform.
3637
@@ -140,28 +141,20 @@ jobs:
140141
141142
**Critical**: Output ONLY the JSON object, nothing else. The JSON will be parsed and validated.
142143
143-
- name: Extract Result from Execution File
144+
- name: Extract Result from Structured Output
144145
id: extract
145146
env:
146-
EXECUTION_FILE: ${{ steps.analysis.outputs.execution_file }} # zizmor: ignore[template-injection]
147+
STRUCTURED_OUTPUT: ${{ steps.analysis.outputs.structured_output }}
147148
run: |
148-
if [ ! -f "$EXECUTION_FILE" ]; then
149-
echo "Execution file not found: $EXECUTION_FILE"
150-
exit 1
151-
fi
152-
153-
# The execution file is an array of conversation messages
154-
# Extract the last assistant message's text content
155-
RESULT=$(jq -r '.[].content[]? | select(.type == "text") | .text' < "$EXECUTION_FILE" | tail -n 1)
156-
157-
if [ -z "$RESULT" ]; then
158-
echo "No text content found in execution file"
149+
if [ -z "$STRUCTURED_OUTPUT" ]; then
150+
echo "No structured output returned from Claude"
159151
exit 1
160152
fi
161153
154+
# The structured_output is already in JSON format matching our schema
162155
{
163156
echo "result<<EOF"
164-
echo "$RESULT"
157+
echo "$STRUCTURED_OUTPUT"
165158
echo "EOF"
166159
} >> "$GITHUB_OUTPUT"
167160

0 commit comments

Comments
 (0)