Skip to content

Commit 0cdc50b

Browse files
Zachary-wWclaude
andcommitted
ci: fix Claude review API response handling
Use the Anthropic API model ID and read text from any content block so review runs do not fail when non-text blocks precede the answer. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent e210696 commit 0cdc50b

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

.github/scripts/claude-review.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,16 @@ def call_claude(api_key, base_url, model, prompt):
2929

3030
with urllib.request.urlopen(req, timeout=180) as resp:
3131
result = json.loads(resp.read())
32-
return result["content"][0]["text"]
32+
33+
for block in result.get("content", []):
34+
if block.get("type") == "text" and "text" in block:
35+
return block["text"]
36+
37+
print(
38+
f"Claude response did not include a text content block: {json.dumps(result)[:1000]}",
39+
file=sys.stderr,
40+
)
41+
raise RuntimeError("Claude response missing text content block")
3342

3443

3544
def parse_diff_files(diff_text):

.github/workflows/claude-review.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
env:
6060
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
6161
ANTHROPIC_BASE_URL: ${{ secrets.ANTHROPIC_BASE_URL }}
62-
CLAUDE_MODEL: "Claude Sonnet 4.6"
62+
CLAUDE_MODEL: "claude-sonnet-4-6"
6363
SKILL_PATH: "skills/loongforge-review/SKILL.md"
6464
DIFF_PATH: "/tmp/pr-diff.txt"
6565
PR_TITLE: ${{ steps.meta.outputs.title }}

0 commit comments

Comments
 (0)