Skip to content

Bug: Tool not executed when assistant response includes both text and function call (partial handling) #427

@vaib-2310

Description

@vaib-2310

In multi-turn conversations with kubectl-ai, when confirming execution with replies like "sure" or "yes", the assistant often responds with:

"Of course. I'll start by..."
[and correctly identifies a function to execute, e.g., oc4 logs]

However, the function/tool is not executed, even though the logs show the tool call was generated properly. The conversation ends prematurely with:

No function calls were made, so most likely the task is completed
What happened?
The assistant appears to send a response having both:

A partially completed text block ("Of course. I'll start by checking the logs...")

A valid function call, such as:

{"name":"oc4","arguments":{"command":"logs -n d7regserv enrich-credit-pre-9-lp5qn", "modifies_resource":"no"}}
But due to how kubectl-ai parses the response, it logs:

Warning: there are non-text parts FunctionCall in the response, returning concatenation of all text parts.
The tool is then never executed, even though the LLM fully constructed the right action.

Flow ends with:

text
No function calls were made, so most likely the task is completed

⏱️ Steps to Reproduce
Use kubectl-ai and a tool like oc4 (in tools.yaml).

Ask a query that requires action, e.g.:

Check logs for pod enrich-credit-pre-9-lp5qn in namespace d7regserv
Wait for the assistant to reply:

Would you like me to proceed with any of these steps?
Respond with:

sure
Observe that the assistant begins with "I'll start by..." AND generates a tool call — but never executes it.

🔍 Logs (Redacted):

Would you like me to proceed with any of these steps

**iteration=0
response: Of course. I'll start by
response: checking the logs for the enrich-credit-pre-9-lp5qn pod to investigate why its readiness probe is failing
response: .
function calls=[{"name":"oc4","arguments":{"command":"logs -n d7regserv enrich-credit-pre-9-lp5qn","modifies_resource":"no"}}]

Warning: there are non-text parts FunctionCall in the response, returning concatenation of all text parts.
No function calls were made, so most likely the task is completed, so we're done.**

💡 Expected Behavior:

kubectl-ai should recognize the presence of a valid function_call even when combined with text parts, and execute it accordingly.

Even if the LLM generates both response types simultaneously, the system should:

Execute the tool,

Then append the assistant's natural language reasoning (ex: "I'm checking the logs now...").

Version Info:

kubectl-ai version:
version: 0.0.15
commit: 77936f0
date: 2025-07-02T22:57:51Z

Model: Gemini 2.5 Pro

Custom tool: oc4 defined in tools.yaml

Host Cluster: OpenShift

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions