You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit e4d397f
Browse filesBrowse the repository at this point in the historyBrowse files
Bound get_schema results for very wide tables in the SQL toolsets (#74017)
## What
`get_schema` in `SQLToolset` and `DataFusionToolset` returned every column of a
table with no bound. On a table with a few thousand columns that is a
six-figure-byte tool result, and because an agent calls `get_schema` before it
can write a query, the result enters message history early and its cost is
re-paid on every later model request. On a several-thousand-column table an
agent could exhaust its context before issuing a single query, even after
#71317 bounded the `query` tool.
#71317 deliberately left `get_schema` alone, because the same fix does not
transfer: column names are the information the agent needs to write SQL, so
truncating to the first N columns leaves it unable to reference or discover the
rest.
## How
`get_schema` now mirrors the `query` tool's bounded-output contract:
- It returns a JSON object `{"columns": [{"name", "type"}, ...], "column_count":
N}` instead of a bare list.
- It accepts an optional `name_contains` substring filter, so the agent can ask
for the columns relevant to its question on a wide table.
- Above `max_columns` (new constructor argument, default 100) or the existing
`max_result_bytes` budget, the full list is replaced by a bounded summary:
`column_count`, a `type_histogram`, a `sample_columns` preview, and
`truncated` / `truncated_by` / `hint` that name the limit hit and point back
at `name_contains`.
Both toolsets move together. The shared logic lives in `build_schema_result`
next to `build_query_result` in `query_results.py`. The provider changelog
records the tool-result shape change, and the toolset docs gain a "Bounded
schema results" section.
---
##### Was generative AI tooling used to co-author this PR?
- [X] Yes - Claude Code (Opus 4.8)
Generated-by: Claude Code (Opus 4.8) following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
---
🤖 Generated with [Claude Code](https://claude.com/claude-code)
0 commit comments