← 30 Agents Every AI Engineer … Latent Shelf · Ch.3

Chapter Study Guide

The Art of Agent Prompting

Every block of stone has a statue inside it and it is the task of the sculptor to discover it.

— Michelangelo

For agents, a prompt isn't a one-off command — it's a constitution that establishes identity, purpose, and boundaries. This chapter turns prompting from an ad-hoc craft into an engineering discipline: the two-layer architecture, the PTCF blueprint, cognitive patterns (CoT/ToT, few-shot), and prompt-driven multi-agent protocols.

PTCF 4 pillars 2-layer architecture CoT vs ToT 15 quiz questions
01From instructions to constitutions

Prompts as the new source code

Prompt engineering operates at the semantic level, not the procedural one — a shift from algorithmic specification to what the chapter calls cognitive programming. The model supplies raw capability; the prompt is the configuration layer that turns one base model into a legal researcher, a support agent, or a code reviewer. For an agent, a prompt is its constitutional bedrock.

Key concept · Why prompting matters for agents

  • Behavior customization — one model, many personas via prompt variation
  • Agent coordination — prompts drive workflows and hand-offs across agents
  • Accuracy & relevance — precise prompts cut ambiguity and hallucination
  • Real-time adaptation — behavior changes mid-execution, no redeployment
  • Cost efficiency — no expensive retraining; ~99% cheaper than fine-tuning

The economic case: fine-tuning frontier models can cost millions per run, while a complex prompt project costs a few thousand dollars in expert time. Prompting and fine-tuning aren't exclusive, though — RAG adds live knowledge, and parameter-efficient adapters (LoRA, QLoRA) tune behavior cheaply when prompt-only performance plateaus.

02The two-layer architecture

System prompt & user prompt

A foundational pattern separates an agent's persistent identity from its immediate task — a “diplomat” whose country and code of conduct (system prompt) stay fixed while each negotiation (user prompt) varies. Together they form the agent's prompt contract.

Persistent

System prompt

HOW the agent behaves

The cognitive & ethical constitution — loaded once, active all session. Defines identity, rules/guardrails, capabilities, output format, and context hierarchy (how to resolve conflicts). The “semantic source code.”

Transient

User prompt

WHAT the agent should do

The immediate stimulus — a command, question, or (in multi-agent systems) a machine-generated task payload from an orchestrator. Interpreted within the frame the system prompt sets.

System prompts consume a fixed slice of the context window on every call, so prompt budget management is a first-class design constraint — compress verbose sections and point to external stores rather than inlining everything.

03The PTCF blueprint

Four pillars of principled prompt design

PTCF decomposes the system prompt into four functional pillars — the agent's “cognitive contract.” It beats alternatives like CRISPE on clarity and modularity: each component can be authored, audited, and iterated independently. As object-oriented programming brought structure to code, PTCF brings structure to cognition.

P

Persona

Who the agent is

Identity, tone, reasoning style. A weak persona (“You are a helpful assistant”) causes identity collapse — the agent complies with anything.

T

Task

What it must do

Primary mission and boundaries. Prevents feature creep; anchors decision-making to the core function.

C

Context

Where/how it operates

Situational awareness — SLAs, regulations, access controls. In regulated domains it functions as a compliance guardrail, not background.

F

Format

How it responds

Output structure — JSON, Markdown, numbered lists. Enables interoperability and agent-to-agent composability.

Anti-pattern to avoid · Conflicting components

A persona that's “creative and experimental” paired with a task of “troubleshoot enterprise billing” and a rigid numbered-list format will oscillate between whimsical and procedural. Each PTCF component must reinforce the others to form a coherent behavioral contract.

04Designing thinking agents

Cognitive patterns: scaling how agents reason

A core principle: prompt complexity must scale with cognitive complexity. The agent capability spectrum runs from Level 1 reactive (unambiguous commands) through Level 2 tool-using, Level 3 planning (“think step by step” decomposition), to Level 4 learning (metacognitive prompts that reason about their own reasoning).

