MCPcopy Index your code
hub / github.com/codehamr/codehamr / TestPackDropsEmptyIDToolMessages

Function TestPackDropsEmptyIDToolMessages

internal/ctx/ctx_test.go:156–172  ·  view source on GitHub ↗

TestPackDropsEmptyIDToolMessages: an empty-ID tool_call must not let subsequent empty-ToolCallID tool messages ride through as "paired". An unidentifiable tool message can never be paired, so it's always dropped, else OpenAI-compat backends 400 on the bare tool message.

(t *testing.T)

Source from the content-addressed store, hash-verified

154// unidentifiable tool message can never be paired, so it's always dropped,
155// else OpenAI-compat backends 400 on the bare tool message.
156func TestPackDropsEmptyIDToolMessages(t *testing.T) {
157 history := []Message{
158 // Malformed assistant with a missing tool_call id (server bug).
159 {Role: RoleAssistant, ToolCalls: []ToolCall{{ID: "", Name: "bash"}}},
160 // Looks paired via the empty ID; must be dropped anyway.
161 {Role: RoleTool, ToolCallID: "", Content: "from empty1"},
162 // Clearly orphan, nothing to pair with.
163 {Role: RoleTool, ToolCallID: "", Content: "TRULY ORPHAN"},
164 {Role: RoleAssistant, Content: "final"},
165 }
166 r := Pack(history, 100000)
167 for _, m := range r.Messages {
168 if m.Role == RoleTool {
169 t.Fatalf("empty-ID tool message survived pack: %+v (full kept set: %+v)", m, r.Messages)
170 }
171 }
172}
173
174// TestPackKeepsPairedToolMessage: a healthy assistant+tool pair that fits the
175// budget stays intact: don't regress into dropping good pairs.

Callers

nothing calls this directly

Calls 1

PackFunction · 0.85

Tested by

no test coverage detected