Repository navigation
Let get_document read a single section with an offset (#1209) - #1247
Closed
rollroyces wants to merge 1 commit into
Closed
rollroyces wants to merge 1 commit into
rollroyces wants to merge 1 commit into
Conversation
Signed-off-by: Royce Lam <roycelam@umich.edu>
Contributor
|
Thank you for picking this up. #1209 was already assigned, and #1235 implements the fix the issue asked for and has been merged, so I'm closing this as superseded. A few things here would have needed changes anyway:
For next time: please run |
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.
Why
search_chunksreturns a chunk excerpt (the first 800 chars). When theanswer sits past the excerpt, the model has to follow up with
get_documentto read more.get_documentjoined all sections andtruncated at
DOCUMENT_CHARS = 24_000. For a long Markdown table rowor a long procedure section, that 24,000 char cap could easily fall
inside the section the model needs to see — and the tool had no
offset, nochunk_seq, no continuation operation. The model saw"… truncated, N chars omitted" and could do nothing with it
(
#1209).The fix is a single new affordance: when a section is long enough
that the joined result ran into the budget, the model can ask for
just that section (
chunk_seq) starting at a character offset. Itcan also ask for a smaller per-section cap so the response is
bounded even for a single 30,000-char section.
What changes
crates/utopia-server/src/api/tools.rs:get_document_chunk(doc, chunks, seq, offset)—returns one section's text, starting at
offsetchars in, with a16,000-char per-call ceiling (
CHUNK_PAYLOAD) to keep a singleresponse bounded. The error envelope covers the two ways this
call can miss:
out_of_range—chunk_seqis past the document's sectioncount;
offset_past_end—offsetis past the section's last char.Both return the document name in the
Stepso the model canreason about which document it tried to read.
get_document— whenchunk_seqis set in the args, dispatch tothe helper. When it isn't, keep the existing joined-and-capped
behaviour unchanged, so the model doesn't have to rewrite the
common case.
Documentimport added.crates/utopia-server/src/api/chat.rs:get_document— addchunk_seq(zero-basedinteger, omit to read whole document) and
offset(zero-basedcharacter offset within the chosen section). The description
names the 24,000-char budget so the model knows when to switch
to single-section reads.
What this proposal does not do
search_chunks— the 800-char excerpt there isintentional and the existing description already directs the
model to follow up with
get_documentfor the rest.(chunk_seq, offset);a model that just got back "X chars remaining" can resume with
offset = previous_offset + len(returned)orchunk_seq += 1.No state to clean up.
document tools (
tools.rsintegration tests if any) is theright place; the present PR keeps the surface change small.
The maintainer can add coverage as part of their review pass.
Verification
cargo check -p utopia-server --bin utopia-serverdid not finishin the local sandbox (dev-deps cold rebuild chain on the
external FUSE mount). The diff is small and contained; recommend
running on a workstation with a normal filesystem before merge.
Tracking