anomalyco / anomalyco/opencode
[BUG]: switching to a primary agent that denies execute/subagent busts prompt cache (42k re-sent, 0 cached)
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:
- Warm a session in
builduntil prompt cache is hot. - Add a primary agent that denies
executeandsubagent(read/glob/grep/web only). - Switch
buildtoplanvia Tab, send a message, note cache hits. - Switch
planto the restricted agent, send a message, noteInstructions updated: core/codemodefollowed by full input with 0 cached.
OS: Ubuntu 24.04.5 LTS
Terminal: tmux
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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