GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [Feature] Add Fetch tool that saves to file (like Claude Code) · Issue #7168 · anomalyco/opencode

[Feature] Add Fetch tool that saves to file (like Claude Code) #7168

New issue
Copy link
New issue
Copy link
Closed
#7239
Closed
[Feature] Add Fetch tool that saves to file (like Claude Code)#7168
#7239
Copy link
Assignees
rekram1-node

Description

@jdillon
jdillon
opened on Jan 7, 2026
Issue body actions

Problem

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:

  1. Downloads content to a temp file (e.g., .opencode/tmp/fetch-{hash}.md)
  2. Returns only metadata to context:
    • File path
    • Title
    • Content length
    • First ~500 chars as preview
  3. 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?

Related Issues

  • prompt is too long unrecoverable #4845 (prompt too long)
  • prompt is too long #5360, prompt is too long when replacing in a file. #5478 (duplicates)
  • fix(session): check for context overflow mid-turn in finish-step #6480 (mid-turn compaction - helps multi-turn but not single large fetches)
Reacted by Kamil Chmielewski and David Bernat

Activity

  1. github-actions
    assigned
    thdxr
    on Jan 7, 2026
  2. github-actions commented on Jan 7, 2026

    @github-actions
    github-actionsBot
    on Jan 7, 2026 – with GitHub Actions
    Contributor
    More actions

    This issue mentions several related issues that address the same core problem of context/token overflow:

    • prompt is too long unrecoverable #4845: prompt is too long unrecoverable
    • prompt is too long #5360: prompt is too long
    • prompt is too long when replacing in a file. #5478: prompt is too long when replacing in a file
    • fix(session): check for context overflow mid-turn in finish-step #6480: Mid-turn compaction fix (helps with the context overflow issue)

    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.

  3. rekram1-node
    assigned
    rekram1-node
    and unassigned
    thdxr
    on Jan 7, 2026
  4. rekram1-node commented on Jan 7, 2026

    @rekram1-node
    rekram1-node
    on Jan 7, 2026
    Member
    More actions

    Lol im working on this rn

    Reacted by Jason Dillon
  5. rekram1-node commented on Jan 7, 2026

    @rekram1-node
    rekram1-node
    on Jan 7, 2026
    Member
    More actions

    @jdillon can u show me how claude code does it for reference? I haven't seen any examples before?

  6. jdillon commented on Jan 7, 2026

    @jdillon
    jdillon
    on Jan 7, 2026
    Author
    More actions

    @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.

  7. rekram1-node commented on Jan 7, 2026

    @rekram1-node
    rekram1-node
    on Jan 7, 2026
    Member
    More actions

    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.

    I think that it's doing

  8. rekram1-node
    closed this as completedin #7239on Jan 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @rekram1-node
    rekram1-node

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

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.