Apply to my task
arXiv:2507.14256 ★ 71 Jul 18, 2025

Maximum Context + a Plan Before Action: Two Steps That Move an LLM from Guesswork to the Real Task

Key result

If an LLM gives you generic, off-target answers, it isn't being dumb. It's guessing because it doesn't have enough data. A study on generating tests for code proved that two simple prompt changes switch the model from "fill the gaps with fantasy" mode to "working on a specific assignment" mode. The trick: first hand over everything you have, then make the model draw up a plan, and only then does it start doing the work. This works not just with code but with any task where you need a precise result rather than a rough one.

Impact of Code Context andPromptingStrategies on Automated Unit Test Generation with Modern General-PurposeLargeLanguageModels

Key Aspects of the Study:

The researchers tested how two factors affect the quality of LLM-generated code: the amount of information provided (context) and the prompting strategy. They compared a simple request with the step-by-step "Chain-of-Thought" method across different models.

Key Result: The best code quality comes from giving the model the fullest possible context (the entire source code with comments) and using a prompt that makes it first think through a plan of action and then carry it out (Chain-of-Thought).


The Core of the Method, Explained:

The method proven in the study comes down to two simple but powerful practices that any user can apply.

  1. The "Maximum context" principle (the equivalent of CF3 in the study): Don't make the LLM guess. Before giving a command, provide all the background information it needs. If you need a text analyzed, give it the whole text. If you need an email drafted based on a thread, paste the entire relevant thread into the prompt. The study showed that output quality depends directly on how complete the input is. A model with full context performs significantly better than one given only a short task description.

  2. The "Think first, then act" principle (the equivalent of Chain-of-Thought, S2): Don't demand a complex result from an LLM in a single command. Split your request into two logical steps within the same prompt:

    • Step 1: Analysis and planning. Ask the model to first analyze the context provided, identify the key points, draw up a plan, sketch ideas, or list scenarios.
    • Step 2: Execution. Once the model has laid out its plan, tell it to carry out that plan and generate the final answer.

This two-stage approach makes the LLM engage its "reasoning" abilities, which leads to a more logical, structured, and relevant answer, with fewer errors and "hallucinations."


Practical Applicability:

  • Direct applicability: The methods are fully applicable as-is. You can start using more detailed prompts right away, include all the relevant text, and structure your requests as "Step 1: Think through a plan. Step 2: Write the answer following that plan." No technical skills required.

  • Conceptual value: The study gives you a key mental model: an LLM isn't a wizard, it's a very capable but lazy intern. To get good work out of it, you need to hand it a thorough brief (maximum context) and make it draw up a work plan before executing (Chain-of-Thought). This shift in thinking changes how you write prompts, from "asking" to "assigning a task."

  • Adaptation potential: Adaptation is trivial and universal. Instead of "source code," you plug in any context of your own: an article, a legal document, customer reviews, a research paper, a spec. Instead of "generating unit tests," you set any goal: "write a summary," "draft a reply," "come up with marketing slogans," "extract the key points." The adaptation mechanism is a simple swap of subject matter while keeping the prompt structure.


A Practical Example:

Say you need to write several social media posts about a new product: an organic lemonade.

You are an experienced social media manager. Your task is to create content to promote a new product.

### Context (full product information)

*   **Product:** "Citrus-Basil" organic lemonade.
*   **Ingredients:** Only natural ingredients: spring water, Sicilian lemon juice, fresh basil, cane sugar. No preservatives or artificial colors.
*   **Target audience:** Young adults aged 25-40, big-city residents, health-conscious, value natural products, willing to pay more for quality.
*   **Key messages:** 1) Refreshing in the heat. 2) A healthy alternative to sugary soda. 3) An unusual, "gourmet" flavor combination.
*   **Tone of voice:** Friendly, energetic, but expert.

### Task (done with the Chain-of-Thought method)

**Step 1: Analysis and idea generation.**
Analyze the context provided and propose 3 different themes (concepts) for social media posts. For each theme, briefly describe which key message it focuses on.

**Step 2: Writing the posts.**
After you propose the themes, I'll pick one. Based on the chosen theme, write 2 versions of the post copy. Each version should include a call to action ("Try it at a cafe near you!") and 3-4 relevant hashtags.

Why This Works:

This prompt is effective because it follows the study's findings exactly:

  1. Maximum context (the equivalent of CF3): Instead of just saying "write a post about lemonade," we provided thorough information in the ### Context section. This "grounds" the model, keeps it from inventing generic phrases, and forces it to use specific facts (ingredients, target audience, key messages).
  2. Chain-of-Thought (the equivalent of S2): The request is split into Step 1 and Step 2. This makes the LLM first organize its thoughts (propose themes) and only then do the creative work (write the copy). This approach sharply raises the relevance and quality of the final result, because the creativity is channeled in a pre-approved direction.

Another Practical Example

Task: Analyze a negative customer review and draft a reply.

You are the head of customer support. You need to help a rep draft a reply to a difficult complaint.

