Skip to content

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

Closed as not planned

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

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Apr 10, 2026
  2. github-actions commented on Apr 10, 2026

    @github-actions
    Contributor

    This issue doesn't fully meet our contributing guidelines.

    What needs to be fixed:

    • The issue does not use one of the required issue templates (Bug Report, Feature Request, or Question). Please resubmit using the Bug Report template, which requires filling in the designated fields (e.g., Description, Steps to Reproduce, etc.).

    Please edit this issue to address the above within 2 hours, or it will be automatically closed.

    If you believe this was flagged incorrectly, please let a maintainer know.

  3. added
    needs:complianceThis means the issue will auto-close after 2 hours.
    and removed
    needs:complianceThis means the issue will auto-close after 2 hours.
    on Apr 10, 2026
  4. github-actions commented on Apr 10, 2026

    @github-actions
    Contributor

    Thanks for updating the issue - it now meets the contributing guidelines. The needs:compliance label has been removed.

  5. rekram1-node commented on Apr 10, 2026

    @rekram1-node
    Contributor

    The pdf results are actually dropped already, see

    Image

    We can change the tool to say something other than success tho.

  6. 50sotero commented on Apr 10, 2026

    @50sotero
    Author

    @rekram1-node the problem is after an error like this occurs, the session is blocked from progressing further

    Image
  7. 50sotero commented on Apr 10, 2026

    @50sotero
    Author

    Additional evidence from the affected session (ses_28910d89cffepa6F6x95rQ8dmb) that it became effectively unable to continue meaningful work:

    • This session was running with the Oh My OpenAgent plugin enabled, so the final continuation spam should be treated as plugin-influenced behavior.
    • The session did not end with normal assistant progress or a stable completion state. Near the end, it received repeated plugin/system continuation injections instead:
      • 2026-04-10T15:59:56.324Z: [SYSTEM DIRECTIVE: OH-MY-OPENCODE - TODO CONTINUATION]
      • 2026-04-10T16:00:27.839Z: [SYSTEM DIRECTIVE: OH-MY-OPENCODE - TODO CONTINUATION]
    • Both late injections repeated the same directive:
      • Incomplete tasks remain in your todo list. Continue working on the next pending task.
    • The last recoverable exported work state still showed unfinished work rather than convergence:
      • === Todos ===
      • [x] [completed] Inspect the current CV contact block markup and print styling
      • [x] [completed] Implement the homepage-style grouped phone/WhatsApp rows in the CV header
      • [-] [in_progress] Build and verify the CV page and exported PDF layout
    • Session metadata also shows this was a long, degraded run rather than a quick isolated failure:
      • 341 messages
      • 988 transcript entries
      • duration from 2026-04-10T10:27:58.023Z to 2026-04-10T16:00:27.875Z

    So the strongest conclusion is:

    • the false PDF/capability mismatch still looks like the most plausible OpenCode-core bug being fixed by this PR
    • the session becoming unable to continue further is supported by evidence, but that terminal looping behavior appears to be plugin-influenced rather than something I can confidently attribute to OpenCode core alone

    I’m adding this here because the practical user-visible failure was not just the bad PDF verdict — it was that after enough state churn, the session stopped making meaningful forward progress and collapsed into repeated continuation directives.

  8. removed
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  9. shaked8634 commented on Jun 28, 2026

    @shaked8634

    I had the same error and ended with the same result where the session was stuck.
    The reason was that the PDF files were encrypted.

    I managed to recover the session by removing the last history messages.

  10. github-actions commented on Aug 28, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions