fix: preallocate slice in tests and add ResponseHandled guard in toolloop

Fix prealloc linter failure in load_image_test.go.

Prevent double-resolving media by checking ResponseHandled in toolloop.go.
This commit is contained in:
reusu 2026-03-30 17:58:17 +08:00
parent c65f53a3c5
commit f47ec78e1e
2 changed files with 2 additions and 2 deletions

View file

@ -124,7 +124,7 @@ func TestLoadImage_SuccessPath(t *testing.T) {
0xAE, 0x42, 0x60, 0x82, // CRC
}
var pngData []byte
pngData := make([]byte, 0, len(pngSignature)+len(ihdr)+len(iend))
pngData = append(pngData, pngSignature...)
pngData = append(pngData, ihdr...)
pngData = append(pngData, iend...)

View file

@ -190,7 +190,7 @@ func RunToolLoop(
Content: contentForLLM,
ToolCallID: r.tc.ID,
}
if len(r.result.Media) > 0 {
if len(r.result.Media) > 0 && !r.result.ResponseHandled {
toolMsg.Media = append(toolMsg.Media, r.result.Media...)
}
messages = append(messages, toolMsg)