How an AI can overwrite an existing function and break your code ?

A developer can forget an existing function, and on a team nobody knows a large file by heart. Here is how an AI reacts in that situation.

The silent, invisible truncated read

If your 2,500 line file (100,000 characters) is read by an AI in a single pass, the viewer shows the beginning and the end but ignores the middle. The middle of the file is truncated automatically, without the slightest signal: the AI’s reading tool cuts off beyond a certain threshold without you ever knowing.

"Claude (Opus 4.8) describes this truncation mechanism itself. Unedited screenshot."

The truncation mechanism, explained by the AI itself: it keeps the beginning and the end of the file and drops the middle, with no error and no warning.

That threshold is not the same everywhere. It depends on the reading tool the AI uses, and you do not control it. This is exactly what makes the problem dangerous: you do not know when the cut happens, nor where, nor what was lost. It is a risk you suffer without being able to anticipate or control it.

And do not rely on chunked reading or on a grep to protect you. Reading in slices can still skip the affected zone. A grep only finds the exact text you searched for: if the same logic exists under a different name, it does not see it.

Worse still: the code that depends on this function does not even live in the file you are modifying. It is scattered across other files in the project that the AI never opened. The AI edits one file blind, without knowing that ten others call it. Only AviaCoder, which loads your entire project into its FCMC (Full-Context Multi-Cache) pipeline, sees those calling files and detects the already-existing function. A conventional AI simply does not have them in its field of view.

Two versions of the same function

If the function you ask an AI to implement already exists in that truncated, unread middle, the file will contain two versions of the same function.

"Claude (Opus 4.8) describes this truncation mechanism itself. Unedited screenshot."

Because the middle was never seen, the AI implements the function “from scratch” and reports success, unaware that a duplicate now overrides the original.

In Python, if two functions share the same name, the last definition in the file overrides the previous one. The result is worse than a visible error: every existing call now runs the new, incomplete version, which breaks the older, more detailed function.

No crash, no warning. The old behavior simply disappears, and everything that depended on it stops working silently, reproducing the exact same silent-cascade pattern, but caused by a duplicate rather than a rename.

Demonstration

Take a concrete function: get_user_balance().

The old function, detailed, the one that lived in the truncated middle

def get_user_balance(user_id, currency="EUR"):
    account = db.fetch_account(user_id)
    if account is None:
        return {"amount": 0.0, "currency": currency, "status": "not_found", "last_updated": None}

    amount = account.raw_balance
    if account.currency != currency:
        amount = convert_currency(amount, account.currency, currency)

    cache.set(f"balance:{user_id}", amount, ttl=300)   # side effect: caching
    audit_log.write("balance_read", user_id=user_id)   # side effect: traceability

    return {
        "amount": round(amount, 2),
        "currency": currency,
        "status": account.status,       # "active", "frozen", "closed"
        "last_updated": account.updated_at,
    }

The new function, incomplete, the one the AI rewrites without seeing the old one

def get_user_balance(user_id):
    account = db.fetch_account(user_id)
    return account.raw_balance

The AI, not seeing the original, produces the “obvious” version: it just returns a number. In Python, this second definition overrides the first in the file. Every existing call now runs this one.

The decisive point plays out now. The three files that follow, billing.py, display.py and risk_check.py, are not the file the AI just modified. They are other files in the project, never opened by the AI, never loaded into its context. It has no idea they exist. Only AviaCoder, with its full context, read them at the same time as the modified file, and therefore sees the impact of the rewrite immediately. Here is what breaks in those invisible files.

Proof 1: dictionary keys disappear and break other files

billing.py:

balance = get_user_balance(user_id, currency="USD")
if balance["status"] == "active":        # TypeError: 'float' object is not subscriptable
    charge(balance["amount"])

The new function returns a float, no longer a dictionary. balance["status"] crashes. The currency="USD" argument even raises a TypeError earlier, because the new signature no longer accepts it.

Proof 2: a feature silently stops working

display.py:

b = get_user_balance(user_id)
label = f"{b['amount']} {b['currency']}"   # KeyError / TypeError

The multi-currency display relied on currency and amount. Currency conversion (convert_currency) is gone: a USD account is now shown as a raw amount, with no conversion and no symbol. The “balance in the user’s currency” feature no longer exists.

Proof 3: a silent break with no crash, the worst case

risk_check.py:

balance = get_user_balance(user_id)
if balance and balance["status"] != "frozen":
    allow_withdrawal(user_id)

Before, a frozen account (status == "frozen") blocked withdrawals. Now balance is a float. The condition if balance becomes true as soon as the balance is not zero, and the "frozen" check is gone. Result: a frozen account can withdraw money. No error, no log. The business safeguard has simply vanished.

Other breaks caused by the same rewrite

Lost side effects. The old function wrote to the cache and to the audit log. The new one does none of that. The balance cache is no longer populated, which slows down or makes other pages inconsistent, and the audit trail runs dry, a regulatory problem invisible until the day of an inspection.

Unhandled edge case. The old function handled account is None (a non-existent account) by returning a clean status. The new one calls account.raw_balance directly: on an unknown account, None.raw_balance raises AttributeError. A path that used to work now crashes in production.

Broken type contract. Throughout the code, get_user_balance was expected to return a dictionary. Dozens of calls depend on that contract. A single type change propagates errors across the whole project, while the modified file itself “looks” correct.

That is the central point: the incomplete function does not merely do less, it breaks a contract that files the AI never saw were relying on.

Impossible with AviaCoder

AviaCoder reads your code 100%, without truncation. Its FCMC (Full-Context Multi-Cache) pipeline necessarily sees the existing function in the middle of the file, and above all every file that calls it, billing.py, display.py, risk_check.py and the rest, which the conventional AI never opened. The silent duplication, the cascade of breaks and the broken type contract become impossible, because nothing relevant stayed hidden. That is the difference between editing a file blind and editing an entire project with full awareness.