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]: Don't default agent scratch dir to a RAM-backed /tmp · Issue #55006 · anomalyco/opencode

[FEATURE]: Don't default agent scratch dir to a RAM-backed /tmp #55006

New issue
Copy link
New issue
Copy link
Open
#64031
Open
[FEATURE]: Don't default agent scratch dir to a RAM-backed /tmp#55006
#64031
Copy link

Description

@joshuaeroman
joshuaeroman
opened on Oct 13, 2026
Issue body actions

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

OpenCode's scratch dir is os.tmpdir()/opencode, and the built-in env prompt tells the model to prefer it ("Prefer /tmp/opencode over generic system temporary directories...", packages/core/src/instructions/builtins.ts).

On most Linux distros, /tmp is a tmpfs, so everything the agent puts there lives in RAM until it's deleted. Agents use this dir for big stuff - downloads, extracted archives, builds. In one session mine left ~4.6 GB of firmware images in /tmp/opencode, which ate RAM and pushed the system into swap (zram on my Fedora system, so that's RAM too).

Setting TMPDIR=/var/tmp works around it, but most people won't know they need to.

Suggestion: default the scratch dir to disk-backed storage, e.g. $XDG_CACHE_HOME/opencode/tmp (with cleanup of old files), or at least avoid /tmp when it's tmpfs. The system prompt can still instruct to use /tmp where it makes sense such as high frequency I/O on smaller files.

Reacted by Nikita Pedorich, Vlad Ionescu, abbas jafari and Johannes Rothmayr

Activity

  1. opencode-agent commented on Oct 13, 2026

    @opencode-agent
    opencode-agentBot
    on Oct 13, 2026 – with OpenCode Agent
    Contributor
    More actions

    Thanks for the detailed write-up, @joshuaeroman!

    To restate the request: OpenCode's agent scratch dir, which the env prompt tells the model to prefer, is os.tmpdir()/opencode. On distros where /tmp is tmpfs, large downloads, archives and builds placed there use up RAM. You suggest defaulting to disk-backed storage such as $XDG_CACHE_HOME/opencode/tmp (with cleanup of old files), or at least avoiding /tmp when it is tmpfs.

    I checked the code, and it works the way you describe: the path comes from packages/util/src/global-roots.ts. Setting TMPDIR=/var/tmp is the workaround available today. This can't be done as a plugin, because the scratch path and its automatic access approval are set in core when OpenCode starts.

    Related issues:

    • fix(util): use a per-user tmp directory #52973: open PR that moves the scratch dir to a per-user path (same code, but it doesn't deal with tmpfs)
    • [FEATURE]: Each project should have a dedicated /tmp dir #49073: request for a separate tmp dir per project or session
    • [FEATURE]: Provide a default pre-approved temp directory for skills/tools writing outside the workspace #48100: request for a default pre-approved temp directory
    • agent env: /tmp/opencode advertised as writable scratch but owned by another user #44696: /tmp/opencode owned by another user

    The maintainers will consider this.

  2. CerisonAutomation commented on Oct 22, 2026

    @CerisonAutomation
    CerisonAutomation
    on Oct 22, 2026
    More actions

    The RAM-backed scratch directory is not only a place where agent files are written — it is also loaded as a location, so it gets its own instance of every global stdio MCP server.

    From the server log:

    message="mcp connected" server=supabase ... directory=/private/var/folders/m6/k0xt0jw57f7831mf7j2q4tqw0000gn/T/opencode
    message="mcp connected" server=caveman  ... directory=/private/var/folders/m6/k0xt0jw57f7831mf7j2q4tqw0000gn/T/opencode
    

    So the scratch dir is not only consuming RAM for its own file contents — it is a third "directory" in the per-location server fan-out described in #51003. On this machine the three active locations were:

    /Users/cb
    /private/var/folders/m6/k0xt0jw57f7831mf7j2q4tqw0000gn/T/opencode
    /Users/cb/Downloads/dyad-1.16.0
    

    and the RAM-backed one accounted for a full extra set of MCP processes (~150 MB per server set on this box).

    There is a second, larger consequence. The location watcher subscribes to the ancestor chain of every location, so this scratch path additionally pulls in the following as watched directories:

    /private
    /private/var
    /private/var/folders
    /private/var/folders/m6
    /private/var/folders/m6/k0xt0jw57f7831mf7j2q4tqw0000gn
    /private/var/folders/m6/k0xt0jw57f7831mf7j2q4tqw0000gn/T
    

    see #55937. On this machine path=/ (the filesystem root) was subscribed as well, with 3122 backend=node watcher events against 1629 backend=fs-events events — the node backend is the fallback used for exactly those ancestor paths, so it is the path that turns unrelated filesystem activity into server-side event storms.

    Making the scratch dir live on the same filesystem as the workspace, or excluding it from location discovery, would remove both the RAM pressure and the extra server instances.

  3. abi-jey commented on Nov 22, 2026

    @abi-jey
    abi-jey
    on Nov 22, 2026
    More actions

    Hey guys, same issue here. This behaviour crashes the system as it runs out of memory in larger worktree work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    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.