Repository navigation
fix(mcp): a read_file stop before the first page or paragraph never calls its text partial - #35271
Conversation
…alls its text partial A worker stopped at its wall-clock ceiling before page 1 answered no text with a note saying it stopped "after page 0 ... so the text is partial"; a Word read stopped before its first paragraphs said the same with "0 paragraphs". Such a stop now says the read stopped before page 1 (or the first paragraph) was read and that no text came back, and a stop after parts that held no text says no text was found. A stop that did return text keeps the partial-text note. Claude-Session: https://claude.ai/code/session_01Utp6CazXu8zyYD5PC6J2u7 Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Utp6CazXu8zyYD5PC6J2u7 Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift Check7 anchor(s) derived from 1 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run. What this run could not see
Coarse fallback — 12 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin e6cc60ff2bc7d4cfa65fdb1d82fc9f469de6df43 && git checkout e6cc60ff2bc7d4cfa65fdb1d82fc9f469de6df43
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin f4dbcc2153566226f283c79c73255369c2c97587 a94ee5a0fa4c04fa494c1b2e43e3d85380662b8e && git checkout -B drift-repro f4dbcc2153566226f283c79c73255369c2c97587 && git merge --no-ff a94ee5a0fa4c04fa494c1b2e43e3d85380662b8e
node scripts/docs-audit/affected-docs.mjs --json f4dbcc2153566226f283c79c73255369c2c97587 |
|
repo:objectstack#5 · os-bill · session_01Utp6CXsZsKmgG1EcKp5bY4 维护者速读
席位核对 — ACCEPT (L1-a) · repo:objectstack#5 · head
|
|
repo:objectstack#5 · os-bill · session_01Utp6CazXu8zyYD5PC6J2u7 Landing · ACCEPT (L1-a) → PR #35271 comment 6996919772 · head
Area ai-1 landing armed (ready + auto-merge); #34855 close-out on MERGED. |
Requested by Bill · project thread
Fixes #34855
Clause-②: no
Metadata-protocol: none
维护者速读
read_file读 PDF / Word 时,如果在第 1 页(或第一批段落)读回来之前就被停下,回答仍是「没有内容」,但说明改为「在读到第 1 页之前就停了,没有拿到任何文字」;读过的页都没有文字时,说明改为「已读部分没有找到文字」。读到了文字的情况,说明不变(仍说「文字是部分的」)。content、truncated、note字段不变);回滚即 revert 本 PR。packages/mcp/src/file-content.ts(cpuBudgetNote与stoppedExtractionAnswer的两个分支),packages/mcp/src/mcp-file-tools.test.ts末尾新增的 describe。pnpm --filter @objectstack/mcp exec vitest run src/mcp-file-tools.test.ts,预期 52 个测试全绿,其中新增的「before page 1 of 120 was read, so no text came back」那条通过。What changes
packages/mcp/src/file-content.ts:cpuBudgetNotenow takes where the read stopped (afterthe pages or paragraphs read, orbeforethe first one) and whether any text came back. It calls the text partial only when text came back.stoppedExtractionAnswer(the wall-clock ceiling's overrun answer) branches on "no page / no paragraphs came back": a PDF saysbefore page 1 of M was read, so no text came back(before page 1 was readwhen the PDF had not opened yet), a Word document saysbefore the first paragraph was read, so no text came back. A stop after page 1 or later keeps the partial-text note.pdfAnswer/docxAnswerbuild the note themselves, so acontent: noneanswer can never carry the partial-text sentence. A stop after parts that held no text (a scanned PDF, blank paragraphs) now saysafter page P of M, and no text was found in what was read.The second bullet is the card. The third is a bounded in-place fix of the same defect class in the same function family (same file, same gate families, no claim elsewhere on the file): before it, a budget stop on the in-process path after page 1 of an image-only PDF answered
content: nonewithafter page 1 of 3, so the text is partial. The new pinout of CPU budget after pages or paragraphs that held no textreproduces that answer onorigin/main's logic (ablation A below).Tests
All in the shared harness file
packages/mcp/src/mcp-file-tools.test.ts:read_file: a worker stopped at its wall-clock ceiling before the first page answers no text, never partial text. A stand-in worker sends back exactly the progress a test scripts (the realExtractionProgressmessages) and never answers, so the pool's own overrun path builds the answer and how far the read got is fixed by the script, not by machine load. The clock only decides when the read stops, never where. Pins: PDF opened then stopped before page 1, PDF stopped before it opened, Word stopped before its first paragraphs, and a CONTROL (stop after page 1, and after 64 paragraphs, keeptruncated: trueand the partial-text note).content: nonewith the no-text-found note.Test runs at a94ee5a
Ablations (fix committed first; each restore proven blob == HEAD, git diff HEAD empty)
The tests import
./file-content.jsfrom source and the stand-in worker is adata:module, so nodist/is involved.A:
return gotTextreplaced withreturn true(every stop calls its text partial). Expected red on the no-text pin only:B:
pages.length === 0andparagraphs === 0made never true (the before-first branch gone). Expected red on the two before-first pins, CONTROL green:A and B together are
origin/main's behaviour.Acceptance notes
stoppedExtractionAnsweranswers "the same shape an extraction stopped at its budget answers") and is left as is.file-content.ts, its tests and the releasedCHANGELOG.md, so no i18n surface moves.Verification
Derived gate families at a94ee5a (dispatch-gates --commands, 65 commands)
dispatch-gates --ranwith recorded exit codes: 65 derived, 63 run, 2 NOT-MEASURED, 0 UNRUN. 63 exited 0.node scripts/check-plugin-teardown-shape.mjs --self-test, reason: PREREQUISITE NOT MET, the positive control is pinned to a commit a shallow checkout cannot reach (it grades the checker, not this diff).pnpm check:dual-build-cjs-loads, reason: PREREQUISITE NOT MET, it reads every package'sdist/and only the mcp closure was built here. CI runs it.node scripts/pm/overlap-check.mjs --branch=HEAD:VERDICT clean exit 0(merges cleanly with origin/main, 0 PR heads overlap).🤖 Generated with Claude Code
https://claude.ai/code/session_01Utp6CazXu8zyYD5PC6J2u7