From 0e82253686d1d4063f6496b4e4f41ed684cfcb27 Mon Sep 17 00:00:00 2001 From: BaaRai <130491490+BaaRai@users.noreply.github.com> Date: Sat, 10 Oct 2026 19:19:34 +0200 Subject: [PATCH] Bot: quote the response_format JSON for --argjson --argjson requires strict JSON; the unquoted-key object made jq fail, sent an empty request body, and the triage died with 'model returned nothing'. Also log the raw API response when choices is missing so the next failure shows its cause immediately. --- .github/scripts/bot.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/scripts/bot.sh b/.github/scripts/bot.sh index cc51d22..2e3ad60 100644 --- a/.github/scripts/bot.sh +++ b/.github/scripts/bot.sh @@ -25,17 +25,23 @@ repo="$GITHUB_REPOSITORY" ask_model() { # $1 = system prompt, $2 = user payload, $3 = "json" for JSON mode; prints the answer local body="${2:0:$MAX_CHARS}" extra - local req + local req resp extra='{}' - [ "${3:-}" = "json" ] && extra='{response_format: {type: "json_object"}}' + [ "${3:-}" = "json" ] && extra='{ "response_format": { "type": "json_object" } }' req=$(jq -n --arg sys "$1" --arg body "$body" --argjson extra "$extra" \ '{model: "deepseek-flash", messages: [{role: "system", content: $sys}, {role: "user", content: $body}], max_tokens: 900, temperature: 0} * $extra') - curl -sS --max-time 120 https://api.deepseek.com/chat/completions \ + resp=$(curl -sS --max-time 120 https://api.deepseek.com/chat/completions \ -H "Authorization: Bearer $DEEPSEEK_API_KEY" \ -H 'Content-Type: application/json' \ - -d "$req" | jq -r '.choices[0].message.content // empty' + -d "$req") + if ! jq -e '.choices[0].message.content' <<<"$resp" >/dev/null 2>&1; then + log "api call failed, raw response: ${resp:0:300}" + echo "" + return + fi + jq -r '.choices[0].message.content' <<<"$resp" } repo_context() { git ls-files | head -120; }