liveBook · Manning

Persona

As explained in AI Agents in Action, Second Edition

An agent persona is a role, background, behavioral style, expertise profile, and operating-constraint specification that guides an AI agent's responses and task behavior.

An agent persona is the set of instructions that defines an agent’s role and guides how it handles tasks and responds. Often called the system prompt, it can specify expertise, communication style, domain focus, and operating constraints. A writing assistant and a coding assistant may use different personas even if both can answer questions. section 1.3.1

Think of the persona as the agent’s operating brief, not its entire skill set. Tools let an agent take actions; reasoning and planning help it choose what to do. The persona shapes those choices and constrains how the result is communicated. These parts interact throughout a task rather than running in a fixed sequence. section 1.3

Write a persona as a clear contract:

  • Name one focused role and state what the agent does and does not do. Include an explicit way to say “I don’t know” when information is missing. section 11.1.1
  • Specify the output format when another program or agent will consume the answer. A JSON response matched to a typed schema avoids brittle string parsing. section 11.1.1
  • Supply relevant changing facts, such as the date or organization, through runtime instructions rather than hardcoding them. Too much injected context can add tokens and confuse the agent. section 11.1.1

A focused support persona

A support assistant can be instructed to answer concisely, prefer retrieved context, admit when context is missing, and never invent facts or make policy exceptions. Its response can follow a typed format with an answer, citations, and a confidence value. Each instruction has a job: set behavior, establish a boundary, or make the result easier for software to handle. section 11.1.1

Listing 11.1 01_core_persona_tips.py
from pydantic import BaseModel, Field
from agents import Agent, Runner
from datetime import date

class Answer(BaseModel):    #1
    """Machine-readable answer format."""
    answer: str = Field(..., description="Concise, user-facing answer")
    citations: list[str] = Field(default_factory=list)
    confidence: float = Field(..., ge=0, le=1)

def core_instructions(ctx, agent) -> str:    #2
    today = date.today().isoformat()    #3
    return (
        f"You are SupportMentor, a helpful domain assistant. Today is {today}.\n"    #4
        "Always:\n"
        "1) Answer concisely; 2) Prefer retrieved context; 3) If context is missing, say you don't know.\n"
        "Output must be valid JSON matching the Answer schema.\n"
        "Never: make policy exceptions or invent facts."
    )

core_agent = Agent(
    name="SupportMentor",
    instructions=core_instructions,   
    output_type=Answer                
)

input = "What's our refund window for accessories?"
result = Runner.run_sync(core_agent, input)
print(result.final_output)

The listing shows how to combine runtime instructions with a Pydantic response model and an OpenAI Agents SDK agent. section 11.1.1

How AI Agents in Action, Second Edition covers it

How deep it goes
Defines the persona, then develops role boundaries, structured output, and runtime instructions through a code example.
Examples
Uses a support assistant with dynamic date instructions and a typed answer containing citations and confidence.
What it assumes
Introduces the role from a plain-language definition; uses Python and typed schemas in its implementation example.
What you can do after
Build it from scratch with a focused role, explicit boundaries, an uncertainty off-ramp, and a defined output format.
How it connects
Connects system prompts and prompt engineering to tools, reasoning and planning, knowledge and memory, and evaluation and feedback.

Also explained in

Compare how 6 books explain persona →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of AI Agents in Action, Second Edition. The section links point to the parts of the book it draws on.