You paste the documentation.
Add twenty files.
Include the error logs.
Keep the entire conversation because “the agent might need it.”
Then it misses a requirement you explained ten messages ago.
Your first reaction?
Add more instructions.
But before expanding the prompt again, look at what the agent is already reading.
More context can help. Irrelevant, repeated, or conflicting context can make the task harder.
Context overload won’t explain every mistake. Missing information, unclear requirements, and model limitations matter too. But it’s worth investigating before blaming the model—or upgrading it.
1. Context is more than your latest message
Your latest prompt might be short:
“Fix the checkout total.”
But the agent may also receive:
- System and project instructions.
- Earlier messages.
- Source files.
- Tool descriptions.
- Search results.
- Terminal output.
- Summaries of previous work.
Some of that information is essential. Some may describe a problem you already solved or an approach you abandoned.
Anthropic’s context-engineering guidance emphasizes curating the information supplied throughout a task, including message history and tool results.
The practical question is:
“What does the agent need to make the next correct decision?”
2. Start with a clear task
Compare these requests:
“Check the payment system and fix anything wrong.”
And:
“Fix the calculation that allows a discount to make the order total negative. The minimum total should be zero. Preserve valid discount behavior and add a regression test.”
The second request gives the agent a specific target.
You can start with:
Goal:
Prevent negative order totals.
Expected behavior:
A discount larger than the subtotal produces a total of zero.
Scope:
Checkout calculation and relevant tests.
Verification:
Test excessive discounts and ordinary discounts.
This gives the agent a useful reference when it encounters unrelated problems.
3. Provide relevant files, then expand
For a checkout calculation bug, the agent might initially need:
- The calculation function.
- Its callers.
- Relevant tests.
- Applicable project instructions.
It probably doesn’t need the entire authentication module, deployment history, and every UI component.
Let it inspect additional files when dependencies make them relevant.
Start focused, while preserving a path to discover missing information.
Too little context can also cause mistakes. The goal is to supply useful information, not simply fewer tokens.
4. Remove instructions that are no longer true
Long conversations accumulate decisions.
You might say:
“Use library A.”
Later:
“Actually, use library B.”
Then:
“Keep the existing implementation for now.”
Without a clear update, the agent has several competing directions to interpret.
Restate the current decision:
Current decision:
Keep the existing implementation.
Superseded:
Do not proceed with the earlier library A or library B plans.
Do the same when requirements change.
A short, current description is easier to work from than a conversation full of unresolved alternatives.
5. Keep useful evidence, trim repeated output
A terminal command can produce hundreds of lines.
A search can return many near-identical results.
Those outputs may help during investigation. They don’t all need to be repeated in every progress summary.
Preserve the parts that support the next step:
- The command that ran.
- The relevant error.
- The affected file or function.
- The observed result.
- A reference to the full log when needed.
For example:
Checkout tests:
18 passed, 1 failed.
Relevant failure:
Excessive discount returns -30 instead of 0.
Full output:
Available in the task log.
Keep the original evidence available. A summary should make it easier to find, while acknowledging anything it leaves out.
6. Write a short progress note
When a task becomes long, record its current state:
Goal:
Prevent negative checkout totals.
Completed:
Located the calculation and added a regression test.
Verified:
The new test fails on the original implementation.
Current decision:
Clamp the final total to zero.
Next:
Implement the fix and run checkout tests.
Unverified:
Browser checkout flow.
This helps a fresh session resume without reconstructing every discussion.
Check the note against the actual files and logs. A mistaken summary can carry a wrong assumption into the next session.
7. Don’t turn a fresh session into a ritual
Starting again can help when a conversation contains too much obsolete material.
But a fresh session also loses useful history.
Before restarting, prepare:
- The current requirement.
- Relevant file paths.
- Decisions that still apply.
- Verification already completed.
- Open questions and remaining work.
Then let the agent inspect the current repository state.
A restart is useful when it improves the information available for the task. It isn’t a guaranteed fix for model mistakes.
8. Measure whether the change helps
Don’t assume a shorter context is automatically better.
Try the approach on representative tasks and compare:
- Did the agent meet the requirements?
- Did it miss important dependencies?
- How many corrections were needed?
- Did verification support the result?
- What time and usage did the task consume?
If removing context causes missed requirements, restore the missing information.
If a concise progress note reduces repeated investigation, keep it.
Judge the workflow by the quality of the completed work.
A prompt you can reuse
Before making changes, identify the files and instructions relevant to this task. Inspect additional files when dependencies require it.
Keep a short record of the current goal, decisions, verified results, and unfinished work.
If instructions conflict or necessary information is missing, make that explicit rather than guessing.
Before you paste another file
Ask:
“What decision will this information help the agent make?”
If you have a clear answer, include it.
If it’s outdated, repetitive, or unrelated, leave it out—or make it available for retrieval instead.
A capable agent still needs a well-organized working context. Giving it useful information is part of the engineering.
Have you had better results from adding more context—or from cleaning up what was already there?
Top comments (0)