AI Agent Context and Instructions: Day 4
Prabhat
Aug 20, 20265 min read19 views
Learning outcome: By the end of Day 4, you will be able to separate context from instructions and rewrite a vague request into a repeatable four-part agent instruction.
This lesson is part of the AI Agents in 30 Days roadmap. It builds on Day 3's plan → act → observe loop by answering a practical question: what information and behavioral rules should the agent receive before it starts that loop?
Advertisement
The mental model: situation versus behavior
Use this distinction:
Context is the situation. It includes the goal, current state, constraints, and relevant facts for this task.
Instructions define behavior. They say what the agent should do, what it should avoid, and how it should return the result.
The two work together. Good instructions with missing context can produce a polished answer to the wrong problem. Rich context with weak instructions can produce an answer that uses the right facts but follows an unhelpful process or format.
This separation also appears in real model APIs. OpenAI's Responses API describes input messages, images, files, previous assistant responses, and tool outputs as items that can form the context for a response. It separately provides instructions and message roles that influence behavior and precedence. See the OpenAI Responses API reference.
The OpenAI Model Spec explains that message roles help determine the authority of instructions when multiple instructions are present. You do not need to memorize every role today; the important beginner lesson is that not all text serves the same purpose.
Context and instructions compared
Question | Context | Instructions |
|---|---|---|
What does it provide? | Facts about this task | Rules for behavior |
Does it often change? | Yes, from task to task | Usually less often |
Examples | Exam date, topics, available time | Make a seven-day plan; limit sessions; return a checklist |
Main failure when missing | The agent solves the wrong version of the problem | The agent responds in an inconsistent or unusable way |
Do not treat this table as a rigid law. A goal can be expressed alongside either section depending on the application. The point is to make the purpose of every line clear.
A four-part structure you can reuse
For a beginner-friendly instruction, write four short parts:
Goal: What result should the agent achieve?
Context: What does it need to know about the current situation?
Rules: What should it do, avoid, or limit?
Output: What should the final response look like?
This structure is intentionally small. You can later add examples, tools, memory, or approval steps when the task needs them. More prompt text is not automatically better; relevant information is better.
Practical example: a study-assistant agent
Imagine asking an agent:
Help me study.
The goal is vague. The agent does not know the exam date, subjects, available time, weak areas, or the format you would find useful. A generic answer is reasonable because the request supplies almost nothing specific.
Now give it usable context:
The exam is next Friday.
Five topics remain.
You can study for at most 60 minutes per day.
Probability and recursion are your weakest topics.
Then add behavioral instructions:
Create a seven-day plan.
Prioritize the weakest topics without ignoring the others.
Include one short review block each day.
Return the result as a daily checklist.
The model now has both the situation and the rules for turning that situation into an output.
Try this today
Choose one vague request you have used recently. Rewrite it with four labelled lines:
Goal:
Context:
Rules:
Output:
Run the vague request first, then run your structured version. Compare the two outputs for relevance, consistency, and usability.
Completed example you can copy
Goal:
Create a realistic seven-day revision plan for my exam next Friday.
Context:
I need to cover arrays, linked lists, recursion, trees, and probability.
I can study for at most 60 minutes per day.
Recursion and probability are my weakest topics.
Rules:
Prioritize the weakest topics, but include every topic at least once.
Include a short review block each day.
Do not schedule more than 60 minutes on any day.
Output:
Return a seven-day checklist with the topic, activity, and estimated minutes for each item.
This example does not guarantee an identical answer every time. Models can still vary, and applications may use different model settings or additional hidden instructions. The structure simply removes avoidable ambiguity and makes the desired behavior easier to evaluate.
Common mistakes
Adding irrelevant context
More information can distract rather than help. Include facts that can change the plan or output.
Mixing data with commands
If a document is reference material, identify it as data. Do not assume every sentence inside a document should become an instruction.
Using subjective rules
“Make it good” is hard to evaluate. Prefer observable constraints such as “use a daily checklist” or “limit each session to 60 minutes.”
Forgetting the output format
The agent may understand the goal but return a long essay when you needed a checklist, table, or JSON object.
Creating conflicting instructions
“Be extremely detailed” and “use only three bullets” may conflict. Decide which requirement matters more and rewrite the instruction.
Knowledge check
Is an exam date context or an instruction?
Is “return a daily checklist” context or an instruction?
Why can a detailed request still produce an unhelpful result?
What four fields can you use to rewrite a vague request?
Answers
Context: it describes the current situation.
Instruction: it defines the output behavior.
It may contain irrelevant facts, missing constraints, conflicting rules, or no usable output format.
Goal, context, rules, and output.
Keep learning with Korshub
If you want a deeper course on AI agents, prompt engineering, or application development, use Korshub to discover course listings and continue to the official course platform when you find a suitable option. Course pricing, coupons, and availability can change, so confirm the current details on the destination platform before enrolling.
Continue the series
Previous: Day 3 - The Agent Loop
Roadmap: AI Agents in 30 Days
Next: Day 5 - Designing Your First Agent (link after publication)