anomalyco / anomalyco/opencode
System prompt is rebuilt every request — a mid-session instruction-file edit or the midnight date rollover forces a full re-prefill
@nexxeln is already working on this.
Since Sep 13, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
The system prompt is rebuilt on every request: instruction.system() re-reads the instruction files (AGENTS.md, CLAUDE.md, memory.md, …) and system.ts injects Today's date. Any change to that prefix — editing an instruction file during a session, or the date rolling over at midnight — changes the system message, so the provider's cached prefix diverges at token ~0 and the entire conversation is re-prefilled.
On a long session (1M-context model) that's ~450K tokens re-prefilled (~4 minutes) with no signal in the UI — it just looks like the model is thinking. It affects every provider, not just Anthropic, and the date case is guaranteed once per day for any session that spans midnight.
Steps to reproduce
- Start a session with a large context and make a few turns (warm the prefix cache).
- Edit an instruction file (e.g.
AGENTS.mdormemory.md) mid-session. - Send another message. The system message hash changes and the follow-up reports 0 cached tokens, re-prefilling from token 0.
OpenCode version
1.18.30
Operating System
Linux (reproduces on all platforms)
Related: #29584 (closed stale), #36483, #43722. Proposed fix: #48777 (rebased from #33246).
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.
Assessment
This issue has not been assessed yet.