#3056·agentscope

[Bug]: Read tool leaks errors from deferred PDF extraction and page writing

Author: neu-hscCreated Sep 30, 2026Updated Sep 30, 2026
Labelstriage/confirmed

Read._read_pdf catches failures while opening a PDF and counting pages, but text extraction and writing a selected-page PDF occur outside that error boundary.

A real reproducer is a one-page PDF whose /Contents stream contains b"BT (unterminated". PdfReader and len(reader.pages) succeed, but extract_text() raises PdfStreamError("Stream has ended unexpectedly"), which escapes the Read tool rather than producing its normal error ToolChunk. Failures when copying or serializing requested pages also escape.

Expected: report these failures as a final error ToolChunk, consistent with initial PDF-read errors, while preserving valid PDF text extraction and native PDF output.

I will add a regression using real malformed PDF bytes and fault-injection tests for page copying/writing. This affects the builtin Read tool, separate from the RAG PDFParser fix in #2975. Codex-assisted investigation.

Source: agentscope-ai/agentscope