Gokul Kolady has posted comments on this change. ( https://gerrit.cloudera.org/25448 )
Change subject: IMPALA-15804: Keep tool_calls when AI response also has text content ...................................................................... Patch Set 1: (2 comments) https://gerrit.cloudera.org/#/c/25448/1/be/src/exprs/ai-functions-ir.cc File be/src/exprs/ai-functions-ir.cc: https://gerrit.cloudera.org/#/c/25448/1/be/src/exprs/ai-functions-ir.cc@259 PS1, Line 259: if (message.HasMember(OPEN_AI_RESPONSE_FIELD_TOOL_CALLS) Maybe we could collapse this series of if statements into one block that handles all the checks ie. const bool has_tool_calls = message.HasMember(OPEN_AI_RESPONSE_FIELD_TOOL_CALLS) && message[OPEN_AI_RESPONSE_FIELD_TOOL_CALLS].IsArray(); const bool has_text_content = message.HasMember(OPEN_AI_RESPONSE_FIELD_CONTENT) && message[OPEN_AI_RESPONSE_FIELD_CONTENT].IsString(); // Return the whole message when there are tool_calls for the caller to execute, or // when there is no usable text content. Some models (e.g. Claude) return a text // preamble alongside tool_calls, so tool_calls must win over content. if (has_tool_calls && (!message[OPEN_AI_RESPONSE_FIELD_TOOL_CALLS].Empty() || !has_text_content)) { rapidjson::StringBuffer buffer; rapidjson::Writer<rapidjson::StringBuffer> writer(buffer); message.Accept(writer); return string(buffer.GetString(), buffer.GetSize()); } if (has_text_content) return message[OPEN_AI_RESPONSE_FIELD_CONTENT].GetString(); https://gerrit.cloudera.org/#/c/25448/1/be/src/exprs/expr-test.cc File be/src/exprs/expr-test.cc: https://gerrit.cloudera.org/#/c/25448/1/be/src/exprs/expr-test.cc@11797 PS1, Line 11797: string content_with_tool_calls_response = R"({ Could we add another test case for the fall-through case (response contains only message content with no tool calls)? -- To view, visit https://gerrit.cloudera.org/25448 To unsubscribe, visit https://gerrit.cloudera.org/settings Gerrit-Project: Impala-ASF Gerrit-Branch: master Gerrit-MessageType: comment Gerrit-Change-Id: Ib11531d7130bd718da1b2093a8ffbc06f2a84759 Gerrit-Change-Number: 25448 Gerrit-PatchSet: 1 Gerrit-Owner: Quanlong Huang <[email protected]> Gerrit-Reviewer: Abhishek Rawat <[email protected]> Gerrit-Reviewer: Gokul Kolady <[email protected]> Gerrit-Reviewer: Impala Public Jenkins <[email protected]> Gerrit-Reviewer: Jason Fehr <[email protected]> Gerrit-Reviewer: Quanlong Huang <[email protected]> Gerrit-Reviewer: Yida Wu <[email protected]> Gerrit-Comment-Date: Mon, 16 Nov 2026 18:56:02 +0000 Gerrit-HasComments: Yes
