Skip to content
TheChatArchiveThe Chat Archive
chatgpt-4o-latest-20250326· OpenAIHugging Face LMArena Human Preference 140K

why do llm most of the time refuse to give you the entire code that you gave them to do…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with DeepSeekdeepseek-v3-0324’s answer.
  1. User

    why do llm most of the time refuse to give you the entire code that you gave them to do modifications? is it the instructions to save money on tokens?

  2. Assistant

    Great question! The behavior you're describing — where large language models (LLMs) like ChatGPT sometimes don't return the full modified code you gave them, even when you ask for it — can be frustrating, and it stems from a combination of reasons:


    🧠 1. Token Limit Awareness

    LLMs operate within a token budget (a fixed amount of data they can process in each request + response). Large pieces of code, especially with modifications, can consume a lot of tokens. So:

    • If the original code is large, and the generated modifications also add text, the model may truncate the response or only include part of the code.
    • The system tries to save space to ensure a complete answer without getting cut off, which sometimes leads to omitting large unchanged parts of the code.

    💵 2. Cost & Efficiency Considerations

    While OpenAI doesn’t explicitly cripple output to reduce token use, providers may optimize outputs to reduce internal processing costs (tokens = compute = money).

    • There might be a soft incentive in some platforms or UI layers to avoid sending unnecessarily verbose code unless explicitly asked (e.g., “only show the changed function” vs “regenerate the entire file”).

    🔧 3. Instruction Interpretation

    LLMs are trained to infer what you probably “want” unless you're very specific:

    • If you say, “Modify the logging in this function,” the model may assume you only want to see the modified portion, not necessarily the full file.
    • Unless you say things like “Return the full modified version of the entire script,” it often defaults to a minimal diff-style response.

    🔄 4. Mental Model of Code as a Patch

    Some models are trained or fine-tuned to treat code edits like diffs — showing only the changes (like in GitHub PRs), especially for productivity. This might explain why you often get:

    # Modified function:
    def foo():
        print("Updated log here")
    

    Instead of the full file. It's intended to be efficient and human-readable—though not always what you want!


    ✅ How To Get Full Modified Code Reliably

    • Give explicit and precise instructions, like:

    "Please return the full updated version of this script, with all modifications applied, not just the changed parts."

    • You can also say:

    "Show me the entire updated file starting from line 1, including unchanged code."


    🚧 TL;DR

    Yes, there's an interplay between token efficiency, instruction interpretation, and possibly cost-saving logic, but the root cause is usually:

    The model’s attempt to minimize output length while still being helpful — unless told otherwise.


    If you'd like, I can help you write a reusable prompt template that guarantees full code outputs every time.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.