MCPcopy Create free account
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 {Role: RoleAssistant, Content: "reply"},
155 }
156 // Tight enough to drop the first assistant, loose enough that the tool
157 // message would otherwise survive. Tuned against the +8 per-message overhead.
158 r := Pack(history, 30)
159 for _, m := range r.Messages {
160 if m.Role == RoleTool {
161 t.Fatalf("orphan tool message survived pack: %+v", r.Messages)
162 }
163 }
164 if len(r.Messages) == 0 {
165 t.Fatal("newest assistant should have survived")
166 }
167}
168
169// TestPackDropsEmptyIDToolMessages: an empty-ID tool_call must not let
170// subsequent empty-ToolCallID tool messages ride through as "paired". An
171// unidentifiable tool message can never be paired, so it's always dropped,
172// else OpenAI-compat backends 400 on the bare tool message.
173func TestPackDropsEmptyIDToolMessages(t *testing.T) {
174 history := []Message{
175 // Malformed assistant with a missing tool_call id (server bug).

Callers

nothing calls this directly

Calls 1

PackFunction · 0.85

Tested by

no test coverage detected