TestToolCallLeakWarningDetectsStrandedXML: a turn ending with leaked tool-call XML stranded in the newest assistant message warns the user; clean text doesn't, and only the NEWEST assistant message is inspected.
(t *testing.T)
| 2231 | if msg.Role == chmctx.RoleSystem && strings.Contains(msg.Content, "acceptance criteria") { |
| 2232 | nudges++ |
| 2233 | } |
| 2234 | } |
| 2235 | if nudges != 1 { |
| 2236 | t.Fatalf("expected exactly one finish re-grounding note in history, got %d", nudges) |
| 2237 | } |
| 2238 | if final.phase != phaseIdle { |
| 2239 | t.Fatalf("turn must end idle after the re-grounded finish, phase=%v", final.phase) |
| 2240 | } |
| 2241 | } |
| 2242 | |
| 2243 | // TestEndTurnResetsVerifyNudged: the latch is per-turn, so endTurn must clear it |
| 2244 | // or a later turn never re-grounds. |
| 2245 | func TestEndTurnResetsVerifyNudged(t *testing.T) { |
| 2246 | m := newTestModel(t, func(http.ResponseWriter, *http.Request) {}) |
| 2247 | m.installTurnContext() |
| 2248 | m.verifyNudged = true |
| 2249 | m.endTurn() |
| 2250 | if m.verifyNudged { |
| 2251 | t.Fatal("endTurn must reset verifyNudged") |
| 2252 | } |
| 2253 | } |
| 2254 | |
| 2255 | // TestToolCallLeakWarningDetectsStrandedXML: a turn ending with leaked |
| 2256 | // tool-call XML stranded in the newest assistant message warns the user; clean |
| 2257 | // text doesn't, and only the NEWEST assistant message is inspected. |
| 2258 | func TestToolCallLeakWarningDetectsStrandedXML(t *testing.T) { |
| 2259 | // XML tool-call body. |
| 2260 | coderLeak := "Let me search.\n<tool_call>\n<function=bash>\n<parameter=cmd>ls</parameter>\n</function>\n</tool_call>" |
| 2261 | // General JSON tool-call body, the target model class, NO `<function=`. |
| 2262 | denseLeak := "Let me search.\n<tool_call>\n{\"name\": \"bash\", \"arguments\": {\"cmd\": \"ls\"}}\n</tool_call>" |
| 2263 | clean := "Done - built and tested, all green." |
| 2264 | |
| 2265 | for name, leak := range map[string]string{"coder-xml": coderLeak, "dense-json": denseLeak} { |
| 2266 | if w := toolCallLeakWarning([]chmctx.Message{{Role: chmctx.RoleAssistant, Content: leak}}); w == "" { |
| 2267 | t.Fatalf("%s: leaked tool call must produce a warning", name) |
| 2268 | } |
| 2269 | } |
| 2270 | if w := toolCallLeakWarning([]chmctx.Message{{Role: chmctx.RoleAssistant, Content: clean}}); w != "" { |
| 2271 | t.Fatalf("clean reply must not warn, got %q", w) |
nothing calls this directly
no test coverage detected