MCPcopy Create free account
hub / github.com/codehamr/codehamr / TestPackDropsDanglingPartialParallelGroup

Function TestPackDropsDanglingPartialParallelGroup

internal/ctx/ctx_test.go:308–326  ·  view source on GitHub ↗

TestPackDropsDanglingPartialParallelGroup: cancelling a parallel round after only some results return leaves assistant(c1,c2)+tool(c1). The assistant has an unanswered call (c2), so it must be dropped, and dropOrphanTools must then clean up the now-orphaned tool(c1).

(t *testing.T)

Source from the content-addressed store, hash-verified

306 // no tool(c1): the user Ctrl+C'd before it finished
307 {Role: RoleUser, Content: "actually, do this instead"},
308 }
309 r := Pack(history, 100000)
310 for _, m := range r.Messages {
311 if m.Role == RoleAssistant && len(m.ToolCalls) > 0 {
312 t.Fatalf("dangling assistant.tool_calls survived pack: %+v", r.Messages)
313 }
314 }
315 // Both user messages must remain, only the unpaired assistant is dropped.
316 if len(r.Messages) != 2 {
317 t.Fatalf("want 2 user messages kept, got %d: %+v", len(r.Messages), r.Messages)
318 }
319}
320
321// TestPackDropsDanglingPartialParallelGroup: cancelling a parallel round after
322// only some results return leaves assistant(c1,c2)+tool(c1). The assistant has
323// an unanswered call (c2), so it must be dropped, and dropOrphanTools must then
324// clean up the now orphaned tool(c1).
325func TestPackDropsDanglingPartialParallelGroup(t *testing.T) {
326 history := []Message{
327 {Role: RoleUser, Content: "do two things"},
328 {Role: RoleAssistant, ToolCalls: []ToolCall{
329 {ID: "c1", Name: "bash"}, {ID: "c2", Name: "bash"},

Callers

nothing calls this directly

Calls 1

PackFunction · 0.85

Tested by

no test coverage detected