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

Open
#48,778 1 comment 0 reactions 1 assignee View on GitHub

@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
  1. Start a session with a large context and make a few turns (warm the prefix cache).
  2. Edit an instruction file (e.g. AGENTS.md or memory.md) mid-session.
  3. 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

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.