Agent rule pattern

Context budgeting

Limits on what enters the model context and how large it may be.

7 of 100 projects

The shape of the rule

  1. Name the context owner
  2. Set a size limit
  3. Protect prompt stability
How to use it

Repositories that build agents assign context an owner, cap each item, and require extra review above a set size.

Give injected material an owner and a size limit. Say when it loads and which changes need extra review for cost or prompt stability.

Examples from real projects

3 examples · Pinned source

Limits on the model context

Model history is incremental to preserve prompt caching. Every injected item has a hard size cap, anything over 1,000 tokens needs review, and fragments use a named trait.

AGENTS.mdL97
Source excerpt starting at line 97.
3. No unbounded items - everything injected in the model context must have a bounded size and a hard cap.

Treat prompt stability as a conversation invariant

The guide explains that changing past context or toolsets invalidates the cached prefix and increases cost. Commands that change prompt state default to the next session, with an explicit immediate option.

AGENTS.mdL20–26
Source excerpt starting at line 20.
- **Per-conversation prompt caching is sacred.** A long-lived conversation reuses a cached  prefix every turn. Anything that mutates past context, swaps toolsets, reloads memories, or  rebuilds the system prompt mid-conversation invalidates that cache and multiplies the user's  cost. We do not do it; the ONE exception is context compression. Slash commands that mutate  system-prompt state (skills, tools, memory) must be **cache-aware**: default to deferred  invalidation (takes effect next session) with an opt-in `--now` flag (`/skills install --now`  is the canonical pattern).

Account for the cost of core capabilities

The capability ladder starts with existing commands and skills, then plugins, then narrow shared contracts. Adding an integration does not by itself justify a new core manager or tool.

AGENTS.mdL13
Source excerpt starting at line 13.
- **Small core, capable plugins.** Model-facing core additions have an ongoing context cost. Optional capability belongs at the edges; core supplies generic contracts. A feature needing a new integration is not, by itself, a reason to add another core tool or manager. [VISION.md](VISION.md) owns product scope.

Projects using this pattern (7)

Browse in directory →
← All agent rule patterns