How to reduce the context cost of an AI coding agent

Give the agent the relevant files, a short problem statement and the target test. Keep unrelated logs and generated files out of context.

Example

A component change only needs the component, its props and its test. The built asset directory adds tokens with little useful information.

What to do

  1. Start with the exact behavior to change and the files likely involved. Exclude binary output, dependencies, generated bundles and verbose logs.
  2. Ask the agent to find missing context explicitly. Use a bounded reproduction and short test output instead of sending a full repository transcript.
  3. If the conversation grows, summarize decisions and open a clean task. Measure input and cache usage before and after.

How to verify

The same change passes with fewer input tokens and fewer unrelated file reads.

Limits

Reducing context too far can hurt multi-file migrations and debugging. Supply the information your acceptance test requires.

Spendplane for this workflow

Estimate usage before committing to a model mix

Related reading