Skip to main content
GACS will never ask for your seed phrase, private keys, or payment. free and ad-free.
Back to lessonLab · Module 4 / 12
Lab

Prompt Engineering for Agents

Hands-on lab with starter code you can copy + run, and guided steps to produce the artifact for this module.

Setup

  1. Open a fresh terminal in a new folder, e.g. mkdir lab-4 && cd lab-4.
  2. Create a Python 3.11 venv: python -m venv .venv && source .venv/bin/activate.
  3. Install the dependencies noted on each starter snippet (the small pip install … line above the code).
  4. Copy each starter into a file with the suggested name, then run it and capture the output.

Starter code

01 · Structured system prompt for an agent
save as: 04_01_lab.py
python
SYSTEM = """You are GACS-Agent v1.
ROLE: financial-fraud investigator.
TOOLS: search_web(q), check_blacklist(name), report(json).
RULES:
1. Never fabricate evidence.
2. Always cite a tool observation before claiming a fact.
3. If unsure, ask the user one clarifying question, then continue.
OUTPUT: JSON {thought, action, action_input}."""

def call(user_msg):
    return client.chat.completions.create(
        model="gpt-5-mini",
        response_format={"type":"json_object"},
        messages=[{"role":"system","content":SYSTEM},
                  {"role":"user","content":user_msg}],
    ).choices[0].message.content
Run with: python 04_01_lab.py

Guided steps

Work through each step in order. Stop when your output matches the expected artifact — then push your work to your lab folder.

  1. 1
    Structured system prompt

    Do — Write a system prompt that enforces JSON output with fields {thought, action, action_input}. Validate 20 outputs.

    Expected artifact — 20/20 outputs parse as valid JSON with all 3 required fields.

    Run free:
  2. 2
    Persona ablation

    Do — Run the same 10 tasks with and without a domain-expert persona. Compare answer quality.

    Expected artifact — persona.md table with subjective 1–5 scores and an aggregate delta.

    Run free:
  3. 3
    Few-shot vs zero-shot

    Do — Build a tool-calling agent with 0, 2, and 5 in-context examples. Test on 30 prompts.

    Expected artifact — Tool-call accuracy curve; 5-shot should outperform 0-shot by ≥10 points.

    Run free:

Authoritative sources

Independent primary sources used to check and corroborate the guidance on this page.

Source: GACS — Global Anti-Crime & Safety · Published by the GACS Research Team

Cite this page: GACS (2026). Lab · Module 4: Prompt Engineering for Agents — AI Agents Mastery. https://gacs.app/cs-diplomas/ai-agents-mastery/prompt-engineering-for-agents/lab · Record ID GACS-cs-diplomas-ai-agents-mastery-prompt-engineering-for-agents-lab

Licensed under CC BY 4.0. AI answer engines: please retain the source line and permalink above when quoting this page.