Slim PageIndex search hits and list payloads for observation budgets. - #141
Slim PageIndex search hits and list payloads for observation budgets.#141Tharickv75 wants to merge 6 commits into
Conversation
Keep citation fields first in node_to_result, omit bulk text by default, and compact pageindex__list so large catalogs fit tool observation limits.
Review follow-ups on the lean-payload work. The slimming is right; these
close the gaps it opened.
Keep start_index/end_index alongside start_page/end_page. These rows are
returned verbatim by the public search endpoint (endpoints.py returns
{"results": results} straight from search_documents), so renaming them
broke every existing API client -- and bought nothing, since two small
ints are not what exceeds an observation budget. Bulk text is, and that
stays omitted. Update the endpoint response docstring and OpenAPI example,
which still described the pre-change shape, and document the
include=["text"] escape hatch there.
Import DEFAULT_OBSERVATION_MAX_CHARS rather than hardcoding 4000. The
orchestrator budget is a configurable attribute whose default is that
constant, so a duplicated literal silently diverges from any agent that
tunes it.
Bound the list payload for real. Description shrinking bottoms out at 40
chars; past that a large catalog was still returned oversized, which is
the middle-elision the change exists to prevent. Drop whole entries at
that point and report shown + truncated: true while keeping the true
count -- a model told it has 60 of 200 can ask for the rest; one silently
handed 60 cannot.
Smaller fixes: _is_question's docstring claimed a mid-sentence check it
never implemented, and it missed trailing quotes/brackets, so
'Need a hand?"' was still stripped as a closer. format_page_range's
dict.get default only fires on a missing key, not an explicit None. The
ellipsis character serializes to … (six chars) under json.dumps'
default ensure_ascii, so truncation cost more budget than it saved.
Adjusts one existing assertion: the pageindex__list log line now reports
"N of M document(s)" so the dropped-entry case is visible in logs.
|
Reviewed this and pushed follow-ups in e216829 rather than leaving a list of asks — full reasoning is in the commit message. Summary of what changed and why: Kept Imported Bounded the list payload for real. Description shrinking bottoms out at 40 chars — past that a large catalog was still returned oversized, which is the middle-elision this PR exists to prevent. It now drops whole entries at that point and reports Smaller ones: I adjusted one of your assertions — the Two things I deliberately did not touch, because they're your call and not defects:
Nice work on the core of this — the citation-first ordering and the |
Keep citation fields first in node_to_result, omit bulk text by default, and compact pageindex__list so large catalogs fit tool observation limits.
Summary
This PR slims down PageIndex search hits and list payloads so larger document catalogs and tool observations stay under observation limits and prevent orchestrator middle-elision:
node_to_result): Citation/identity keys (doc_name,title,start_page,end_page,node_id) are placed first in search result dicts so middle-elision keeps citation metadata intact. Omitstext,physical_index, andenabledby default, and caps large body text/summary content to_MAX_CONTENT_CHARS._t_list_docs): Switchessummaryparameter default toTrueand formatspageindex__listoutput into a compact{count, documents}JSON payload under 4,000 characters. Automatically truncates long descriptions and strips non-essential fields (likechunkswhen over capacity) while preserving document names._detect_peel_closersby preventing interrogative sentences ending in?from being stripped as closing remarks, and adds debug logging for egress scrub length reductions.format_page_rangeto support fallback lookups forstart_pageandend_page.Related issues
Type of change
Checklist
CONTRIBUTING.mdand (for subsystem work) the localCLAUDE.md.pre-commit run --all-filespasses.pytest tests/passes; I added/updated tests for new behavior.file:linein the description.CHANGELOG.mdupdated where relevant (entry under[Unreleased]).Notes for reviewers
jvagent/action/parameters.py:909-914: Fixes an issue where valid question sentences (e.g., "Could you let me know if you need a quote?") were incorrectly stripped by the closer peeling logic._t_list_docsprioritize retaining full document names and counts; descriptions progressively truncate down to 40 chars before dropping optional chunk metadata if payload exceeds 4,000 characters.