Repository navigation
fix: expose SQL result truncation and reject duplicate output columns - #331
Open
seyoung4503 wants to merge 1 commit into
Open
seyoung4503 wants to merge 1 commit into
seyoung4503 wants to merge 1 commit into
Conversation
This was referenced Nov 26, 2026
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.
SQL tool responses can lose information deterministically: the renderer labels a bounded fetch as total rows, and SQLAlchemy row-to-dict conversion silently overwrites duplicate column names.
Fetch one lookahead row after the unchanged safety decision, retain only the configured budget, and report fetched/displayed counts, fetch/display truncation and whether safety changed the SQL. Counts describe the executed SQL, not source-table cardinality. Detect duplicate result-column names before dict conversion, including empty results, and return an actionable error requiring unique aliases instead of silently losing values. Existing unique aliases execute normally.
Verification: six real MCP stdio regressions failed before implementation. After the fix, the full root suite has 267 passed and 1 skipped; Ruff and diff checks pass. Coverage includes exact boundary, overflow, empty results, display-only truncation, preserved safety SQL cap, duplicate labels and successful retry with unique labels. A model-free replay of the existing local003 query against the read-only benchmark DB through actual MCP confirms fetched_rows=1000, displayed_rows=50 and fetch_truncated=true. Evidence is committed under bench/accuracy/mcp-review-results/deterministic-result-completeness. This demonstrates result fidelity, not a benchmark accuracy increase.
No prompt changes. Based on #326, independently of later prompt experiments. SQLAlchemy duplicate-label validation covers that adapter; other adapters cannot recover columns already collapsed by an upstream JSON API. No merge.
Reuse: existing RunSQL, _render_rows, SqlAlchemyExplorer and actual stdio test fixture. No new production functions; production net +21 lines. Existing display limit is named, not changed. No environment variables or deployment changes.