A prompt is the instruction and context that guides a language model or agent toward a desired response. Prompt engineering turns that input into a reliable control layer: clear, structured prompts make behavior more predictable, productive, and cost-aware. section 2.2
A useful prompt behaves less like a casual question and more like an executable specification. State the role, put the main directive first, separate supplied data with delimiters, and specify the audience, objective, length, and output shape when needed. section 2.2.1
Build prompts progressively:
- Assign a role or persona to establish vocabulary, tone, and depth. section 2.2.1
- Front-load instructions and fence user data with unique delimiters. section 2.2.1
- Add concrete constraints such as audience, word count, objective, or response format. section 2.2.1
- Keep stable instructions, persona, and tool definitions near the top when prompt caching matters; place dynamic content later. section 2.2.1
A compact research prompt
You are an expert Research AI Librarian. Find five relevant recent articles for the supplied query. Write for technology analysts, use only the last 30 days, and limit each summary to 150 words. Delimit the query separately from the instructions, then require exactly five results.
Table 2.2 Essential prompt techniques
| Technique |
Description |
Example prompt snippet |
How it works with agents |
| Assign a clear role or persona |
State a role that sets vocabulary, tone, and depth. |
“You are a senior DevOps engineer. Diagnose the Docker error below …” |
Switch persona strings to create researcher, critic, or planner agents without code changes. |
| Front-load Instructions and use delimiters |
Put the directive first; fence user data with unique markers. |
Task: Summarize in ≤100 words. Article: ` |
Always apply this practice with agents. |
| Be specific and detailed. |
Supply concrete length, audience, and objective. |
“Write a 200-word LinkedIn post in a friendly tone with two actionable tips …” |
Prevents agents from producing outputs that violate word limits or brand tone. |
| Define the exact output format. |
Provide a skeleton JSON / CSV / Markdown structure. |
|
OpenAI Agents SDK supports typed outputs, so this won’t be required in our examples. |
| Use few-shot examples. |
Embed labelled examples as mini unit-tests. |
Input: “Free Bitcoin!!!” ⇒ Label: Spam Input: “Team lunch?” ⇒ Label: Not Spam |
Agents can store examples in a vector DB and retrieve similar ones at runtime for adaptive prompting. |
| Chain-of-thought for complex reasoning |
Ask the model to think step by step, then answer. |
“Let’s work this out step by step … Return only the final value.” |
Produces an auditable reasoning trace that a critic or verifier agent can inspect before execution. |
| Emphasize positive instructions. |
Say what to do, not just what to avoid. |
“Explain using high-school language.” (versus “Don’t use jargon.”) |
Positive phrasing lowers rule-violation rates, boosting autonomous reliability. |
| Eliminate ambiguity |
Replace fuzzy words with numeric bounds. |
“Provide 3–4 key points under 50 words total.” |
Agent guardrails can auto-check length and count and trigger retries if out of spec. |
| Pick the right model and settings. |
Match model tier and generation knobs to the task. |
model=gpt-4o, temperature=0.7, max_tokens=300 |
Balances cost, latency, and reasoning depth so agents meet specifications. |
| Iterate and refine. |
Treat each response as feedback; tighten and repeat. |
After each run, log prompt + output; adjust length spec or add an example; rerun until >95 % on spec. |
Logs feed a format-fixer sub-agent or fine-tune, creating a self-improving agent pipeline. |
Use the technique table as a checklist for persona, instruction order, delimiters, specificity, and output-format decisions. section 2.2.1
Prompt quality has boundaries. Conflicting instructions make priorities ambiguous; oversized prompts consume context and tokens; overly fragmented prompts add latency and cost. Split large tasks into role-specific steps, but consolidate related micro-tasks when repeated calls are wasteful. section 2.2.3
In agent systems, do not duplicate tool metadata or structured-output declarations inside the instruction prompt when the SDK already supplies them. Keep only tool-specific guidance that changes handling, and validate behavior against the required output. section 7.2.3

















































