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.
What happened?
isFunctionCall()inpackages/core/src/utils/messageInspectors.tscurrently requires every part in a model turn to containfunctionCall.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 usingisFunctionCall()andisFunctionResponse().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
functionCallshould 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.