Skip to content

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

@jdillon

Description

@jdillon

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

Metadata

Metadata

Assignees

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