What happened
When sending a PDF document via Telegram, the bridge detects it as a PDF, downloads it, and sends it to OpenCode as a file part (mime application/pdf, url data:application/pdf;base64,...). However the OpenAI model sometimes replies as if no PDF was attached (e.g. "I don't have the PDF file to analyze yet").
We added debug logging and confirmed the bridge is attaching the PDF correctly.
Evidence from logs
From ~/Library/Logs/opencode-telegram-bridge.log (macOS launchd):
- Telegram document received:
declaredMime: application/pdf
inferredMime: application/pdf
fileSize: 2162125
- Attachment prepared:
downloadedMime: application/pdf
byteLength: 2162125
dataUrl.header: data:application/pdf;base64,
dataUrl.payloadLength: 2882836
- OpenCode prompt request parts:
{ type: "text" }
{ type: "file", mime: "application/pdf", filename: "...pdf", url: "data:application/pdf;base64,..." }
- Model used:
openai/gpt-5.2-codex
So the bridge is not dropping the PDF.
Suspected root cause
This looks like an upstream issue in how OpenCode (or its underlying provider stack) forwards PDF file parts to OpenAI, especially for models routed through the OpenAI Responses API.
Related upstream reports:
OpenAI's own docs show that data:application/pdf;base64,... is a valid format for PDF file inputs in Responses API:
Why this is a problem for this repo
We only talk to OpenCode via @opencode-ai/sdk/v2 and intentionally do NOT integrate directly with OpenAI (avoid scope creep). If OpenCode drops/ignores PDFs for OpenAI models, there is no self-contained fix here.
Repro steps
- Run OpenCode server:
opencode serve
- Run this bridge as a service (launchd/systemd)
- Send a PDF document (no caption) to the bot
- Observe model reply indicating the PDF is missing
Expected
Model should be able to reference and analyze the attached PDF.
Actual
Model replies as if there is no PDF.
Notes / Workarounds
- Switching to a non-OpenAI provider/model (e.g. Anthropic/Google) may work.
- We do not want to implement OpenAI file uploads / file_id flow in this project.
What happened
When sending a PDF document via Telegram, the bridge detects it as a PDF, downloads it, and sends it to OpenCode as a file part (mime
application/pdf, urldata:application/pdf;base64,...). However the OpenAI model sometimes replies as if no PDF was attached (e.g. "I don't have the PDF file to analyze yet").We added debug logging and confirmed the bridge is attaching the PDF correctly.
Evidence from logs
From
~/Library/Logs/opencode-telegram-bridge.log(macOS launchd):declaredMime: application/pdfinferredMime: application/pdffileSize: 2162125downloadedMime: application/pdfbyteLength: 2162125dataUrl.header: data:application/pdf;base64,dataUrl.payloadLength: 2882836{ type: "text" }{ type: "file", mime: "application/pdf", filename: "...pdf", url: "data:application/pdf;base64,..." }openai/gpt-5.2-codexSo the bridge is not dropping the PDF.
Suspected root cause
This looks like an upstream issue in how OpenCode (or its underlying provider stack) forwards PDF file parts to OpenAI, especially for models routed through the OpenAI Responses API.
Related upstream reports:
openai.chatandopenai.responses: openai Responses does not support PDF by URL vercel/ai#7803OpenAI's own docs show that
data:application/pdf;base64,...is a valid format for PDF file inputs in Responses API:Why this is a problem for this repo
We only talk to OpenCode via
@opencode-ai/sdk/v2and intentionally do NOT integrate directly with OpenAI (avoid scope creep). If OpenCode drops/ignores PDFs for OpenAI models, there is no self-contained fix here.Repro steps
opencode serveExpected
Model should be able to reference and analyze the attached PDF.
Actual
Model replies as if there is no PDF.
Notes / Workarounds