Repository navigation
Continue truncated paper context from its included bytes - #692
Merged
Merged
Conversation
The paper context stops at 80 KiB of stored Markdown, and a model that asked for more by reading with cursor next restarted at the title. The notice now points continuation at pwc_read_paper with offset set to the paper's included_bytes. Budget trimming reports the bytes it kept, and pdf_text papers are excluded because their text is not the Markdown. Depends on the pwc-cli read_paper offset parameter. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit cf0b240. Configure here.
Budget trimming measured the HTML-escaped body, so included_bytes could overstate the stored Markdown and an offset read would skip text. It now decodes the kept body before counting. Layout-markdown papers are also excluded from offset continuation, because their text is not the stored Markdown either. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
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.

Summary
pwc_read_paperwithoffsetset to itsincluded_bytes, not at the title (the oldcursor: "next"restarted reading at the beginning).included_bytesto the bytes it kept, so an offset never skips text the model did not see.pdf_textpapers are excluded from offset continuation, because their text is not the stored Markdown.Deploy order
Deploy the pwc-cli MCP change first (huggingface/pwc-cli#35). Until it is live, the hosted
read_paperrejectsoffset. This is a chat change, so it is not merged or deployed; it waits for explicit authorization.Verification
npx --no-install node --test --import tsx test/paper_context_budget.test.ts: 11 pass, includingtrimmed papers report the Markdown bytes kept for offset continuation.test/paper_pagination.test.ts: the new offset test passes.pagination survives session restore...fails, but it also fails onmain(the installed@earendil-works/pi-coding-agentdiffers from the version the test expects).main(createMcpExtensionis missing from the installedpi-coding-agent).uv run --env-file backend/keys.env pytest backend/tests/chat/test_paper_context.py: 28 pass.backend/tests/chat: 9 fail here, 8 of which also fail onmain. The ninth,test_turn_job_migration_is_guarded_and_preserves_schema_ownership, fails onorigin/main'sdocs/deployment.md, which this change does not touch.🤖 Generated with Claude Code
Note
Medium Risk
Changes paper-reader continuation semantics and depends on a coordinated pwc-cli MCP deploy; misaligned offsets could skip or duplicate paper text until both sides are live.
Overview
Truncated in-context paper text can now be continued correctly via
pwc_read_paper: models are instructed to passoffsetfrom each paper’sincluded_bytes(no cursor on the first call, thencursor: "next"), instead of paging from the start.content_originpapers (e.g. PDF-extracted text) are excluded from offset continuation because their body is not stored Markdown.Context-budget trimming rewrites each paper’s
included_bytesto the raw Markdown byte count actually kept in the prompt (after unescaping HTML entities), and the budget notice documents that contract so offset reads do not skip unseen text.Paper-reader system notices (Python + MCP research prompt) are aligned with the same workflow. Tests cover trimmed
included_bytes, escaped Markdown byte accounting, and offset-then-cursor pagination.Reviewed by Cursor Bugbot for commit c361798. Bugbot is set up for automated code reviews on this repo. Configure here.