fix(session): report the characters a request excerpt really drops - #868
Open
ANIRUDDHA ADAK (aniruddhaadak80) wants to merge 1 commit into
Conversation
ANIRUDDHA ADAK (aniruddhaadak80)
requested review from
Aayam Bansal (aayambansal) and
Ishaan Gangwani (ishaan1124)
as code owners
September 30, 2026 10:14
|
ANIRUDDHA ADAK (@aniruddhaadak80) is attempting to deploy a commit to the InkVell Team on Vercel. A member of the Team first needs to authorize it. |
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.
What does this PR do, and why?
The compaction handoff tells the summarizer how large the request it is about to summarize was, and that number was inflated every time the request was too big to quote whole.
requestTextquotes the opening ask and the closing instructions, with a marker between them:Both slices are kept, so the excerpt carries
maxcharacters, butomittedsubtracts onlymax - tailand never counts the tail as kept — the same arithmetic the neighbouring tool-output cap had. A 50,000-character request with the defaultmax = 2,000keeps 1,500 + 500 = 2,000 characters and reports "48,500 characters omitted" for the 48,000 that are really gone. That count is the summarizer's only evidence about the size of what it is condensing, and it overstates it by a quarter of the excerpt budget.The count now derives the two retained slices once and subtracts their real lengths, so it also accounts for the whitespace
trimEnd()/trimStart()discard at the cut. The excerpt itself is byte-for-byte the same size and the same content as before; only the number changes.Linked issue
small fix, no issue
How did you verify it?
Reproduction, before the fix (50,000-character request, default
max = 2,000):and with whitespace on both cuts:
After the fix both report
marker agreesand the script exits 0.Tests and gates:
bun test --timeout 15000 ./test/session/compaction.test.ts— 76 pass, 0 fail, 1221 expect() calls (3 new assertions added to the existingrequestTextexcerpt cases, in thesessionshard pertooling/repo/test-shards.ts)backend/cli/src/session/compaction.tsand re-running gives 1 fail withomitted: 48526received against48026expected — exactly the 500-character tail inflation. The test asserts the invariant (reported + still-quoted == request length) rather than a hard-coded formula, so it also pins the whitespace case.bun run typecheckinbackend/cli— exit 0All matched files use Prettier code style!Not run locally: the full
bun run --cwd backend/cli testsuite (~10 min) and Deep CI.Checklist
bun run checkis green (format, typecheck, backend + frontend/ui + SDK tests) — run the touched shard, the backend typecheck and the format check; the fullbun run checkaggregate was not run locallybun run --cwd frontend/workspace buildsucceeds if I touchedfrontend/workspaceorfrontend/ui— not applicable./tooling/repo/generate.tswas run and thetooling/sdkoutput committed if I changedbackend/cli/src/server— not applicablefrontend/docs/src/content/openscience/is updated if behavior changed — the marker wording is unchanged, only the number it printspackage.jsonversions and tags are written by the release workflow)installandfrontend/landing/public/installare still byte-identical if I touched either — not applicable