anomalyco / anomalyco/opencode

[FEATURE]: mechanism to keep critical rules visible against long-context dilution

Open
#41,590 1 comment 0 reactions 1 assignee View on GitHub

@nexxeln is already working on this.

Since Aug 10, 2026.

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

Description

Checklist

  • I have verified this feature has not been suggested before (searched existing issues before filing).

Not a duplicate of #37767 / #40474 (checked before filing):

  • #37767 covers repeated static prompt context across requests and context efficiency in long sessions.
  • #40474 covers the missing reminder/re-injection mechanism in V2's request path (agent-switched messages dropped, no mode reminders).
    This request is wider: it asks for a first-class, verifiable mechanism whose injected content must actually reach the LLM context (verifiable in DB / request payload), not just logs or TUI rendering — plus optional "always-pinned" rules that survive any amount of context growth. Neither existing issue specifies the traceable-injection requirement.

Feature

Provide a supported, native mechanism so that important rules/instructions (e.g. from AGENTS.md) remain effective and visible to the LLM even when the conversation context grows very long.

Why (reason) — the "7-second fish" problem

Every AI agent is essentially a "7-second fish": high capability, but terrible memory. Each session/context boundary is a memory reset; it only survives on the current context window. In long sessions, rules injected early are diluted and forgotten as the conversation grows — so the agent drifts and violates its own golden rules (comment conventions, proxy usage, timeout discipline, role naming, etc.).

The user tried to counter this with a plugin (rules_reminder.js) that every N rounds console.logs a condensed rule card into the log stream. Verification showed this never entered the LLM context at all — it only printed a big text block over the TUI/interface, obscuring the actual conversation, and it had zero effect on the model's behavior. There is currently no reliable way for a plugin to inject text into the LLM context that the model actually reads, nor a way to verify it (plugin self-logs are not evidence).

Request details

  1. A first-class mechanism to re-inject/highlight critical rules at a given interval (e.g. every N user turns), OR a way for plugins/AGENTS.md sections to be marked "always pinned" so they never get diluted.
  2. The injected content must actually reach the LLM context (verifiable in the DB / request payload), not just logs or UI.
  3. Optionally: context window management / automatic compaction info so rules survive.

Please iterate on this soon — context dilution is the single biggest reliability problem in long agent sessions.

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.