Skip to course content
Free CrewAI course

CrewAI for Multi-Agent Automation

Unit 02.00: A role that changes behaviour, not just tone

"You are a world-class expert with twenty years of experience" changes how an agent writes. It does not change what it will refuse to do.

Constraints, not credentials

A role definition earns its place when it makes some outputs impossible. Credentials and adjectives adjust register; rules adjust behaviour.

The code builds a decorative agent and a functional one and counts the constraints in each backstory.

from crewai import Agent

decorative = Agent(
    role="Senior Expert Analyst",
    goal="Provide excellent analysis",
    backstory="You are a world-class analyst with 20 years of experience.",
    allow_delegation=False,
)
functional = Agent(
    role="Refund eligibility checker",
    goal=("Decide whether a refund request falls inside the 7-day window, "
          "using only the purchase date and the request date"),
    backstory=("You have exactly two inputs. If either is missing you say so "
               "rather than estimating. You never consider goodwill exceptions."),
    allow_delegation=False,
)

for label, agent in [("decorative", decorative), ("functional", functional)]:
    rules = sum(w in agent.backstory.lower()
                for w in ("only", "never", "rather than", "if"))
    print(f"{label:11} constraints in backstory: {rules}")
    print(f"            goal: {agent.goal[:70]}")

# "World-class with 20 years of experience" changes the tone of the output and
# nothing about what the agent will or will not do. "You never consider goodwill
# exceptions" changes an answer.

The functional agent's backstory contains three rules: exactly two inputs, say so rather than estimating, never consider goodwill exceptions. Each one rules out a specific output you would otherwise get.

The last is the sharpest. "Never consider goodwill exceptions" is the difference between an agent that says a refund is outside the window and one that helpfully suggests making an exception - which is a decision the business did not delegate to it.

The mistake this prevents

The mistake is writing roles that read well. "Meticulous", "senior", "detail-oriented" cost tokens on every call and change nothing you could test for. If you cannot name the output a line prevents, cut the line.

Takeaway

Write role and backstory as rules that rule things out. The test for every line: what output does this make impossible? If the answer is none, it is decoration.