Repository navigation
[FEATURE]: Avoid auto-inlining large SVG files when pasting file path in TUI #13660
Description
Feature hasn't been suggested before.
- I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request
Problem
When pasting an .svg file path into the TUI input, OpenCode automatically reads the SVG file and inlines its full content into the model request.
For large SVG files, this can:
- Exceed model context limits
- Cause truncation of previous conversation
- Increase token cost significantly
- Slow down responses
- Fail requests silently or unexpectedly
This behavior is surprising because the user only intended to reference a file path, not inject the entire SVG content into the prompt.
While SVG makes the issue easy to reproduce due to large inline path data, the underlying problem applies to any large text-based resource file. The root cause is unconditional file inlining without token-awareness.
Reproduction
- Copy an SVG file path, e.g.
/home/Projects/nekopage/Page/public/favicon.svg - Paste it into OpenCode TUI input.
- Send any message.
Observed:
- TUI labels it as [SVG: ]
- OpenCode still inlines the entire SVG content into the request
- API returns: "Input exceeds context window of this model"
Why This Is Problematic
SVG is technically a text file, but semantically it is an image resource.
Large SVG files often contain:
- Massive path data
- Long inline style blocks
- Thousands of vector commands
In most cases, the model does not need the entire raw XML content.
Automatic full inlining is unsafe for:
- Token usage
- Cost control
- Context window stability
- Predictability in TUI usage
Proposed Solution
Introduce a size-aware and type-aware file injection policy.
Suggested Behavior
- Detect file type (.svg or content starting with <svg)
- Estimate file size or token count
- If above a configurable threshold:
- Do NOT auto-inline full content
- Instead:
- Include file path only
- Or include a structured summary
- Or prompt user for confirmation
Example UX
Detected large SVG (142KB, ~18k tokens).
Using summary mode. Use --expand to inline full file.
Config Options
- max_auto_inline_tokens
- auto_inline_svg: true/false
- large_text_policy: inline | summary | path_only | prompt_user
Expected Outcome
- Prevent accidental context overflow
- Improve cost control
- Make TUI behavior more predictable
- Provide smarter file handling for resource-like files
Evidence / Logs
-
After pasting the SVG path, the TUI shows it was recognized as an SVG resource reference:
[SVG: /home/Projects/nekopage/Page/public/favicon.svg]
-
However, OpenCode still reads and inlines the full SVG XML content into the outgoing request.
-
The provider returns an error:
"Input exceeds context window of this model"
This indicates the request payload is already over the context limit at send time, caused by automatic file inlining rather than user intent.
- Attached a large SVG sample in this issue for easy reproduction.
(The file is intentionally large to trigger the current auto-inlining behavior.)
Activity
github-actions commentedon Apr 16, 2026
To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.