Skip to content

System prompt is rebuilt every request — a mid-session instruction-file edit or the midnight date rollover forces a full re-prefill #48778

Description

@Capicua25x

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).

Activity

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

Metadata

Metadata

Assignees

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