mirror of
https://github.com/coder/coder.git
synced 2026-09-22 05:05:20 +08:00
fix: use structured output for classify-issue-severity workflow (#21240)
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.5
parent
6fa58c9999
commit
48484afaa4
@@ -31,6 +31,7 @@ jobs:
|
||||
uses: anthropics/claude-code-action@f0c8eb29807907de7f5412d04afceb5e24817127 # v1.0.23
|
||||
with:
|
||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
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"]}}]}'
|
||||
prompt: |
|
||||
You are an expert software engineer triaging customer-reported issues for Coder, a cloud development environment platform.
|
||||
|
||||
@@ -140,28 +141,20 @@ jobs:
|
||||
|
||||
**Critical**: Output ONLY the JSON object, nothing else. The JSON will be parsed and validated.
|
||||
|
||||
- name: Extract Result from Execution File
|
||||
- name: Extract Result from Structured Output
|
||||
id: extract
|
||||
env:
|
||||
EXECUTION_FILE: ${{ steps.analysis.outputs.execution_file }} # zizmor: ignore[template-injection]
|
||||
STRUCTURED_OUTPUT: ${{ steps.analysis.outputs.structured_output }}
|
||||
run: |
|
||||
if [ ! -f "$EXECUTION_FILE" ]; then
|
||||
echo "Execution file not found: $EXECUTION_FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# The execution file is an array of conversation messages
|
||||
# Extract the last assistant message's text content
|
||||
RESULT=$(jq -r '.[].content[]? | select(.type == "text") | .text' < "$EXECUTION_FILE" | tail -n 1)
|
||||
|
||||
if [ -z "$RESULT" ]; then
|
||||
echo "No text content found in execution file"
|
||||
if [ -z "$STRUCTURED_OUTPUT" ]; then
|
||||
echo "No structured output returned from Claude"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# The structured_output is already in JSON format matching our schema
|
||||
{
|
||||
echo "result<<EOF"
|
||||
echo "$RESULT"
|
||||
echo "$STRUCTURED_OUTPUT"
|
||||
echo "EOF"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user