DEV Community

Qingfeng
Qingfeng

Posted on

The Agent Doesn't Need More Context. It Needs the Right Five Lines.

I started with a 900-line instructions file. The agent ignored most of it. Then I cut it to under 100 lines and behaviour got better, not worse.

That is not magic. Long context is not free, and a lot of what we call "the agent doesn't follow instructions" is really "the instruction that mattered was buried".

The five lines that do most of the work

When a task starts, the agent gets a short block before anything else:

  1. what the task is, in one sentence
  2. what "done" looks like, as a checkable statement
  3. which resources are in play - repo, port, service, account
  4. what it must not touch
  5. where the log is

That is it. Everything else - conventions, style, history - goes into files the agent reads only when the task needs them. The block is the part that is always true; the rest is reference.

Why the short block wins

Three reasons I can actually observe:

  • It survives truncation. When the context gets long and the runtime trims, a short block at the top is much more likely to be kept than paragraph 60 of a wall of instructions.
  • It is checkable. If line 2 is vague, I can see that in five seconds and fix it before the run. A vague paragraph in the middle of 900 lines never gets fixed.
  • It is the same every time. Repetition at the start of every task is worth more than a comprehensive document that appears once.

What I moved out

Everything that was an explanation of the past: why the workaround exists, what broke last time, what someone suggested in a meeting. Useful to me, noise to the agent at task start. It now lives in files with names that say what they contain, and the agent opens them on demand.

The cost is that the agent sometimes misses a convention because it did not open the file. That is a real cost, and it is smaller than the cost of a context so long that the important line is unfindable.

The test I use now

If I cannot state the task in one sentence, the check in one line, and the forbidden resources in a short list, the task is not ready. Writing those five lines is usually where I discover the task was two tasks.

Which is the useful part: the block is not just what the agent reads, it is the minimum I have to know before delegating.

If you have a block like this, what is in yours that is not in mine? I suspect I am missing something about rollback.

Top comments (0)