CrewAICrewAI 1.15 · Python 3.10 to 3.13
0%
1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
32 small wins to finish your pathNext lesson

What the model is sent

An agent's role, goal and backstory, and the task's description, become ordinary messages. Printing them shows exactly what the model reads before it answers.

Lesson 4's crew answered, but the model was hidden inside it. A small subclass of ShopLLM can print every message it receives and then answer as before.

Examplepeek.py
from shop_llm import ShopLLM


class Peek(ShopLLM):
    def call(self, messages, tools=None, **kwargs):
        for message in messages:
            print(f"--- {message['role']}")
            print(message["content"].strip())
        return super().call(messages, tools, **kwargs)

Peek changes nothing about the answer. It prints each message's role and text, then hands over to ShopLLM.call with super().

Examplecrew.py, as it stands
from crewai import Agent, Crew, Task
from shop_llm import ShopLLM

agent = Agent(
    role="Support agent",
    goal="Answer customers of a small online shop",
    backstory="You have worked the shop's support desk for years.",
    llm=ShopLLM(model="shop"),
)
task = Task(
    description="Answer the customer: Where is my order A17?",
    expected_output="One short, friendly sentence.",
    agent=agent,
)
crew = Crew(agents=[agent], tasks=[task])

The crew as it stands, with its agent, its task and the model it runs on.

Two messages

Example
agent.llm = Peek(model="shop")
crew.kickoff()

The system message is built from the agent: You are and the role, then the backstory, then the goal. The user message is built from the task: the description, then the expected output, then two instructions CrewAI adds to every task. A hosted model reads all of it, which is why the documentation's advice on crafting agents is mostly about writing a specific role and a concrete goal.

The model never learns it is part of a crew. Each agent's call is a fresh conversation, and anything it needs from another agent has to arrive in these messages; lesson 14 shows how.

The backstory is prompt text

Example
agent.llm = Peek(model="shop")
agent.backstory = "You answer in one sentence and never guess an order status."
crew.kickoff()

Changing an attribute changes the prompt on the next run. The role, goal and backstory are only text the model reads.

Try it yourself
  • Set agent.goal to something else and find where it lands in the system message.
  • Change expected_output to "A reply of at most ten words" and read the user message.
  • Add a second task for the same agent and count how many times Peek prints.

Every expert started right here.