genai-toolbox icon indicating copy to clipboard operation
genai-toolbox copied to clipboard

implement `orderedmap` to all tools to preserve column order in SQL restults

Open feng-1985 opened this issue 5 months ago • 2 comments

Prerequisites

Question

I am using the ToolboxClient (with mysql), and notice that the sql statement's column order is not the same with the result of sql.

Such as: sql statement in the yaml "select start_time, end_time, course_date from course"

when check the input of llm (the result of sql) or run tool using toolbox ui: {"course_date":"2025-09-15", "end_time":"2025-09-15 10:10:00", "start_time":"2025-09-15 11:30:00"}

It seems very subtle, but sometime confuse the llm the understanding when the order is meaningful.

Code

No response

Additional Details

No response

feng-1985 avatar Sep 17 '25 06:09 feng-1985

@feng-1985 Thankyou for opening this issue! Golang sorts map by keys during json.Marshal(). But seems like this could potentially be resolved by creating a custom Marshal() function. I'll open this issue up for contributions

Yuan325 avatar Sep 22 '25 17:09 Yuan325

orderedmap is introduced and implemented within the execute_sql tools in #1852. We will still have to expand this feature to all other tools.

Yuan325 avatar Nov 05 '25 18:11 Yuan325