fix(session): report the characters a capped tool result really drops - #867
Open
ANIRUDDHA ADAK (aniruddhaadak80) wants to merge 1 commit into
Conversation
The marker counted only the head it cut, so the tail the same line keeps was reported as omitted: a 10,000-character result cut to 2,000 said 8,400 omitted while all 2,000 kept characters were shown. Count both retained slices, less the whitespace the trims drop at the cut.
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?
A tool result that gets cut down for a reduced-fidelity handoff is reported with a marker counting how many characters were left out. The count was wrong in one direction, every time.
capOutputkeeps the head of the result and then re-appends its tail:The two slices together carry
maxcharacters, butomittedsubtracts onlymax - tail— the tail is never counted as kept, even though the very next expression prints it. The marker therefore over-reports the omission by exactlytailcharacters. A 10,000-character result cut to 2,000 keeps 2,000 characters and drops 8,000, but the marker reads "8,400 characters of this result omitted for the handoff". The model reading the handoff is told a 400-character stretch was removed that it is in fact looking at.The count now derives the two retained slices once and subtracts their real lengths, so it also accounts for the whitespace
trimEnd()/trimStart()discards at the cut.Linked issue
small fix, no issue
How did you verify it?
Reproduction, before the fix (10,000-character result,
max = 2000):After the fix:
A second fixture with whitespace on both cuts behaves the same way (it reported 2,000 dropped for 1,603 really dropped).
Tests and gates:
bun test --timeout 15000 ./test/session/cap-output.test.ts— 3 pass, 0 fail (3 new tests, in thesessionshard pertooling/repo/test-shards.ts)bun test --timeout 15000 ./test/session/message-v2.test.ts— the existing message tests are unchanged and passbackend/cli/src/session/message-v2.tsreverted and the new test left in place, 2 of the 3 new tests fail (Expected: 8000 / Received: 8400andExpected: 1603 / Received: 2000); the third, which covers the unmarked case, still passes.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