Skip to content

bug: isFunctionCall and isFunctionResponse return true for empty parts arrays #23195

Description

@PewterZz

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/agentIssues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Qualityeffort/small1 day or less: trivial logic, UI adjustments, docskind/bugpriority/p2Important but can be addressed in a future release.status/bot-triagedstatus/possible-duplicate

    Type

    No fields configured for Bug.

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions