Skip to content

bug: mixed function-call model turns are not recognized as tool turns #28894

Description

@sylvesterkaczmarek

What happened?

isFunctionCall() in packages/core/src/utils/messageInspectors.ts currently requires every part in a model turn to contain functionCall.

That misses valid mixed model turns containing a function call alongside another part, for example a thought plus a tool call.

This matters in ClassifierStrategy, which removes tool-related turns from routing history using isFunctionCall() and isFunctionResponse().

isFunctionResponse() already detects a function response among sibling parts, so the subsequent function-response turn is removed while the mixed model function-call turn is retained. The classifier can therefore receive an unmatched function-call turn.

Expected behavior

A model turn containing at least one functionCall should be recognized as a function-call turn even when sibling thought/text parts are present.

Suggested fix

Use content.parts.some((part) => !!part.functionCall) and add regression coverage for a mixed thought + function-call turn.

Found by source audit on current main.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/agentIssues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Qualitykind/bugpriority/p2Important but can be addressed in a future release.status/bot-triaged

    Type

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions