google-gemini / google-gemini/gemini-cli

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

Open Beginner friendly
#28,894 1 comment 0 reactions 0 assignees View on GitHub
area/agent kind/bug priority/p2 status/bot-triaged
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.