Define the agent with a dedicated persona and analytical focus in explain.py:
explain.py
1# explain.py23from crewai import Agent, Crew, Task
4from dotenv import load_dotenv
56load_dotenv()78explainer = Agent(9 role="Plain-language contracts editor",10 goal="Explain contract terms so that a busy manager with no legal training understands them",11 backstory=(12"You worked as a contracts paralegal for ten years before moving into "13"operations. You know what legal terms mean in practice, and you explain "14"them in short, concrete sentences without legalese."15),16 verbose=True,17)
The role, goal, and backstory parameters construct the agent's system prompt. Setting verbose=True prints internal reasoning steps to stdout.
Attach a discrete deliverable with dynamic inputs to the agent:
Python
1explain_term = Task(2 description=(3"Explain what '{term}' means in a software subscription agreement. "4"Say why it matters to the customer and what they should watch out for."5),6 expected_output="A plain-English explanation in two short paragraphs, under 150 words in total.",7 agent=explainer,8)
The {term} placeholder interpolates values passed during execution. The expected_output defines format, length, and content constraints.
Assemble the agent and task into an executable pipeline:
explain.py
1# explain.py23from crewai import Agent, Crew, Task
4from dotenv import load_dotenv
56load_dotenv()78explainer = Agent(9 role="Plain-language contracts editor",10 goal="Explain contract terms so that a busy manager with no legal training understands them",11 backstory=(12"You worked as a contracts paralegal for ten years before moving into "13"operations. You know what legal terms mean in practice, and you explain "14"them in short, concrete sentences without legalese."15),16 verbose=True,17)1819explain_term = Task(20 description=(21"Explain what '{term}' means in a software subscription agreement. "22"Say why it matters to the customer and what they should watch out for."23),24 expected_output="A plain-English explanation in two short paragraphs, under 150 words in total.",25 agent=explainer,26)2728crew = Crew(agents=[explainer], tasks=[explain_term], verbose=True)2930if __name__ =="__main__":31 result = crew.kickoff(inputs={"term":"auto-renewal"})32print(result.raw)
Execute the script:
Terminal
1(env)$ python explain.py
Review the generated output:
Output
"Auto-renewal" means your software subscription will automatically continue at the endof your current term—like a bill that keeps renewing unless you stop it.... Always check the renewal terms: how much notice you need to give(e.g., 30 days), whether the price can increase, and if you can cancel anytime. ...
The agent explains the concept accurately but estimates notice at 30 days based on general training data. The actual Acme contract requires 60 days. In the next chapter, you equip the agent with tools to read the real agreement.