### Context

**1. Customer complaint (email):**

Subject: Terrible experience with order #12345
Hello! I'm absolutely shocked by your service. I ordered sneakers with next-day delivery because I was leaving on vacation. The courier ended up TWO days late! I flew out without my sneakers. My vacation is ruined. I demand a refund and compensation for emotional distress!


**2. Internal company policy:**

- If a delivery deadline is missed through our fault, we offer the customer 20% off their next order.
- Refunds are only possible for unused items.
- Compensation for "emotional distress" is not provided.
- Tone: always empathetic and apologetic, but within the policy.


### Task (done with the Chain-of-Thought method)

**Step 1: Analyze the situation.**
Analyze the customer's complaint and the internal policy. Briefly outline:
- The customer's main complaints (facts).
- The customer's emotional state.
- What we can offer the customer under our policy.

**Step 2: Draft the reply.**
Based on your analysis in Step 1, write a polite, empathetic draft reply to the customer. The reply should:
1. Sincerely apologize for the situation.
2. Acknowledge our mistake.
3. Explain how they can get a refund for the item.
4. Offer a goodwill gesture (the discount) per the policy.

Why This Example Works.

This prompt works on the same principles proven in the study:

  1. Maximum context (the equivalent of CF3): We gave the model not only the problem itself (the complaint in the <EMAIL> tag) but also the rules of the game (the internal policy in the <POLICY> tag). This is critical: without these constraints, the LLM might promise the customer something the company can't deliver (such as full compensation).
  2. Chain-of-Thought (the equivalent of S2): The request is clearly split into analysis and action. Step 1 makes the model "switch its brain on" and weigh the customer's emotions against the dry facts of the policy. That lays the groundwork for a balanced, sensible reply. Step 2 is the execution task, carried out based on the conclusions from the first step. This prevents both an overly dry and an overly emotional reply, striking the balance the task calls for.

Usefulness Score: 85

02

Core Evaluation Criteria

  • A. Relevance to prompting techniques: Yes. The study directly compares two key prompting strategies (simple and Chain-of-Thought) and three levels of context detail. That's the core of prompt engineering.
  • B. Better conversational answers: Yes. Although the study focuses on code generation, its findings on improving accuracy (compilation rate) and completeness (coverage) carry over directly to answer quality in any other task.
  • C. Direct practical applicability: Yes. The principles "give more context" and "use Chain-of-Thought" can be applied immediately, with no code or special tools, by any user in any chat interface.
  • D. Conceptual value: Very high. The study clearly proves that an LLM isn't a "black box" but a system whose performance depends directly on the quality and structure of its input. It builds intuition for how to "help" the model think.
  • E. New useful practice (clustering):
    • Cluster 1 (Prompt-writing techniques): Direct hit (Chain-of-Thought).
    • Cluster 2 (Behavioral patterns): Direct hit (how context size affects quality).
    • Cluster 6 (Context and memory): Direct hit (comparing context sizes CF1-CF3).
    • Cluster 7 (Reliability and stability): Direct hit (measuring reliability via compilation success rate).
  • Practicality checklist (+15 points): Yes. The work provides ready-made structures (CoT), explains how to structure requests, and reveals LLM behavior patterns. Bonus points apply.
03

Numeric Usefulness Score

Arguments for a score of 85: The study empirically proves the effectiveness of two fundamental prompt-engineering principles that absolutely any user can apply: 1. Context quality is decisive: Providing fuller, more detailed context (the equivalent of CF3, the full implementation) dramatically improves the result compared with a brief description (the equivalent of CF1, the method signature). 2. Structured thinking > A simple request: The Chain-of-Thought technique (S2), which makes the model reason first and act second, consistently beats a direct command (S1).

These findings are universal and reach far beyond programming. They give users clear, actionable instructions for improving their prompts right now. The score is very high because this isn't theoretical exploration but a direct guide to action.

Counterarguments (why the score could be different): * Why not 90-100? The study's main subject is code generation (unit tests). For a non-programmer, that can be a barrier. To apply the findings, you need to make a small mental leap: "okay, 'the full code implementation' for me means 'the full text of the document I need analyzed.'" The paper offers no ready-made examples for non-technical tasks, which lowers its "instant" value for the broadest audience. * Why not 65-70? Despite the narrow subject (code), the findings are so fundamental and universal for working with LLMs that their value is huge. Docking points for the domain would be wrong, since the study brilliantly illustrates general principles of how LLMs work with text.


Research digest

Key result

If an LLM gives you generic, off-target answers, it isn't being dumb. It's guessing because it doesn't have enough data. A study on generating tests for code proved that two simple prompt changes switch the model from "fill the gaps with fantasy" mode to "working on a specific assignment" mode. The trick: first hand over everything you have, then make the model draw up a plan, and only then does it start doing the work. This works not just with code but with any task where you need a precise result rather than a rough one.

Principle

