google-gemini / google-gemini/gemini-cli
bug: mixed function-call model turns are not recognized as tool turns
- Dominant language
- TypeScript
- Stars
- 107k
- Forks
- 14.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 45
Description
### 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.
Contributor guide
Research direction
Start in packages/core/src/utils/messageInspectors.ts and compare isFunctionCall() with isFunctionResponse(). Trace how ClassifierStrategy uses these inspectors, then add regression coverage for a mixed thought and function-call turn. Done means any model turn containing at least one functionCall is recognized and the regression coverage passes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- ai, cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 88/100