fix(core): reject PDF files to prevent session corruption (fixes #2020)

This commit is contained in:
Drew Duncan 2026-02-28 10:17:46 -08:00
parent c6a723efef
commit de20bb12bd
3 changed files with 18 additions and 21 deletions

View file

@ -24,7 +24,7 @@ Qwen Code provides a comprehensive suite of tools for interacting with the local
## 2. `read_file` (ReadFile)
`read_file` reads and returns the content of a specified file. This tool handles text, images (PNG, JPG, GIF, WEBP, SVG, BMP), and PDF files. For text files, it can read specific line ranges. Other binary file types are generally skipped.
`read_file` reads and returns the content of a specified file. This tool handles text and images (PNG, JPG, GIF, WEBP, SVG, BMP). For text files, it can read specific line ranges. PDF files are not supported directly - extract text externally first. Other binary file types are generally skipped.
- **Tool name:** `read_file`
- **Display name:** ReadFile
@ -35,11 +35,13 @@ Qwen Code provides a comprehensive suite of tools for interacting with the local
- `limit` (number, optional): For text files, the maximum number of lines to read. If omitted, reads a default maximum (e.g., 2000 lines) or the entire file if feasible.
- **Behavior:**
- For text files: Returns the content. If `offset` and `limit` are used, returns only that slice of lines. Indicates if content was truncated due to line limits or line length limits.
- For image and PDF files: Returns the file content as a base64-encoded data structure suitable for model consumption.
- For image files: Returns the file content as a base64-encoded `inlineData` object suitable for model consumption.
- For PDF files: Returns an error message directing users to extract text externally.
- For other binary files: Attempts to identify and skip them, returning a message indicating it's a generic binary file.
- **Output:** (`llmContent`):
- For text files: The file content, potentially prefixed with a truncation message (e.g., `[File content truncated: showing lines 1-100 of 500 total lines...]\nActual file content...`).
- For image/PDF files: An object containing `inlineData` with `mimeType` and base64 `data` (e.g., `{ inlineData: { mimeType: 'image/png', data: 'base64encodedstring' } }`).
- For image files: An object containing `inlineData` with `mimeType` and base64 `data` (e.g., `{ inlineData: { mimeType: 'image/png', data: 'base64encodedstring' } }`).
- For PDF files: An error message string explaining that PDFs are not supported.
- For other binary files: A message like `Cannot display content of binary file: /path/to/data.bin`.
- **Confirmation:** No.