From 82e59160e128fc056082f13e268b0de3cf842cdb Mon Sep 17 00:00:00 2001 From: Simba Zhang Date: Thu, 5 Nov 2026 19:45:04 -0800 Subject: [PATCH 1/2] test: fail test 4b on failed tool request and wrong finish_reason Test 4b only FAILed when the reply contained tool-call text. An HTTP error or timeout, and a parsed get_weather call with finish_reason "stop" (the #262 regression), both fell through to SKIP and the script exited 0. SKIP is now kept only for a reply with no tool-call shape. Fixes #266 Co-Authored-By: Claude Haiku 5.5 --- tests/test-dflash.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/test-dflash.sh b/tests/test-dflash.sh index a110c58..a418457 100755 --- a/tests/test-dflash.sh +++ b/tests/test-dflash.sh @@ -225,8 +225,14 @@ TOOL_RESP=$(curl -sf --max-time 180 -X POST "$URL/v1/chat/completions" \ TOOL_NAME=$(echo "$TOOL_RESP" | jq -r '.choices[0].message.tool_calls[0].function.name // empty' 2>/dev/null || echo "") TOOL_CONTENT=$(echo "$TOOL_RESP" | jq -r '.choices[0].message.content // empty' 2>/dev/null || echo "") TOOL_FINISH=$(echo "$TOOL_RESP" | jq -r '.choices[0].finish_reason // empty' 2>/dev/null || echo "") +# SKIP is reserved for a reply with no tool-call shape at all. A failed request (HTTP error +# or timeout) and a parsed tool call with the wrong finish_reason are regressions, so FAIL. if [ "$TOOL_NAME" = "get_weather" ] && [ "$TOOL_FINISH" = "tool_calls" ]; then pass "DFlash tool call parsed: tool_calls[0]=get_weather, finish_reason=tool_calls" +elif [ -z "$TOOL_RESP" ]; then + fail "tool request failed (HTTP error or timeout)" +elif [ -n "$TOOL_NAME" ]; then + fail "tool call parsed but finish_reason=$TOOL_FINISH" elif echo "$TOOL_CONTENT" | grep -q "tool_call\|get_weather"; then fail "DFlash handed the tool call over as text: $(echo "$TOOL_CONTENT" | head -c 120)" else From d2494f9a38a802eede8207d1dbacd52da47db749 Mon Sep 17 00:00:00 2001 From: Simba Zhang Date: Thu, 5 Nov 2026 22:45:08 -0800 Subject: [PATCH 2/2] test: FAIL test 4b on a body cut off mid-way and on a 200 with no choices Test 4b captured curl output with `|| echo ""`, so a response cut off after a few bytes was non-empty. jq then parsed nothing, and the test fell through to SKIP and exited 0. A 200 whose body is not a chat completion (for example an error object) also SKIPped. Capture the curl exit status and FAIL on non-zero. FAIL when the response has no `choices[0]`. SKIP stays for a valid reply with no tool-call shape. Verified by running the 4b block against a fake server in each mode: | server reply | before (82e5916) | after | |-------------------------|------------------|------------| | HTTP 500 | FAIL | FAIL | | empty 200 body | FAIL | FAIL | | body cut off mid-way | SKIP (exit 0) | FAIL | | 200 error object | SKIP (exit 0) | FAIL | | tool call, finish=stop | FAIL | FAIL | | plain text reply | SKIP | SKIP | | correct tool call | PASS | PASS | Co-Authored-By: Claude Haiku 5.5 --- tests/test-dflash.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/test-dflash.sh b/tests/test-dflash.sh index a418457..968ae81 100755 --- a/tests/test-dflash.sh +++ b/tests/test-dflash.sh @@ -219,18 +219,22 @@ fi # a capability, not a contract, so a reply without any tool-call shape reports SKIP. log "Test 4b: a tool call under DFlash arrives as tool_calls, not as text" TOOLS='[{"type":"function","function":{"name":"get_weather","description":"Get the current weather for a city","parameters":{"type":"object","properties":{"city":{"type":"string"}},"required":["city"]}}}]' +TOOL_RC=0 TOOL_RESP=$(curl -sf --max-time 180 -X POST "$URL/v1/chat/completions" \ -H "Content-Type: application/json" \ - -d "{\"model\":\"$MAIN_MODEL\",\"max_tokens\":120,\"temperature\":0,\"tools\":$TOOLS,\"messages\":[{\"role\":\"system\",\"content\":\"You are a weather kiosk. Call get_weather for any weather question and say nothing else.\"},{\"role\":\"user\",\"content\":\"What is the weather in Paris right now?\"}]}" 2>/dev/null || echo "") + -d "{\"model\":\"$MAIN_MODEL\",\"max_tokens\":120,\"temperature\":0,\"tools\":$TOOLS,\"messages\":[{\"role\":\"system\",\"content\":\"You are a weather kiosk. Call get_weather for any weather question and say nothing else.\"},{\"role\":\"user\",\"content\":\"What is the weather in Paris right now?\"}]}" 2>/dev/null) || TOOL_RC=$? TOOL_NAME=$(echo "$TOOL_RESP" | jq -r '.choices[0].message.tool_calls[0].function.name // empty' 2>/dev/null || echo "") TOOL_CONTENT=$(echo "$TOOL_RESP" | jq -r '.choices[0].message.content // empty' 2>/dev/null || echo "") TOOL_FINISH=$(echo "$TOOL_RESP" | jq -r '.choices[0].finish_reason // empty' 2>/dev/null || echo "") -# SKIP is reserved for a reply with no tool-call shape at all. A failed request (HTTP error -# or timeout) and a parsed tool call with the wrong finish_reason are regressions, so FAIL. +# SKIP is reserved for a reply with no tool-call shape at all. A failed request (HTTP error, +# timeout, or a body cut off mid-way), a 200 that is not a chat completion, and a parsed tool +# call with the wrong finish_reason are regressions, so FAIL. if [ "$TOOL_NAME" = "get_weather" ] && [ "$TOOL_FINISH" = "tool_calls" ]; then pass "DFlash tool call parsed: tool_calls[0]=get_weather, finish_reason=tool_calls" -elif [ -z "$TOOL_RESP" ]; then - fail "tool request failed (HTTP error or timeout)" +elif [ "$TOOL_RC" -ne 0 ]; then + fail "tool request failed (curl exit $TOOL_RC: HTTP error, timeout, or body cut off)" +elif ! echo "$TOOL_RESP" | jq -e '.choices[0]' >/dev/null 2>&1; then + fail "tool response is not a chat completion (no choices): $(echo "$TOOL_RESP" | head -c 120)" elif [ -n "$TOOL_NAME" ]; then fail "tool call parsed but finish_reason=$TOOL_FINISH" elif echo "$TOOL_CONTENT" | grep -q "tool_call\|get_weather"; then