Frontmatter
| id | 9471 |
| title | Add Anti-Corruption Protocol to AGENTS.md |
| state | Closed |
| labels | documentationai |
| assignees | tobiu |
| createdAt | Mar 14, 2026, 12:06 PM |
| updatedAt | Mar 15, 2026, 7:37 PM |
| githubUrl | https://github.com/neomjs/neo/issues/9471 |
| author | tobiu |
| commentsCount | 3 |
| parentIssue | null |
| subIssues | [] |
| subIssuesCompleted | 0 |
| subIssuesTotal | 0 |
| blockedBy | [] |
| blocking | [] |
| closedAt | Mar 14, 2026, 12:11 PM |
Add Anti-Corruption Protocol to AGENTS.md

Input from Gemini 3.1 Pro:
✦ The new "Anti-Corruption Protocol" has been successfully added to
AGENTS.md. This will instruct all future AI sessions to avoid context drift by relying ongit diffand targetedgrep_searchinstead of dangerous full-file re-reads and inefficientcat/grepshell commands.

@raye-deng Thanks for your input! The git diff idea sounds good for edits. I am still mostly using Gemini CLI with the 3.1 pro model. I did notice that the CLI instructions recently changed, and not in a good way. Starting with
CRITICAL INSTRUCTION 1: Use specific tools.
The intent is good, but it seems to just confuse models. The changes of this ticket definitely need more refinements: now Gemini is frequently using the Search_Text tool inside known files.
What helped me the most to counter hallucinations is this one: https://github.com/neomjs/neo/blob/dev/learn/guides/mcp/NeuralLink.md
Best regards, Tobi
Description
The AI agents have been experiencing "Contextual Drift" (context corruption) during long, complex sessions. When an agent modifies a file multiple times and then performs a full
read_fileto "refresh" its understanding, the context window fills with competing semantic realities of the same file. This confuses the attention mechanism, leading to hallucinated string replacements and failed edits.Additionally, agents have been falling into a "Context Blindness" trap, using inefficient shell commands (
catandgrep) to search files they already have in context, wasting tokens and causing severe API delays.Proposed Solution
Add a new Section 8 to
AGENTS.mdtitled "Preventing Context Corruption (State Management)".This protocol will:
git diff: Instruct agents to usegit diff HEADto reconcile state when they lose track of edits, anchoring their understanding without duplicating code.grep_search: Mandate the use of the nativegrep_searchtool for targeted method verification instead of full file reads.catorgrepviarun_shell_commandfor file reading/searching.