Repository navigation
Conversation
An offloaded response is moved into session SQL so the tool result stays small, but the handle still carried every column name and up to five unbounded preview rows. A response that is wide rather than tall, or one with long text cells, put most of the payload back on the handle. Cap the preview at 4 KB, shortening string cells (and the text form of other cells such as BLOBs) over 200 characters with a marker giving the full length, and cap the schema at 60 columns within 4 KB. The preview keeps whole rows only, so every row it returns has every column; a first row wider than the budget alone is kept up to the budget so the preview is not empty. preview_truncated and schema_column_count (the full column count) appear only when a bound applied, and are set after caller metadata so a keyword cannot replace them. Stored values are unchanged, and handles within the bounds are identical to before.
Comusus
requested review from
Rahul-1404,
anniewn,
bhatia-di,
callnmm,
chittev,
finklen-amazon,
johnwangwyx,
shsrams,
somsubhro and
wangyuhere
as code owners
October 16, 2026 17:36
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4790 +/- ##
=======================================
Coverage 93.55% 93.55%
=======================================
Files 1068 1068
Lines 92344 92394 +50
Branches 15025 15035 +10
=======================================
+ Hits 86389 86438 +49
Misses 3562 3562
- Partials 2393 2394 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
anniewn
approved these changes
Oct 16, 2026
This branch has not been deployed
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.
Fixes
Summary
Changes
When a tool result crosses the session-SQL threshold,
convert_api_response_to_tablestores it in a table and returns a handle: table name, schema, row count and a preview of the first rows. The handle had no size bound. It listed every column name and copied up to five preview rows in full, so a result that is wide rather than tall (many flattened columns), or one with long text cells, put most of the payload back on the handle that was meant to replace it.This PR bounds the handle. Stored values are not changed.
utilities/sql_utils.pyPREVIEW_BUDGET_BYTES). String cells longer than 200 characters (PREVIEW_CELL_MAX_CHARS) are shortened with a marker giving the full length:... [N chars total, query the table for the full value]. Non-text cells such as BLOBs are shortened through their text form the same way, so one large cell cannot cost the whole row.SCHEMA_COLUMN_LIMIT) within 4 KB (SCHEMA_BUDGET_BYTES).preview_truncated: trueandschema_column_count(the full column count) appear only when a bound applied. They are set after caller metadata, so a keyword argument with the same name cannot replace them.tests/utilities/test_sql_utils_bounded_handle.py(21 tests). The end-to-end cases reopen the session database and check that the stored table still has every column and the full cell values. They cover long cells, BLOB cells, wide records, a tall preview, the exact-fit boundary, empty input, a first row wider than the budget, an unserializable cell, caller metadata that tries to set the flags, and a small result whose handle is unchanged.User experience
Before: an offloaded handle contains every column name and up to five full preview rows, however wide or long they are.
After: a handle that fits within the bounds is identical to today. A larger handle is capped at a few KB. The agent sees
preview_truncated/schema_column_countwhen something was left out, and reads the rest from the table withsession-sql, for example:Checklist
Is this a breaking change? (Y/N) N. Handles within the bounds are unchanged, and the stored tables are unchanged. Only oversized handles are shortened, and they are marked when they are.
RFC issue number:
Checklist:
Test plan
uv run --frozen pytest --cov --cov-branch: 1,940 passed; every new line insql_utils.pycovereduv run --frozen pyright: 0 errorsuv run --frozen ruff checkandruff format --check: cleangitleaksandcheck-license-header, which could not install on our network (both run in CI)Acknowledgment
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the project license.