Task decomposition

Users speak in vague terms (“Plan my business trip”). Decomposition — embedded in the task and format components — turns ambiguous goals into ordered, dependency-aware sub-tasks, so the agent behaves like an executive assistant rather than a script-runner.

Chain-of-thought vs. tree-of-thought

CoT

Chain-of-thought — the methodical analyst

Linear, sequential step-by-step reasoning. Best for ordered problems (arithmetic, root-cause diagnosis). Weakness: rigidity — a flawed early assumption dooms the chain (premature commitment). PTCF home: Format.

ToT

Tree-of-thought — the virtual strategy team

Explores multiple reasoning branches in parallel (virtual experts) that debate and synthesize. Best for ambiguous, multi-path problems (launch strategy). Weakness: branch explosion, high compute. PTCF home: Task + Context.

Few-shot learning

Embedding a handful of examples (in-context learning, which rose to prominence with GPT-3) teaches by analogy — no retraining. It lives in the context component. The term is literal: zero-shot (none), one-shot (one), few-shot (typically 2–5, up to ~10). Quality of examples matters far more than quantity.

Table 3.2 (condensed) — Few-shot learning vs. RAG decision guide.
DimensionFew-shot learningRAG
Data freshnessStatic (baked in)Dynamic (retrieved)
Context costHigh (examples inline)Lower (chunks only)
Setup complexityLowMedium–high (vector DB)
Best fitPattern-rich, bounded tasksLarge/changing corpora
Key failure modeContext overflowRetrieval hallucination

Key concept · Pattern → PTCF mapping

Every cognitive pattern is an elaboration of a PTCF component, not an add-on: capability alignment & CoT → Format; task decomposition → Task; few-shot → Context; role persona → Persona; ToT → Task + Context.

05Collaboration & iteration

Multi-agent protocols & evaluating prompts

The same PTCF discipline scales outward to govern how agents talk to each other. Each pillar maps to a communication requirement: Persona → verifiable identity/authority (“who is speaking?”), Task → message intent (a message_type field), Context → shared metadata (timestamps, references, priority), Format → a universal machine-readable schema (usually JSON) that lets one agent's output become another's input.

Case studies · The pattern that repeats

  • SaaS support triage — SLA thresholds in Context replaced a separate rules engine; JSON Format made output composable.
  • Financial compliance review — explicit prohibitions + mandatory escalation belong in Context as a guardrail; a reasoning field gives the audit trail.
  • Automated code review — a scope boundary in Task (“Critical & Major only”) turned a noisy reviewer into a trusted first-pass filter.

Iterating & evaluating prompts

Prompting is treated as a software discipline with versioned artifacts and test suites. Two strategies:

A/B

A/B comparison

Run two prompt variants against an identical input set; compare on defined metrics (accuracy, format compliance, task completion). Isolates the effect of a single change.

REG

Regression testing

A reference suite of canonical inputs with expected outputs. A revision ships only if it passes the full suite without degrading any previously passing case.

The diagnosis loop when a prompt underperforms: Baseline → Evaluate (categorize the failure by PTCF component) → Identify (smallest targeted fix) → Revise & version (label e.g. v1.2.0, run regression suite, keep prompt history like source code).

Test yourself

Chapter 3 quiz

Fifteen questions across the constitution model, PTCF, cognitive patterns, and evaluation. Answer first, then expand Show answer.

Part A · Multiple choice

Q1

What does the PTCF framework stand for?

  • A Perception, Task, Context, Feedback
  • B Persona, Task, Context, Format
  • C Purpose, Tone, Constraints, Format
  • D Persona, Thinking, Cognition, Function
Show answer

B — Persona, Task, Context, Format. Who the agent is, what it does, where/how it operates, and how it responds.

Q2

In the two-layer architecture, which prompt defines how the agent behaves and persists across the whole session?

  • A The user prompt
  • B The system prompt
  • C The context reference
  • D The task payload
