Contextual Prompting, simply: from chat to AI Agent

Contextual Prompting, simply: from chat to AI Agent

Imagine asking a friend to help you cook a meal. Without telling them what you want (a chocolate cake), who the audience is (children), the constraints (gluten-free), and what you expect (a 5-step recipe), they are likely to get it wrong.

Contextual prompting is exactly that: giving the AI the key information it needs to get it right the first time.

For those of you who are new to AI, this article will demystify the subject step by step.

We'll start with the simple basics with AI chats (such as ChatGPT), then move on to more advanced AI agents (which sometimes work alone in the background).

By the end, you'll know how to properly brief an AI, with examples and exercises.

Ready? Let's go!


What is contextual prompting?

Contextual prompting is the art of providing an AI with essential information—in the right place and at the right time—so that it understands and responds effectively to your request.

It's like giving a clear briefing to a colleague: without context, AI can invent details or give overly general answers. With the right context, it becomes accurate and useful.

Simple metaphor: Think of a GPS. Without telling it your destination, constraints (avoid tolls), and style (scenic route), it will send you anywhere.

Contextual prompting is entering these details for a relevant route.

The 4 basic building blocks of context

  • Objective: What you want to accomplish (e.g., “Write a cake recipe”).
  • Audience: Who is it for? (e.g., “For 8-year-olds”).
  • Constraints: Limits (e.g., “Gluten-free, less than 300 words”).
  • Deliverables: What you expect as output (e.g., “A numbered list of steps”).
    Concrete example

    Instead of saying "Tell me about dogs" say:
Objective: Explain 5 dog breeds.
Audience: Children.
Constraints: 5 breeds max, simple language.
Deliverables: List with one fun fact per breed.
Box: Common mistakes
  • Context too vague: ”Do something cool" → Random response.
  • Too late: Adding details after the fact → AI may ignore them or contradict itself.
  • Contradictions: “Be brief” but “Give details” → Confusion.

Illustration 1 : the 4 building blocks

[Objective] --> [Audience] --> [Constraints] --> [Deliverables]
  (Goal)        (For whom?)   (Limitations)        (Output)
Ex: Recipe    Children         Gluten-free      Steps
Key takeaway: Good contextual prompting significantly reduces vague or incorrect responses, especially when Objective, Audience, Constraints, Deliverables are provided from the outset.

There are multiple levels in the usage of the building blocks for a contextual or structured prompting (if you want to explore them).


Context locations: Chat vs. Agent (visual reminder)

  • Chat: the context lives in the system prompt and your messages within the context window (short memory). Sometimes a long memory exists (profile, notes) that persists from one session to another.
  • Agent: the context lives in the orchestrator (server), input/output contracts (JSON) between roles (Planner / Executor / Critic), policies (authorized tools, limits), and persistent memory (knowledge base, cache).

Context for AI chats/assistants (human interaction in a chat UI)

Here, we are talking about interfaces such as ChatGPT or Claude, where you chat live with the AI via a chat. It is interactive, like a ping-pong game: you ask a question, the AI responds, and you adjust.

Where it works

  • System message: a fixed prompt at startup (e.g., “You are a history teacher”).
  • Conversation instructions: added to your messages (e.g., “Respond in French”).
  • Short-term memory: the context window (what the AI sees of the current discussion).
  • Long-term memory (sometimes): persistent notes or user profiles.
  • Tools: one-off calls (e.g., web search if enabled).

Usage logic

Fast and iterative. Ideal for short tasks with low latency (a few seconds). The AI follows your instructions without a complex plan.

Best practices

  • Provide a framework using the 4 building blocks: {Objective, Audience, Tone, Constraints, Deliverables}.
  • Provide 1–2 input/output examples for guidance.
  • Require formats (lists, tables) and limit (no detailed thought chains).
    Mini-exercise

Rewrite this poor brief: “Write about Paris.” →

Objective: Describe Paris.
Audience: Novice tourists.
Constraints: 200 words max, focus on history.
Deliverables: 3 paragraphs with a travel tip.
Before/after example
Before: “What is AI?” → Generic answer.
After: “Objective: Explain AI simply.
Audience: Beginners.
Constraints: No jargon.
Deliverables: Definition + 2 examples.” → Clear and focused answer.

Illustration 2 : Human ↔ chat interaction

[Human] —(brief + short context)—> [Chat Assistant]
      ^<—— rapid iterations (questions/answers) ——>^
Ex: “Add more details?” → Immediate adjustment

Illustration 3: short-term vs. long-term memory

Short-term (window): [Msg1] [Msg2] [Msg3] (may forget the very first ones)
Long term           : [Fixed profile] <-- persistent --> [Saved notes]

Box: Frequent errors (chat)

  • Overloading the window: too many messages → the AI “forgets” the beginning.
  • Ignoring tone: not specified → response too formal or too familiar.

Key point: in a chat, the context is dynamic and adapts to each message.

Context for AI agents (agentic patterns + orchestration)

Let's move on to AI agents: more autonomous systems that can work in the background, without constant interaction. Like a personal assistant who plans your trip on their own, calling on tools (flight search, booking, etc.).

Where they operate

  • Orchestrator/server: central brain that manages tasks.
  • Background tasks: executed without you (e.g., triggers such as a received email, a timer, an event).
  • Workflow graphs: chains of steps (plan → execute → verify).
  • Systematic access to tools: Planner (plans), Retriever (searches for information), Executor (acts), Critic/Guard (controls).
  • Persistent state: long memory (knowledge base), cache for intermediate results.
  • Controlled limits: budgets (time, tokens, costs) and policies (authorized tools, security).

Usage logic

Multi-step, with planning and verification. Ideal for complex tasks; longer latency (minutes to hours depending on the job).

