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
[Feature] Add Fetch tool that saves to file (like Claude Code) #7168
The built-in webfetch tool returns entire page content directly into conversation context. For documentation pages (TanStack, MDN, React docs, etc.), this frequently exceeds the 200k token limit:
prompt is too long: 207654 tokens > 200000 maximum
This happens within a single tool response - the page itself is too large. Mid-turn compaction (#6480) can't help because overflow occurs before compaction can trigger.
Proposed Solution
Add a Fetch tool similar to Claude Code's implementation:
Downloads content to a temp file (e.g., .opencode/tmp/fetch-{hash}.md)
Returns only metadata to context:
File path
Title
Content length
First ~500 chars as preview
Agent uses read tool to access content in chunks as needed
Claude Code's approach:
Fetch downloads to temp, returns path + summary
Agent reads sections as needed using standard file tools
Large pages never blow context because content lives on disk
Benefits
Any page size works - content is on disk, not in context
Agent reads selectively - only loads what's relevant
Consistent with existing read tool patterns for large files
Solves a class of problems, not just individual pages
Workaround Question
Is there an existing custom tool or plugin that implements this pattern?
I see custom tools can be created in .opencode/tool/ - has anyone published a fetch-to-file tool that could serve as a workaround until this is built-in? If not, is there a recommended approach for implementing this as a custom tool?
The current solution via mid-turn compaction (#6480) helps with multi-turn scenarios, but as noted in this issue, it doesn't solve the single large fetch problem where the content itself exceeds the token limit before it can be processed.
@rekram1-node I can't find any docs, I may have been confused about WebFetch vs. it showing Fetch. Though I can say that it does have some internal handling of this tool which doesn't cause the session to blow out when it tries to look at a page. I have seen it download urls to tmp files and refer to those tmp files later for reading.
I have run into this several times, and the exact same prompts work fine in claude.
I wonder if I slipped through to an alternative universe because I really did think it had 2 different modes to fetch URL content, but now I can't find it.
I imagine though, that a solution might be to always stream content to a tmp file, then if the content is too large, to provide the llm the file ref and how big it is and then let it decide if it needs to call another tool to parse out something or if it should do something else to summarize it before adding it to the conversation. or if its was small to just include it and rm the tmp file?
I also wonder if it might be using a sub-agent to handle fetching and summarizing, but at this point i'm just wildy guessing.
Activity
github-actions commentedon Jan 7, 2026
This issue mentions several related issues that address the same core problem of context/token overflow:
The current solution via mid-turn compaction (#6480) helps with multi-turn scenarios, but as noted in this issue, it doesn't solve the single large fetch problem where the content itself exceeds the token limit before it can be processed.
rekram1-node commentedon Jan 7, 2026
Lol im working on this rn
rekram1-node commentedon Jan 7, 2026
@jdillon can u show me how claude code does it for reference? I haven't seen any examples before?
jdillon commentedon Jan 7, 2026
@rekram1-node I can't find any docs, I may have been confused about WebFetch vs. it showing Fetch. Though I can say that it does have some internal handling of this tool which doesn't cause the session to blow out when it tries to look at a page. I have seen it download urls to tmp files and refer to those tmp files later for reading.
I have run into this several times, and the exact same prompts work fine in claude.
I wonder if I slipped through to an alternative universe because I really did think it had 2 different modes to fetch URL content, but now I can't find it.
I imagine though, that a solution might be to always stream content to a tmp file, then if the content is too large, to provide the llm the file ref and how big it is and then let it decide if it needs to call another tool to parse out something or if it should do something else to summarize it before adding it to the conversation. or if its was small to just include it and rm the tmp file?
I also wonder if it might be using a sub-agent to handle fetching and summarizing, but at this point i'm just wildy guessing.
rekram1-node commentedon Jan 7, 2026
I think that it's doing