What happened?
isFunctionCall() and isFunctionResponse() in messageInspectors.ts return true for messages with empty parts arrays. This happens because Array.every([]) is vacuously true in JavaScript.
This means any message with role: "model" and parts: [] is incorrectly classified as a function call, and any message with role: "user" and parts: [] is incorrectly classified as a function response.
// Current behavior:
[].every((part) => !!part.functionCall) // => true (vacuous truth)
What did you expect to happen?
Both functions should return false when parts is an empty array, since there are no actual function call or function response parts present.
Client information
Found via code review. The file has no existing test coverage.
Login information
No response
Anything else we need to know?
No response
What happened?
isFunctionCall()andisFunctionResponse()inmessageInspectors.tsreturntruefor messages with emptypartsarrays. This happens becauseArray.every([])is vacuouslytruein JavaScript.This means any message with
role: "model"andparts: []is incorrectly classified as a function call, and any message withrole: "user"andparts: []is incorrectly classified as a function response.What did you expect to happen?
Both functions should return
falsewhenpartsis an empty array, since there are no actual function call or function response parts present.Client information
Found via code review. The file has no existing test coverage.
Login information
No response
Anything else we need to know?
No response