GoogleCloudPlatform/kubectl-ai

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

开放

#427 创建于 2025年7月21日

 (2 条评论) (1 个反应) (0 位负责人)Go (708 个派生)auto 404
buggood first issue

仓库指标

星标
 (7,532 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

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: 77936f0d85d0f2bf8d421ea7b915b80a76fdcd0e date: 2025-07-02T22:57:51Z

Model: Gemini 2.5 Pro

Custom tool: oc4 defined in tools.yaml

Host Cluster: OpenShift

贡献者指南