scripts/scrum_review: pipe diff via temp files — fixes argv overflow on large bundles

`jq --arg` and `curl --data-binary @-` both read stdin/argv-bound
buffers. Diffs >~128KB blow past the kernel's argv limit even when
piped via stdin (because we still build `body` as a shell variable
first, then feed it to curl). Voice-ai full bundle was 156K and
hit it.

Switch to writing user/system/body to mktemp files, jq reads via
--rawfile, curl reads via @file. Same on-the-wire shape, no argv
involvement. Cleanup with rm at the end.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
root 2026-04-30 19:57:34 -05:00
parent 68d9e554b0
commit a2fa9a2ce7

View File

@ -75,20 +75,27 @@ run_review() {
\`\`\`diff \`\`\`diff
$DIFF_CONTENT $DIFF_CONTENT
\`\`\`" \`\`\`"
local body
body=$(jq -n --arg model "$model" --arg sys "$SYSTEM" --arg user "$user" \
'{model:$model, max_tokens:4096, messages:[{role:"system",content:$sys},{role:"user",content:$user}]}')
printf " %-6s %s ... " "$short" "$model" printf " %-6s %s ... " "$short" "$model"
local t0=$SECONDS local t0=$SECONDS
local status local status
# Pipe the body via stdin (`-d @-`) — large diffs (>~128KB) blow
# past the kernel's argv limit when passed via `--data <literal>`. # Build the body via temp files — both jq's --arg AND curl's
# Phase A+B was 128875 bytes and hit "Argument list too long" until # --data run into the kernel's argv limit (~128KB) when the diff
# this fix. # is large. Voice-ai full bundle was 156K and hit it twice.
status=$(printf '%s' "$body" | curl -sS -o /tmp/scrum_resp.json -w '%{http_code}' --max-time 240 \ # Piping through files (and using --rawfile for jq) sidesteps both.
local body_file user_file sys_file
body_file=$(mktemp); user_file=$(mktemp); sys_file=$(mktemp)
printf '%s' "$user" > "$user_file"
printf '%s' "$SYSTEM" > "$sys_file"
jq -n --arg model "$model" --rawfile sys "$sys_file" --rawfile user "$user_file" \
'{model:$model, max_tokens:4096, messages:[{role:"system",content:$sys},{role:"user",content:$user}]}' \
> "$body_file"
status=$(curl -sS -o /tmp/scrum_resp.json -w '%{http_code}' --max-time 240 \
-X POST "$GATEWAY/v1/chat" \ -X POST "$GATEWAY/v1/chat" \
-H 'Content-Type: application/json' \ -H 'Content-Type: application/json' \
--data-binary @-) --data-binary "@$body_file")
rm -f "$body_file" "$user_file" "$sys_file"
local elapsed=$((SECONDS - t0)) local elapsed=$((SECONDS - t0))
if [ "$status" != "200" ]; then if [ "$status" != "200" ]; then
printf "✗ HTTP %s (%ds)\n" "$status" "$elapsed" printf "✗ HTTP %s (%ds)\n" "$status" "$elapsed"