Skip to content

Commit 6a448f9

Browse files
mbevc1claude
andauthored
fix: read text blocks from Claude response in release version suggester (#1228)
claude-sonnet-5 returns a thinking block before the text block, so reading .content[0].text yielded nothing and `make release` failed. Join all text blocks instead, and raise max_tokens so thinking tokens do not truncate the changelog. Co-authored-by: Claude <noreply@anthropic.com>
1 parent 9257451 commit 6a448f9

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎bin/suggest-version-ai.sh‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,16 @@ BODY=$(jq -n \
103103
--arg model "$CLAUDE_MODEL" \
104104
--arg prompt "$PROMPT" \
105105
--rawfile diff "$DIFF_FILE" \
106-
'{model: $model, max_tokens: 1024, messages: [{role: "user", content: ($prompt + "\n\n--- diff ---\n\n" + $diff)}]}')
106+
'{model: $model, max_tokens: 4096, messages: [{role: "user", content: ($prompt + "\n\n--- diff ---\n\n" + $diff)}]}')
107107

108108
RESPONSE=$(curl -s -S -X POST "https://api.anthropic.com/v1/messages" \
109109
-H "x-api-key: $ANTHROPIC_API_KEY" \
110110
-H "anthropic-version: 2023-06-01" \
111111
-H "Content-Type: application/json" \
112112
-d "$BODY")
113113

114-
CONTENT=$(echo "$RESPONSE" | jq -r '.content[0].text // empty')
114+
# The response may start with a thinking block, so join all text blocks instead of reading content[0].
115+
CONTENT=$(echo "$RESPONSE" | jq -r '[.content[]? | select(.type == "text") | .text] | join("\n")')
115116
if [ -z "$CONTENT" ]; then
116117
echo "ERROR: Anthropic API failed or returned no content. Response:" >&2
117118
echo "$RESPONSE" | jq . >&2

0 commit comments

Comments
 (0)