anomalyco / anomalyco/opencode

[BUG]: switching to a primary agent that denies execute/subagent busts prompt cache (42k re-sent, 0 cached)

Open
#50,055 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description:
Switching primary agent mid-session from plan to a custom ask agent that denies execute and subagent injects Instructions updated: core/codemode (the Code Mode tool catalog is stripped) and the next turn re-sends the full context: 42372 input tokens, 0 cached. Same session, build to plan switches preserve cache (276 in, 43377 cached), and switching ask back to build hits cache again (3352 in, 43889 cached), so the bust is scoped to the codemode catalog flip, not the agent switch itself.

Plugins: monitor.ts (local background-watch plugin)

OpenCode version: 2.0.10

Steps to reproduce:

  1. Warm a session in build until prompt cache is hot.
  2. Add a primary agent that denies execute and subagent (read/glob/grep/web only).
  3. Switch build to plan via Tab, send a message, note cache hits.
  4. Switch plan to the restricted agent, send a message, note Instructions updated: core/codemode followed by full input with 0 cached.

OS: Ubuntu 24.04.5 LTS

Terminal: tmux

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue in OpenCode 2.0.10 using the listed agent transitions and observe the cache counters alongside the Instructions updated: core/codemode message. Trace the prompt-cache and instruction-update path where the restricted agent changes the Code Mode catalog. Done means switching to the restricted agent no longer forces a full context resend, while the documented cache-preserving transitions continue to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
ai-infra-agents
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.