CrewAI Beginner Workflow - Simple Responder

A starter project translating enterprise technical jargon into clear business value using CrewAI & Google Gemini.


crewai_quickstart.py
import os
from crewai import Agent, Task, Crew, Process, LLM

# 1. Environment Configuration
os.environ["GOOGLE_API_KEY"] = "YOUR_GOOGLE_API_KEY"

# 2. Define the Brain (LLM)
gemini_brain = LLM(
    model="gemini/gemini-1.5-flash",
    temperature=0.5
)

# 3. Define the AI Agent
responder_agent = Agent(
    role="Senior Technical Copywriter",
    goal="Translate complex, dry technical jargon into clear, high-impact business value.",
    backstory=(
        "You are an expert at enterprise software modernization. You excel at taking "
        "dense, low-level architecture descriptions and explaining them so clearly "
        "that both business stakeholders and developers immediately understand the value."
    ),
    verbose=True,
    allow_delegation=False,
    llm=gemini_brain
)

# 4. Define the Task
raw_input_data = (
    "Migrating legacy monolithic enterprise modules to a containerized microservices "
    "architecture utilizing an asynchronous event-driven bus for cross-module communication."
)

respond_task = Task(
    description=f"Analyze this technical feature description: '{raw_input_data}'. Rewrite it into a 2-sentence summary that highlights practical business efficiency.",
    expected_output="A concise, two-sentence business-value summary.",
    agent=responder_agent
)

# 5. Assemble the Crew and Execute
crew = Crew(
    agents=[responder_agent],
    tasks=[respond_task],
    process=Process.sequential
)

# Kick off workflow
print("--- Starting CrewAI Agent Workflow ---")
result = crew.kickoff()

print("\n--- Final Structured Response ---")
print(result)

Code Structure & Core Concepts

CrewAI designs AI workflows similar to human software development teams. Instead of giving a general prompt to a standard chatbot, you construct specialized Agents with dedicated roles, assign them precise Tasks, and group them into a Crew to manage execution.

1. LLM Configuration
Brain

LLM(model="gemini/gemini-1.5-flash") acts as the processing engine driving the agent. Setting temperature=0.5 balances structural consistency with subtle creative writing, ensuring explanations sound natural rather than overly robotic.

2. Agent Blueprint
Persona

An Agent defines the AI worker's specific domain expertise:

  • Role: Job title and expertise scope.
  • Goal: The primary objective governing all responses.
  • Backstory: Context that conditions tone, vocabulary, and analytical approach.
  • verbose=True: Prints step-by-step thinking logs to the console.
3. Task Specification
Assignment

A Task details the operational instructions given to the agent.

  • description: Detailed instructions along with the raw source string.
  • expected_output: Explicit formatting constraints (forcing a 2-sentence target summary).
  • agent: Explicitly assigns accountability to responder_agent.
4. Crew Orchestration
Manager

The Crew class acts as the supervisor coordinating execution:

  • agents & tasks: Accepts ordered lists of workers and jobs.
  • Process.sequential: Executes tasks in linear order (Task 1 → Task 2).
  • kickoff(): Triggers the pipeline and compiles the final string output.
Key Takeaway

Even when running a single agent, CrewAI requires wrapping the execution inside a Crew container. This architectural pattern makes it easy to scale up later by adding secondary agents (e.g., an Editor agent or a Code Reviewer agent) into the same pipeline without changing your fundamental logic.