Key patterns (simply defined)

  • ReAct: reasoning + acting in a loop (observe → use a tool → update the response).
  • Plan–Act / Reflect: plan, act, correct if necessary.
  • Plan–Execute: overall plan, then step-by-step execution.
  • Stateful Agents: agents with persistent state (memory) for continuity.
    Best practices (agents)
  • Separate roles: the Planner only plans; the Executor executes; the Critic verifies.
  • Declare resources & constraints: budgets, authorized tools, deadlines, policies.
  • Define I/O contracts in JSON: clear, mandatory fields.
  • Avoid detailed thought processes: prefer action logs and observable validation criteria.

Summary table of few patterns (the full list count +50 patterns)

Pattern Description Example
ReAct Think + act in a loop Agent that searches for and summarizes an article.
Plan–Act / Reflect Plans, acts, corrects Coding agent who tests and corrects bugs.
Plan–Execute Overall plan + execution Workflow to produce an automatic report.


Illustration 4 : agent pipeline

[Trigger/Brief] -> (Planner) -> [Plan JSON]
                   |              \
                   v               -> (Executor) -> [Actions/Tools] -> [Results]
                (Critic/Guard) -> [Checks] -> [Validation/Retry]

Illustration 5 : JSON I/O contract + budgets

Input  : { objective: “Plan trip”, constraints: “Budget $500” }
Contract: {
  steps: [
    { id: 1, goal: “Search flights”, tool: ‘flight_search’,
      input: { route:“PAR-ROM”, dates:"2025-10-12. .2025-10-16“ },
      expected_output: { table: [”airline“,”price“,‘stopovers’] },
      success_criteria: ”≥2 options < $120" }
  ],
  budgets: { thinking_tokens: 2000, max_time_s: 60 }
}
Output: { steps: [...], summary: “Routes and prices selected” }

Box: Common errors (agent)

  • Mixing roles: Planner who executes → chaos and lack of control.
  • Ignoring budgets: agent loops → costs/time skyrocket.
Key takeaway: agents are like autonomous robots, with a structured context for orchestration (roles, contracts, budgets, persistent memory).

Clear comparison: chats vs. agents

Execution location Memory type Interaction unit Typical latency Controls I/O format Common errors Typical example
Chat UI (browser/app) Short (window) + sometimes long Ping-pong Q&A 1–5 s Basic (prompts) Free text, lists Forgets context, vague responses Ask for a recipe
Orchestrator (background) Persistent (KB, status) Multi-step workflow Minutes–hours Budgets, guardrails, policies Structured JSON + reports Cost overruns, loops Automate emails/reports

In the news (educational vignettes)

  • Automated deep search: public “agent” systems can investigate a topic, consult pages, compare sources, and produce a summary—a good example to visualize the difference from a simple chat response.
  • “Fast vs. deep” routing : some platforms automatically choose a fast model (for small tasks) or a reasoning model (for complex tasks), illustrating the latency/quality trade-off.

Step by step: from your idea... to the right context

  1. Formulate the objective and the audience (e.g., “Generate business ideas for beginning entrepreneurs”).
  2. Choose: Chat or Agent depending on complexity/controls required.
  3. Write the prompt MVP: add the 4 building blocks.
  4. Test, observe, improve: add examples, specify deliverables.
  5. If agent: define roles, tools, JSON I/O contracts, guardrails, and budgets.
    Illustration 6 (ASCII): guardrails & budgets
[Brief] -> [Guardrail: Budget 100 tokens] -> [Agent]
          | (if exceeded) -> [Stop + Alert]

FAQ for beginners

Should you tell the AI everything?

No, focus on the essentials. Too many details overload and muddle the message.

What is a “tool”?

For an AI Agent a tool is an external function that the AI calls (web search, spreadsheet, email, another agent, etc.).

What is an orchestrator?

The “conductor” who coordinates the roles of an agent (planner, executor, critic) and memory.

How can I avoid made-up answers?

Give clear constraints, provide examples, and, if necessary, allow factual research.


Glossary

  • Context: information given to the AI to guide its response.
  • Context window: short memory of a discussion (limited in tokens).
  • System Prompt: fixed instructions at startup.
  • Agent: autonomous AI that acts alone or semi-autonomously.
  • Orchestrator: system that manages workflows, roles, and memory.
  • Planner: role that plans the steps.
  • Executor: role that executes actions/tools.
  • Critic/Guard: control role (validation, security, quality).
  • Memory: storage of persistent information (profile, KB, cache).
  • RAG: Retrieval-Augmented Generation (search before response).
  • Budget: limits (time, tokens, costs) imposed on the agent.
  • Guardrails: rules to prevent undesirable behavior.
  • ReAct: reason + act pattern.
  • Hallucination: unsupported invented response.
  • Token: text unit (≈ piece of word) used to measure costs.
  • Workflow: chain of automated steps.

Quick checklist

For Chat

  • Objective ✔
  • Audience ✔
  • Tone ✔
  • Constraints ✔
  • Deliverables ✔
  • I/O example ✔

For Agent

  • Roles (planner/executor/critic) ✔
  • Inputs (JSON) ✔
  • Expected outputs ✔
  • Authorized tools ✔
  • Policies (guardrails) ✔
  • Budgets (time/tokens) ✔
  • States (memory) ✔
  • Controls (validation) ✔

Conclusion

In summary:

  1. Contextual prompting makes AI more reliable with 4 simple building blocks.
  2. Chats for quick interactions; agents for complex automations with control.
  3. Always test step by step and iterate with small additions of context.
    Practical exercise
    Take a daily task (e.g., planning a meal) and brief an AI chatbot with the four building blocks. Then, imagine an agent to automate weekly planning (roles, tools, JSON contract, budget).