Agents: role, goal and backstory

CrewAI · Essentials · 10 min

Agent definitions are prompts in disguise; good ones are the biggest lever on output quality.

An Agent is one AI worker. CrewAI turns three plain-text fields into the agent's instructions:

  • role: the job title, for example "Senior market researcher". It appears in prompts and logs.
  • goal: what the agent is trying to achieve, in one or two sentences.
  • backstory: background that sets tone and expertise, such as "You have 10 years of experience analysing consumer apps and you always cite sources."

Together these act like a detailed system prompt. Specific, concrete wording works far better than vague praise like "You are the best researcher".

Other useful settings:

  • llm: which model this agent uses (a later lesson). If you leave it out, CrewAI uses the MODEL environment variable or its default OpenAI model.
  • tools: functions the agent may call, like web search.
  • verbose=True: print the agent's reasoning and tool use, very helpful while learning.
  • allow_delegation: lets the agent hand work to other agents in the crew. It is False by default.
  • max_iter: the most think-act cycles the agent may use on one task (default 25), a safety limit against endless loops.
  • max_rpm: a cap on model requests per minute, to respect provider rate limits.

Text fields can contain {placeholders} such as {topic}. They are filled in when the crew starts, so one agent definition can serve many inputs.

An agent does nothing on its own: it needs a task to work on.

Example

from crewai import Agent

researcher = Agent(
    role="Senior {industry} researcher",
    goal="Find recent, verifiable facts about {topic} and cite every source",
    backstory=(
        "You have ten years of experience in {industry} analysis. "
        "You prefer primary sources and say clearly when something is uncertain."
    ),
    verbose=True,           # show reasoning and tool calls in the terminal
    allow_delegation=False, # default: do not hand work to other agents
    max_iter=15,            # stop after 15 think-act cycles on a task
)
print(researcher.role)      # Senior {industry} researcher  (filled in at kickoff)

Remember

  • role, goal and backstory become the agent's instructions
  • Be concrete: expertise, standards and constraints beat flattery
  • max_iter, max_rpm and allow_delegation control cost and behaviour

Watch out for

  • Writing a long, generic backstory; it costs tokens on every call and rarely helps more than two specific sentences.

Check yourself

  1. Which agent field mainly states what the agent is trying to achieve?

Sign in to answer, see the explanations, and get this lesson back as a quick review later.

Official docs: docs.crewai.com/en/concepts/agents