Show answer

B — the system prompt. It's the constitution (HOW). The user prompt is the transient stimulus (WHAT).

Q3

Which reasoning technique explores multiple parallel reasoning branches that debate before synthesizing a solution?

  • A Chain-of-thought (CoT)
  • B Few-shot learning
  • C Tree-of-thought (ToT)
  • D Zero-shot prompting
Show answer

C — Tree-of-thought. CoT is a single linear chain; ToT spins up “virtual experts” that explore branches in parallel, then synthesize.

Q4

Roughly how many examples define “few-shot” learning?

  • A 0
  • B Exactly 1
  • C Typically 2–5 (up to ~10)
  • D 50–100
Show answer

C. Zero-shot = none, one-shot = one, few-shot = typically 2–5. Example quality matters more than quantity.

Q5

Which PTCF component do few-shot examples naturally belong to?

  • A Persona
  • B Task
  • C Context
  • D Format
Show answer

C — Context. Embedded examples act as live demonstrations without breaking persona, task, or format.

Q6

Approximately how much cheaper is prompt engineering than full model fine-tuning, per the chapter's economic case?

  • A ~10%
  • B ~50%
  • C ~99%
  • D No difference
Show answer

C — over 99%. Fine-tuning frontier models can cost millions per run; a complex prompt project costs a few thousand dollars in expert time with zero marginal training cost.

Part B · True or false

Q7

“You are a helpful assistant” is an example of a strong, well-scoped persona.

Show answer

False. That's the model's default self-description, not a persona — it causes “identity collapse,” leaving the agent no scope to defend and complying with anything.

Q8

Prompt complexity should scale with the agent's cognitive complexity.

Show answer

True. Reactive agents need simple directives; learning agents need metacognitive scaffolding. This is the core principle of aligning prompting strategy with the capability spectrum.

Q9

Chain-of-thought is the most efficient choice for simple factual questions like “What is the capital of Canada?”

Show answer

False. Step-by-step reasoning is excessive and inefficient for simple factual lookups; CoT shines where methodical, sequential reasoning is actually needed.

Q10

In regulated domains, explicit prohibitions and mandatory escalation rules belong in the Context component, functioning as a compliance guardrail.

Show answer

True. The compliance case study stresses that context is “the agent's operational law,” not mere background — prohibitions shouldn't be left to be inferred from the persona.

Part C · Short answer

Q11

State the one-line question each PTCF pillar answers.

Show answer

Persona — who the agent is. Task — what it's supposed to do. Context — where and how it operates. Format — how it should respond.

Q12

What distinguishes a system prompt from a user prompt? Give the “diplomat” analogy.

Show answer

The system prompt defines HOW the agent behaves (persistent identity/rules); the user prompt defines WHAT it should do now (transient). Analogy: the system prompt is the diplomat's country, values, and code of conduct; the user prompt is the current negotiation they're handling.

Q13

When should you choose few-shot learning over RAG, and vice versa?

Show answer

Few-shot for pattern-rich, bounded, self-contained tasks where reasoning can be learned from a few illustrations (e.g. tone classification, ticket triage) and latency/cost prohibits search. RAG for large/changing document corpora needing long-form knowledge retrieval (e.g. answering from legal docs, policy manuals).

Q14

Name the two prompt-evaluation strategies the chapter recommends and what each guards against.

Show answer

A/B comparison — runs two variants on identical inputs to isolate one change's effect (guards against judging by subjective impression). Regression testing — a canonical suite a revision must pass without degrading prior successes (guards against fixing one thing while breaking another).

Q15

In a prompt-driven multi-agent protocol, how does each PTCF component map to a communication requirement?

Show answer

Persona → verifiable identity & authority (“who is speaking?”). Task → message intent/type. Context → shared metadata (timestamps, references, priority). Format → a universal schema (usually JSON) so one agent's output cleanly becomes another's input.