Repository navigation
fix(llm): build /llm schema without GROUP_CONCAT truncation - #2492
Merged
rolandwalker merged 1 commit intoDec 3, 2026
Merged
Conversation
GROUP_CONCAT output is silently cut at group_concat_max_len (1024 bytes by default on MySQL), so wide tables lost columns in the schema sent to the LLM. Fetch columns ordered by table and ordinal position and group them in Python instead. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
get_schema()in the/llmspecial command built each table's line of theschema prompt with
GROUP_CONCAT(column_name, ' ', COLUMN_TYPE SEPARATOR ', ').MySQL silently truncates
GROUP_CONCATresults atgroup_concat_max_len,which is 1024 bytes by default on MySQL 8 (with only a warning), so for
tables with many columns the schema sent to the LLM lost its trailing columns
and the closing parenthesis. The
GROUP_CONCATalso had noORDER BY, so thecolumn order within a table was not guaranteed.
The query now selects
table_name, column_name, COLUMN_TYPEfrominformation_schema.columnsordered bytable_name, ordinal_position, andthe columns are grouped per table in Python. The output format is the same
(
table(col type, col type)), with no length limit and columns indefinition order.
Tests: added
test_get_schema_groups_columns_without_group_concat_truncation(a 100-column table whose concatenated definition is well over 1024 bytes,
plus a second table), and updated the two existing dummy cursors to return
per-column rows. The new test fails on
mainand passes with the change;mycli_test/pytests/test_special_llm.pypasses (34 tests).Checklist
changelog.mdfile.mycli/AUTHORS.txtfile (or it's already there).This PR was prepared with the assistance of Claude Code (AI).