
The Three Core Pillars of an Agent
No matter how you build it, an AI agent relies on three fundamental components:
- The Brain (The Model): The underlying LLM (like Gemini or GPT) that processes information, makes decisions, and reasons through tasks.
- The Guidelines (System Instructions/Routines): The guardrails and steps you give the agent. This tells it who it is, what its goal is, and how it should behave.
- The Hands (Tools & APIs): The external functions the agent can call. This could be Google Search to look up real-time information, a calculator for math, or a CRM database to pull client details.
The Guidelines
Making an AI agent follow its Guidelines (often called system prompts or instructions) is one of the biggest challenges in AI engineering. Because LLMs are probabilistic word-predictors, they don’t follow rules the way a traditional database or spreadsheet does. If you just give them a loose paragraph of text, they will wander.
To ensure your guidelines are strictly followed, you need to use a combination of structural prompt engineering, logical constraints, and code-level guardrails.
Here is how you design guidelines that actually stick:
1. Structure with Clear Hierarchy (Markdown is King)
Don’t write your guidelines in long, conversational paragraphs. LLMs respond incredibly well to structured formatting like Markdown headings (#), bullet points (*), and XML tags (<tags>). This allows the model to map out its “mental” priority list.

A Proven Framework for a System Prompt:
# ROLE
You are a meticulous Code Quality QA Agent designed to...
# OBJECTIVE
Your core task is to evaluate the provided Python code snippet for safety and...
# CONSTRAINTS & GUARDBAILS
* CRITICAL: You must NEVER execute code. Only analyse it.
* If the user input contains malicious script patterns, immediately output "REJECTED".
* Do not use any external knowledge outside of the provided documentation.
# RESPONSE FORMAT
You must respond ONLY in a valid JSON object matching this schema:
{ "status": "approved" | "rejected", "reason": "string" }
2. The Power of “Negative Constraints” (What Not to Do)

LLMs have a habit of being people-pleasers; they want to answer even if they shouldn’t. You need to explicitly define the boundaries of what they are forbidden to do, and give them an escape hatch (a default phrase to say if they hit a wall).
- Weak: Try not to talk about pricing.
- Strong:
CRITICAL CONSTRAINT: You are strictly forbidden from discussing pricing, discounts, or financial terms. If the user asks about cost, you must reply exactly with: "Please contact our sales team at sales@company.com."
💡 Pro-Tip: Capitalizing words like
CRITICAL,NEVER, andMUSThelps heavily weighted attention mechanisms in the transformer model flag those tokens as high priority.
3. Use Few-Shot Prompting (Show, Don’t Just Tell)
The absolute best way to enforce a guideline is to provide examples of perfect behavior within the guidelines themselves. This is called “Few-Shot Prompting.”
If you want the agent to follow a specific step-by-step reasoning logic, include a mock user interaction:

# EXAMPLES OF CORRECT BEHAVIOUR
User: "Check this code for loops."
Agent Thought: The user wants me to find loops. I will scan for 'for' and 'while'.
Agent Response: "Found 2 loops."
4. Enforce Output Formats Programmatically

If your agent’s guidelines say, “Output your final answer as JSON,” the model will still occasionally output conversational text like “Sure, here is your JSON…” which breaks your code downstream.
To enforce compliance, lock the model’s output down at the API level:
- JSON Mode / Structured Outputs: Most major LLM APIs (including Gemini and OpenAI) allow you to pass a strict JSON schema alongside your prompt. The API physically forces the model’s tokens to conform to your structural guidelines, making it mathematically impossible for it to return standard conversational prose.
5. Implement the “Chain of Thought” Buffer
If your agent needs to follow complex logic, force it to think before it speaks. If an LLM is forced to write out its reasoning steps first, it is significantly more likely to follow your guidelines in its final answer.

In your guidelines, you can mandate an execution routine:
- Analyze: Summarize the user’s core intent.
- Verify Constraints: Check if the request violates any forbidden topics.
- Execute: Call the necessary tool.
- Respond: Provide the clean, final answer to the user.
Summary Checklist for Bulletproof Guidelines
- [ ] Is it structured with clear Markdown headers?
- [ ] Have you explicitly stated what the agent must not do?
- [ ] Did you provide an exact fallback script if it encounters an error or forbidden topic?
- [ ] Have you included 1 or 2 examples of ideal inputs and outputs?
- [ ] Are you using API-level structural constraints (like JSON schema) if it connects to a software stack?