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

Function TestPackRecoveryDropsPartialParallelGroup

internal/ctx/ctx_test.go:259–278  ·  view source on GitHub ↗

TestPackRecoveryDropsPartialParallelGroup: the empty-recovery path (newest is a tool result whose owner fell past a tight budget) must not resurrect a partially-answered parallel group as a dangling assistant. owner issued c1,c2 but only c1 came back; newestToolGroup recovers [assistant(c1,c2), tool

(t *testing.T)

Source from the content-addressed store, hash-verified

257}
258
259// TestPackRecoveryDropsPartialParallelGroup: the empty-recovery path (newest is
260// a tool result whose owner fell past a tight budget) must not resurrect a
261// partially-answered parallel group as a dangling assistant. owner issued c1,c2
262// but only c1 came back; newestToolGroup recovers [assistant(c1,c2), tool(c1)],
263// which must then be stripped to nothing rather than reaching the wire and 400ing.
264func TestPackRecoveryDropsPartialParallelGroup(t *testing.T) {
265 bigArgs := strings.Repeat("y", 4*5000) // owner far over the tight budget below
266 history := []Message{
267 {Role: RoleUser, Content: "do two things"},
268 {Role: RoleAssistant, ToolCalls: []ToolCall{
269 {ID: "c1", Name: "bash", Arguments: map[string]any{"cmd": bigArgs}},
270 {ID: "c2", Name: "bash"},
271 }},
272 {Role: RoleTool, ToolCallID: "c1", Content: "out1"}, // c2 result never arrived
273 }
274 r := Pack(history, 300) // forces the budget walk + drops to empty, then recovery
275 for _, m := range r.Messages {
276 if m.Role == RoleAssistant && len(m.ToolCalls) > 0 {
277 t.Fatalf("dangling partial-parallel assistant reached the wire: %+v", r.Messages)
278 }
279 if m.Role == RoleTool {
280 t.Fatalf("orphaned tool survived after its assistant was dropped: %+v", r.Messages)
281 }

Callers

nothing calls this directly

Calls 1

PackFunction · 0.85

Tested by

no test coverage detected