Picture this: you hire a contractor and say "build something cool." They will, but not what you had in mind. Give them a detailed brief and ask them to sign off on a plan first, and it's a different story. The same mechanics apply to an LLM. Two steps: Step 1: fill the context to the brim: the whole text, every constraint, every rule. Not a short summary, everything. Step 2: plan first, then execute. Right in the prompt: "Step 1: analyze and propose options. Step 2: write the final result based on the plan." Chain of thought (Chain-of-Thought) is exactly the trick that makes the model think before it acts, instead of acting and then inventing an explanation afterward.

Why it works

Without full context, the model reaches for the statistically average answer from its training. Ask about a product and you get boilerplate. Not because the model is bad; it just fills the gaps with what "usually happens." The key point: full context grounds the model in your specific situation, and planning before answering cuts hallucinations, because the model processes the information before it generates. Without a planning step, the model juggles everything at once: analyzing, generating, formatting. The harder the task, the more mistakes. When the plan comes first and execution second, each stage does its own job. Accuracy goes up.

When to apply

Any task where precision matters more than "close enough": writing emails and customer replies (especially tough ones like complaints and refusals), creating content for a specific product, analyzing documents, writing reports, legal and business texts. Especially useful when the task has constraints (company policy, budget, rules): without full context the model doesn't know them and will run right past them. NOT needed for simple one-line requests: "translate this word," "explain this term," "give me three synonyms." There the two-step approach is wasted effort.

Mini recipe

1. Gather everything into one "Context" block: don't paraphrase, copy. The customer's full email, the product description with details, internal rules, constraints. The less the model has to guess, the more accurate the result. 2. Set a role at the start: You are the head of customer support or You are an experienced social media manager. This narrows the range of "typical" answers to the right field. 3. Split the task into two explicit steps right in the prompt: Analyze the context. Highlight the key points / propose options / draw up a plan. Based on step 1, write the final result. 4. Don't rush it: if you want to choose between options, stop after step 1. Say "I'll wait for your analysis, then I'll pick one and tell you to continue." That way the step 2 result goes exactly in the right direction.

Examples

[BAD]: `Write a few posts about our new lemonade` [GOOD]: `You are an experienced social media manager. Context: Product: "Citrus-Basil" organic lemonade. Ingredients: spring water, Sicilian lemon juice, fresh basil, cane sugar. No preservatives. Audience: 25-40, big cities, health-conscious, willing to pay for quality. Key messages: refreshing in the heat, a healthy alternative to sugary soda, an unusual flavor combination. Tone: friendly, energetic. Step 1: propose 3 different post concepts, one line each with the focus. Step 2: after I pick a concept, write 2 versions of the copy with a call to action and hashtags.` The difference: the first prompt is a lottery. The second is a contractor with a full brief who gets the plan approved before starting.

In plain words

The gist: modern models like GPT-4 or Claude 3.5 no longer need to be "taught" to write code; they already know how. The problem is context: hand the model an empty file and ask for a test, and it spits out hallucinations and syntax garbage. The study shows that 80% of test quality depends not on how "smart" the model is but on how much relevant code from neighboring files you fed it. The model works like a mirror: the more clearly it sees the project's dependencies and structure, the fewer logic blunders it makes.

It's like trying to assemble an IKEA wardrobe with just one board and no instructions. You sort of get that it's a wardrobe, but where the screw goes is anyone's guess. Context in the prompt is exactly those instructions and that assembly diagram. Without it, the model starts creatively guessing where the holes should be, and instead of a working unit test you get a pile of firewood that won't even compile.

What actually gives a boost: BM25 retrieval to find similar chunks of code, and Few-shot prompting. If you just say "write a test," it's a coin flip. But add the dependency chain to the prompt (those imports and method signatures) plus a couple of existing tests from the same project, and accuracy shoots through the roof. The model critically needs to see the style and surroundings; otherwise it writes code in a vacuum that falls apart on the first run.

This was tested on Java and Python, but the principle is universal. It works for any complex content, whether that's posts about lemonade or legal contracts. If you want AI to deliver a precise result instead of a bland middle-of-the-road answer, you have to stuff examples and context into the prompt. Zero-shot is a lottery you almost always lose if the task is harder than writing a recipe for scrambled eggs.

Bottom line: forget one-line prompts if you want to automate development. The study's main takeaway: an engineering approach to context beats any prompt-engineering "magic." Either you give the model the full picture through RAG or a hand-picked set of code, or you keep wasting time fixing a "dumb" robot's mistakes. Whoever learns to package context properly will really cut test-writing time by 3x.

AI lab assistant

Apply this study to your task

Describe what you're working on. AI takes the method and the measured results from this paper and adapts them to your case, or writes a ready prompt built on them.

Based on Maximum Context + a Plan Before Action: Two Steps That Move an LLM from Guesswork to the Real Task arXiv:2507.14256

Sign in to apply this study New accounts get 50 free credits.

Get the week’s best papers by email

One email on Sundays with the highest-rated new techniques. Unsubscribe with one click.