From f4d5e779a5c1a4e87a791865890319eeacc60e26 Mon Sep 17 00:00:00 2001 From: JianFeeeee Date: Sun, 11 Oct 2026 13:00:46 +0800 Subject: [PATCH] =?UTF-8?q?chore(lua):=20=E7=A7=BB=E9=99=A4=E8=AF=AF?= =?UTF-8?q?=E5=85=A5=E7=9A=84=E4=B8=B4=E6=97=B6=E5=A4=8D=E7=8E=B0=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=20zz=5Frepro=5Ftest.go?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 上一条 commit 用 git add -A 时把工作树里一个未跟踪的临时复现脚本 (zz_repro_test.go,注释自称「临时复现」)一并扫了进去。它不属本次范围: 不对任何东西做断言(只有 t.Logf),且它探查的 anthropic 空数组问题 在 main 上同样存在,是既有行为,不由本分支引入。 顺带确认它想复现的那个形状:唯一命中的是 `"messages":{}` —— 空 Lua 数组经 luaTableToGoValue 变成 JSON 对象而非 空数组。这确实是个真问题(Anthropic 会拒),但它在 main 上就存在,属 独立缺陷,不在线格式 v2 分支的处理范围。已记入 plan.md 已知遗留。 --- internal/lua/zz_repro_test.go | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 internal/lua/zz_repro_test.go diff --git a/internal/lua/zz_repro_test.go b/internal/lua/zz_repro_test.go deleted file mode 100644 index 9387e4f..0000000 --- a/internal/lua/zz_repro_test.go +++ /dev/null @@ -1,30 +0,0 @@ -package lua - -import ( - "strings" - "testing" -) - -// 临时复现:内核发出的 assistant(content=null)+tool_calls 形状, -// 经 anthropic.lua 转换后 content 是否变成对象 {}(上游期望数组)。 -func TestZZReproAnthropicEmptyBlocks(t *testing.T) { - vm := NewVM(freshAdapterDir(t)) - if err := vm.Start(); err != nil { - t.Fatal(err) - } - defer vm.Stop() - - cases := map[string]string{ - "assistant content=null + tool_calls": `{"model":"x","messages":[{"role":"user","content":"hi"},{"role":"assistant","content":null,"tool_calls":[{"id":"c1","type":"function","function":{"name":"f","arguments":"{}"}}]},{"role":"tool","tool_call_id":"c1","content":"ok"}]}`, - "assistant content=空串 + tool_calls": `{"model":"x","messages":[{"role":"user","content":"hi"},{"role":"assistant","content":"","tool_calls":[{"id":"c1","type":"function","function":{"name":"f","arguments":"{}"}}]},{"role":"tool","tool_call_id":"c1","content":"ok"}]}`, - "仅 system": `{"model":"x","messages":[{"role":"system","content":"s"}]}`, - } - for name, body := range cases { - out, err := vm.Transform("anthropic", "transform_request", body) - if err != nil { - t.Fatalf("%s: %v", name, err) - } - bad := strings.Contains(out, `"content":{}`) - t.Logf("%-38s content为对象{}: %v\n out=%s", name, bad, out) - } -}