Conversation
NousResearch#69334 capped discovery bookends (1200 chars) and scroll windows (4000) via _shape_message(max_content_len=...) but _read_session still shaped rows with no cap, so one archived tool result stored as a message came back whole - a single read returned 74K chars and took a request from ~50K to ~89K tokens in one step. Cap read-shape messages at 2000 chars with the same content_truncated / original_content_chars metadata, and add a regression test. Fixes NousResearch#114344
Collaborator
|
Thanks @MrSimonC. Your change was salvaged into #114901 with your authorship preserved (cherry-picked); #114901 — fix(session_search): read shape and title-match entries cap per-message content like FTS hits (#114344, salvage #114349) — is now merged on |
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.
What does this PR do?
Caps per-message content on the
session_searchread shape (_read_session). #69334 addedmax_content_lento_shape_messageand used it for discovery bookends (1200) and scroll windows (4000), but the read path still shaped rows with no cap, so a single archived tool result stored as a message could come back whole. I hit a read that returned 74K chars in one tool result and took a request from ~50K to ~89K tokens in a step, which kills a session on a 64K local slot.This uses the same mechanism with a 2000-char cap and the same
content_truncated/original_content_charsmetadata, so the agent can scroll for detail if it needs it. Bounding message count (head 20 / tail 10) on its own isn't enough when each message is unbounded.Related Issue
Fixes #114344
Type of Change
Changes Made
tools/session_search_tool.py: add_READ_MAX_CONTENT = 2000and pass it asmax_content_lenin_read_session. One call site, no schema or output-shape change beyond the existing truncation metadata.tests/tools/test_session_search.py: addTestReadShape::test_read_caps_oversized_message_content- an 80K-char message on a 3-message session must come back capped withoriginal_content_chars == 80000and the whole read under 5K chars.How to Test
pytest tests/tools/test_session_search.py -q- 68 pass (67 existing + 1 new)._read_sessioncall site to_shape_message(m)and the new test fails.session_search(session_id=<id>)from a fresh session, and check the big message now carriescontent_truncated: true.Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests pass - rantests/tools/test_session_search.py(68 pass); I haven't run the full suite locallyDocumentation & Housekeeping
docs/, docstrings) — N/A, the inline comment explains the capcli-config.yaml.exampleif I added/changed config keys — N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — N/A