You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TUI: pasting a file path attaches the whole file even when it can't fit the model's context; no way to paste the path as text #57162
What happened: I pasted the path of a PDF into the TUI prompt, meaning to give the agent the path. The TUI turned the paste into a [PDF 1] attachment and sent the whole document. The request came to about 1.37M tokens, and the provider rejected it with prompt is too long: 1368578 tokens > 1000000 maximum. Recovering took a manual revert of that message. The PDF was well under the 20 MB local-attachment cap.
Current behaviour (checked on dev, packages/tui/src/component/prompt/local-attachment.ts): when the pasted text resolves to local files, they become attachments, up to 32 paths and MAX_LOCAL_ATTACHMENT_BYTES = 20 MB in total. The cap is in bytes. Nothing compares the attachment's likely token cost with the active model's context window, so a few-MB PDF can exceed a 1M-token model.
Requests:
Before attaching, estimate the token cost (for PDFs, at least page count × a per-page estimate). If it won't fit the active model's remaining context, insert the path as plain text or ask, instead of sending a request that's bound to fail.
Thanks for the detailed report and for checking the code on dev.
To restate: when a pasted path resolves to a local file, the TUI attaches the whole file and only checks its size in bytes, not its likely token cost against the active model's context window. You're asking for two things:
Estimate the token cost before attaching (for PDFs, e.g. page count × a per-page estimate). If it won't fit the remaining context, insert the path as text or ask first.
A way to paste a path as plain text: a modifier, a setting, or undo-to-text right after the paste.
Right now the paste handling works as designed, so I've filed this as a feature request. Maintainers will consider it. This isn't something a plugin can do today, because plugins can't step into the TUI's paste-to-attachment handling.
So they are not duplicates, but a "paste path as text" option (request 2 here) or an "attach images only" policy (proposed in #57698) would address both. Cross-linking so the relationship is explicit.
Activity
opencode-agent commentedon Oct 19, 2026
Thanks for the detailed report and for checking the code on
dev.To restate: when a pasted path resolves to a local file, the TUI attaches the whole file and only checks its size in bytes, not its likely token cost against the active model's context window. You're asking for two things:
Right now the paste handling works as designed, so I've filed this as a feature request. Maintainers will consider it. This isn't something a plugin can do today, because plugins can't step into the TUI's paste-to-attachment handling.
Related:
prompt.paste_mode: "dialog"option with choices for how a paste is inserted, which could cover your second requestbeenotung commentedon Oct 21, 2026
Related: #57698 reports the same root behaviour (a pasted PDF path becomes a
[PDF 1]attachment) but a different failure mode.this model does not support pdf inputregardless of size. Token-cost gating would not help that case.So they are not duplicates, but a "paste path as text" option (request 2 here) or an "attach images only" policy (proposed in #57698) would address both. Cross-linking so the relationship is explicit.