Skip to content

Valid PDF tool results can be forwarded to models without PDF input support #21908

@50sotero

Description

@50sotero

Description

A valid PDF can be attached by read.ts, then forwarded back into model context from MessageV2.toModelMessagesEffect() even when the selected model does not support input.pdf. In the failing session, that led to a bogus The file you uploaded is badly formatted or corrupted verdict on a healthy PDF.

Important context: this session was running with the Oh My OpenAgent plugin enabled. The repeated OH-MY-OPENCODE - TODO CONTINUATION / continuation-style spam should therefore be treated as plugin-influenced behavior, not as a pure OpenCode core symptom by itself. The core issue I am reporting here is the incorrect PDF handling path, not the plugin-layer session spam.

The same file later read successfully and hashes as a healthy PDF:

  • path: debug/cv-print-test.pdf
  • header: %PDF-1.4
  • sha256: 5ba26ba22bca394c29ab50d8ac1ba4097332a1100d76d9b1e2aae4195cc6216b

Current upstream packages/opencode/src/tool/read.ts does not parse PDFs into text; it returns PDF read successfully plus a PDF attachment. The risky step is later, when packages/opencode/src/session/message-v2.ts forwards completed tool-result attachments without checking model.capabilities.input.pdf.

Plugins

Oh My OpenAgent plugin enabled

OpenCode version

dev branch (observed against local clone bf601628db3c187478ff853fe33b91cec652355e)

Steps to reproduce

  1. Start a session with a model that does not support PDF input.
  2. Run the read tool on a valid PDF so the tool result contains PDF read successfully plus a PDF attachment.
  3. Let the session continue so MessageV2.toModelMessagesEffect() rebuilds model messages from the stored tool result.
  4. Observe that the PDF attachment can be forwarded back into model context even though the model does not support input.pdf.
  5. In the failing plugin-augmented session I inspected (ses_28910d89cffepa6F6x95rQ8dmb), that produced: The file you uploaded is badly formatted or corrupted. Please fix the file and try again.

Screenshot and/or share link

No share link. Relevant failing session: ses_28910d89cffepa6F6x95rQ8dmb

Operating System

WSL / Linux

Terminal

Shell session via OpenCode tooling

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions