Skip to content

AGENTS.md Token Usage: How Much Do Instructions Cost?

· Pedro Villaca

Quick answer

AGENTS.md instructions contribute context when Codex loads them. Their cost depends on the loaded text, tokenizer, caching, and subsequent work. Keep essential rules and remove duplication. Verify which files apply before moving instructions, because nested guidance depends on the discovery path.

Download Halv for your repository

A useful instruction file prevents mistakes. An oversized instruction file can also repeat information or mix procedures from unrelated areas. The goal is to improve the instruction set without removing the rules that make the result correct.

First, check which instructions Codex loads

OpenAI documents a global instruction layer and project instructions along the path to the working directory. An AGENTS.override.md file can take precedence over AGENTS.md at the same level. See the official discovery rules.

Before an audit, record the launch directory and applicable files. Do not assume a file is active merely because it exists somewhere in the repository.

For example:

repository/
  AGENTS.md
  services/
    payments/
      AGENTS.md

Launching from services/payments gives discovery a different path from launching at the repository root. Verify the active instructions after changing the layout. Moving a required rule into an undiscovered file can make the instruction set smaller and less useful.

Bytes, tokens, and cost are different measurements

Use file size to identify unusually large instruction files. Use the relevant tokenizer or request telemetry to measure tokens. Use the provider’s accounting to measure cost.

OpenAI’s project_doc_max_bytes setting controls a byte limit, not a token budget. Do not convert that limit directly into a token count.

Repeated input can also receive different treatment under prompt caching. OpenAI explains matching prefix reuse in its prompt caching guide. An instruction reduction therefore does not imply an identical percentage reduction in money spent.

Keep, shorten, move, or remove

Instruction type Recommended action Reason
Required test commands Keep The agent needs a completion check
Constraints on existing work Keep The agent must preserve unrelated changes
Security and data rules Keep Token reduction does not justify weaker controls
Repeated explanation Shorten One precise rule can replace several restatements
Specialist procedure Scope carefully Only relevant tasks need the full procedure
Obsolete command Correct or remove A short incorrect rule still wastes work
Historical discussion Move to documentation Most tasks need the decision, not its full history

Example: shorten a rule without changing its meaning

This example shows an editorial reduction, not measured token savings.

Before:

Please remember that when you make a change to authentication,
you should always make sure that you run the session tests.
The session tests are important because authentication changes
can affect session expiry and refresh behavior.

After:

After authentication changes, run the session tests.
Check session expiry and refresh behavior.

The shorter version keeps the trigger and required behavior. In a real repository, include the exact test command if the agent cannot reliably discover it.

Give each rule one job

A compact root file can identify the package manager, main checks, and shared constraints. Specialist files can describe local procedures when the agent’s workflow loads them. Reference longer documentation when the task needs its detail.

Do not hide critical requirements behind vague instructions such as “follow the documentation.” Name the relevant file and the condition that requires reading it. The agent still needs enough information to choose the correct procedure.

Verify the shorter file

  1. Save the original instruction set and repository revision.
  2. Select tasks that exercise its important rules.
  3. Record the loaded instruction files for each launch directory.
  4. Run the baseline with fixed model and tool settings.
  5. Repeat with the shortened instructions in an equivalent checkout.
  6. Compare total usage and required behavior.

Include tests, preserved files, and task acceptance in the comparison. Count repeated investigation and repair work. A file reduction that causes missed requirements fails the audit, even if its initial context is smaller.

Halv supports this workflow with code navigation, command filtering, and context compression. Download Halv and evaluate a task with your existing project rules.

What to report in a measured result

Report the instruction diff, active discovery paths, model, client version, and tokenizer when known. Separate instruction tokens from complete task tokens. Include cached usage, attempts, and test outcomes.

Do not claim that a shorter AGENTS.md explains every difference between two stochastic runs. Repeat tasks and preserve evidence before attributing an improvement to the edit.

For related context decisions, read Codex compact versus new. For tool instructions, read MCP context usage.

Sources and scope

Official documentation checked on September 28, 2026. The example demonstrates writing technique. It does not establish measured token or cost savings.

How to Reduce ChatGPT Usage

Reduce avoidable ChatGPT usage with focused chats, relevant files, controlled tools, shorter outputs, and the right workspace for coding.

How to Reduce Claude Usage

Reduce Claude and Claude Code usage with smaller context, focused Projects, clear model choices, controlled tools, and complete measurement.

Keep the rules. Reduce the noise around them.

Use Halv's code navigation and command filtering alongside focused project instructions. Test the resulting patch before judging efficiency.

JEV agent routing is included in your Halv subscription, with no separate routing fee. Your agent subscriptions remain separate.

7 days free. Then US$10/month. Card required. Cancel in two clicks.

Frequently asked questions

Does Codex read every AGENTS.md in a repository at startup?

No. The documented discovery process follows global guidance and the path from the project root to the working directory. Check which files apply to your launch directory.

Is the AGENTS.md size limit a token limit?

No. project_doc_max_bytes limits bytes. Token counts depend on the tokenizer and text, so file size does not directly establish token usage.

Can I reduce cost by deleting test instructions?

Deleting essential checks can increase failed work. Keep the commands and constraints needed for correctness, then remove duplicate or irrelevant explanation.

Will nested AGENTS.md files always load automatically?

Do not assume that every descendant file loads at startup. Verify discovery from the directory where you launch Codex and check any additional file-reading behavior separately.