provider: WorkBuddy plugin min 0.2.6, an empty tool_calls is no call (plugins #540)

itspig (plugins #540, 2026-10-31) ran v0.1.2283 with workbuddy 0.2.5 on
the live account in a [workbuddy, volcengine] group: the refusal
"\nSorry, I can't respond to this question.\n" still reached the client
and the workbuddy try was done/200 with firstText 3208, volcengine never
asked.

The cause was in the plugin. copilot.tencent.com puts "tool_calls": []
on every delta (f2c7536d7), and the plugin's unsaid let a reply through
at the first delta with a truthy tool_calls, which [] is in JS. The gate
opened at the reasoning chunk, so the line went on as text and the
gateway, seeing text, rightly took the try as answered. 0.2.5's fixture
came from itspig's paste, read off magpie after chatTidy had dropped the
empty list. workbuddy 0.2.6 (plugins d0d0716) counts only a list with a
call in it.

- The workbuddy mover's min is 0.2.6 (npm view --prefer-online: 0.2.6).
- TestDeepSeekRefusalAfterThinkingFailsOver gets "workbuddy's wire":
  what 0.2.6 hands on from that framing (tool_calls [], finish_reason ""
  until the last, empty reasoning_content and refusal) is refused and b
  answers. The gateway's hold and firstText don't count a delta with
  only role, refusal "" or an empty list as text.

Run on mote, at this tree before the rebase onto origin/main and again
after it (see below):
- go test ./internal/gateway -run
  'TestDeepSeekRefusalAfterThinkingFailsOver|TestWorkBuddy540EndToEnd'
  -count=1: ok.
- go test ./internal/provider -run 'Mover|Moved|Workbuddy|WorkBuddy': ok.
- gofmt -l clean.
- End to end (TestWorkBuddy540EndToEnd, kept out of this commit, since it
  needs the plugin's source beside it): the real workbuddy plugin loaded
  by magpie's plugin host behind a fetch shim to a fake
  copilot.tencent.com, signed in with an API key, in a group
  [workbuddy-plugin/deepseek-v4.1-flash, b/m] under the test's sandbox
  HOME, asked as a streamed chat, a one-body chat, Messages (Claude Code's
  ask) and Responses (Codex's ask), for itspig's paste and for the wire
  framing.

Broken by hand: the same end-to-end test with 0.2.5 (b5cc782) loaded is
red on the wire framing for chat, Messages and Responses (b never asked,
"Sorry" in the reply) and green on the paste, which is what itspig saw.

Not tried: a live WorkBuddy account; the trigger prompt was not run; the
full ./... suite.
This commit is contained in:
yetone
2026-10-31 08:44:46 +08:00
parent 86e19b9b74
commit 5c1ccec4a1
2 changed files with 16 additions and 1 deletions
+15
View File
@@ -200,6 +200,21 @@ func TestDeepSeekRefusalAfterThinkingFailsOver(t *testing.T) {
t.Fatalf("tries: %+v", r.Tries)
}
})
// The same from WorkBuddy's own framing, as workbuddy 0.2.6 hands it
// on: "tool_calls": [] and "finish_reason": "" on every delta, an empty
// reasoning_content beside the line it took out (plugins #540).
wire := sse(`data: {"choices":[{"delta":{"content":"","extra_fields":null,"function_call":null,"reasoning_content":" node","refusal":"","tool_calls":[]},"finish_reason":"","index":0,"logprobs":null}],"created":1793401068,"id":"c56c77084382622efa17c799396db5cf","model":"deepseek-v4.1-flash","object":"chat.completion.chunk","usage":null}`,
`data: {"choices":[{"delta":{"extra_fields":null,"function_call":null,"reasoning_content":"","refusal":"","role":"assistant","tool_calls":[]},"finish_reason":"content_filter","index":0,"logprobs":null}],"created":0,"id":"c56c77084382622efa17c799396db5cf","model":"deepseek-v4.1-flash","object":"chat.completion.chunk","usage":null}`,
`data: [DONE]`)
t.Run("workbuddy's wire", func(t *testing.T) {
a, b, s, code, body := run(t, wire)
if code != 200 || !strings.Contains(body, "from b") || strings.Contains(body, " node") || a.n != 1 || b.n != 1 {
t.Fatalf("%d %s (a %d, b %d)", code, body, a.n, b.n)
}
if r := lastRoute(s); len(r.Tries) != 2 || r.Tries[0].Fail != failRefused {
t.Fatalf("tries: %+v", r.Tries)
}
})
t.Run("answered", func(t *testing.T) {
a, b, _, code, body := run(t, answered)
if code != 200 || !strings.Contains(body, "The user is asking") || !strings.Contains(body, "from a") || strings.Contains(body, "from b") || a.n != 1 || b.n != 0 {
File diff suppressed because one or more lines are too long