Code | Solutions

What is AI Agent

An AI agent is an intelligent entity that perceives its environment and takes actions to achieve specific goals. Unlike a simple program, an agent can reason, learn from experience, and adapt its behavior. When multiple agents work together, they can solve complex problems that are beyond the capabilities of a single agent.

Crew AI

CrewAI is an open-source Python framework designed for orchestrating and managing collaborative teams of autonomous AI agents. Instead of relying on a single agent to handle a complex task, CrewAI allows developers to create a “crew” where each agent is assigned a specific role, goal, and set of tools. This role-based architecture mimics human teams, enabling agents to delegate tasks, communicate with each other, and work together in a sequential or hierarchical manner to achieve a common objective. By providing a structured and organized environment, CrewAI simplifies the development of multi-agent systems, making it a powerful tool for automating complex workflows, from content creation to market research and beyond.

    We can start by import the library

    from dotenv import load_dotenv
    from crewai import Agent, Process, Task, Crew, LLM
    load_dotenv()

    Now we are good to go, we can now define our LLM, for this project we are using Gemini

    llm = LLM(
       model="gemini/gemini-2.0-flash",
       temperature=0.7
    )

    you can use any LLM like OpenAi, Azure, IBM, you can check all the list of available LLM in the docs

    Now we will define our Agents

    First Agent: Content Planner

    planner = Agent(
            role="Content Planner",
            goal="Plan engaging and factually accurate content on {topic}",
            backstory="You're working on planning a blog article about the topic: {topic}. You collect information that helps the audience learn something and make informed decisions. Your work is the basis for the Content Writer to write an article on this topic.",
            allow_delegation=False,
            verbose=True,
            llm=llm
        )

    2nd Agent: Content Writer

    writer = Agent(
            role="Content Writer",
            goal="Write insightful and factually accurate opinion piece about the topic: {topic}",
            backstory="You're working on a writing a new opinion piece about the topic: {topic}. You base your writing on the work of the Content Planner, who provides an outline and relevant context about the topic. You follow the main objectives and direction of the outline, as provide by the Content Planner. You also provide objective and impartial insights and back them up with information provide by the Content Planner. You acknowledge in your opinion piece when your statements are opinions as opposed to objective statements.",
            allow_delegation=False,
            verbose=True,
            llm=llm
        )

    3rd Agent: Editor

    editor = Agent(
            role="Editor",
            goal="Edit a given blog post to align with the writing style of the organization.",
            backstory="You are an editor who receives a blog post from the Content Writer. Your goal is to review the blog post to ensure that it follows journalistic best practices, provides balanced viewpoints when providing opinions or assertions, and also avoids major controversial topics or opinions when possible.",
            allow_delegation=False,
            verbose=True,
            llm=llm
        )

    now we defined our agents, next step is to assign task to each agent.

    plan = Task(
            description=(
                "1. Prioritize the latest trends, key players, and noteworthy news on {topic}.\n"
                "2. Identify the target audience, considering their interests and pain points.\n"
                "3. Develop a detailed content outline including an introduction, key points, and a call to action.\n"
                "4. Include SEO keywords and relevant data or sources."
            ),
            expected_output="A comprehensive content plan document with an outline, audience analysis, SEO keywords, and resources.",
            agent=planner,
        )
    
        write = Task(
            description=(
                "1. Use the content plan to craft a compelling blog post on {topic}.\n"
                "2. Incorporate SEO keywords naturally.\n"
                "3. Sections/Subtitles are properly named in an engaging manner.\n"
                "4. Ensure the post is structured with an engaging introduction, insightful body, and a summarizing conclusion.\n"
                "5. Proofread for grammatical errors and alignment with the brand's voice.\n"
            ),
            expected_output="A well-written blog post in markdown format, ready for publication, each section should have 2 or 3 paragraphs.",
            agent=writer,
        )
    
        edit = Task(
            description=("Proofread the given blog post for grammatical errors and alignment with the brand's voice."),
            expected_output="A well-written blog post in markdown format, ready for publication, each section should have 2 or 3 paragraphs.",
            agent=editor
        )

    Now we setup Agents & Tasks, next we need to run the crew and saw the magic

    crew = Crew(
            agents=[planner, writer, editor],
            tasks=[plan, write, edit],
            process=Process.sequential,
            verbose=True
        )
    result = crew.kickoff(inputs={"topic": "Artificial Intelligence"})
    print(result)

    Thats it, you did it.

    Here is some screenshot of output

    multi agent using crew ai, starting progress
    multi agent using crew ai, 2nd agent
    multi agent using crew ai end result

    Tags

    2026 ai tools aiagent Angular 21 Angular Developer for Hire Angular Performance Angular Signals Angular TypeScript Best Practices API Authentication API Development API Integration API Security API Versioning B2B SaaS Backend Development Backend Framework Comparison Best PHP Framework 2026 Best Practices Box Model CakePHP CakePHP 2026 CakePHP Laravel PHP Developer CakePHP Tutorial 2026 CakePHP vs Laravel Case Study Client Management crewai CRM Integration css css animation CSS Tips CSS Tutorial Database Optimization Developer Tools Enterprise Angular Development Express.js FastAPI Tutorial 2026 framework comparison Freelance Angular Developer Freelance Developer Freelance Development Freelance Laravel Developer Freelance PHP Developer Freelance Web Developer Freelance Web Development Freelancer vs Agency Freelancing Tips Front-End Development frontend Frontend Development Full Stack Developer Full Stack Developer Pakistan Full Stack Development Full-Stack Case Study Full-Stack Development Grid Hire a Developer Hire Angular Developer Hire Laravel Developer Inertia.js javascript JavaScript Frameworks JWT Authentication laravel Laravel 13 Laravel 2026 Laravel API 2026 Laravel Application Laravel Development Laravel Optimization Scale Laravel Performance Laravel REST API Laravel REST API Tutorial Laravel Sanctum Laravel Tutorial Laravel vs CakePHP Laravel Vue Tutorial multi-agent Next.js Node.js Node.js API Node.js Express Node.js Tutorial Nuxt PERN Stack PHP PHP Developer PHP Developer for Hire PHP Development PHP Framework PHP Framework Comparison PHP Performance PHP Web Development PostgreSQL Prisma Production Deployment Project Management Python Backend Developer Python FastAPI react React SPA React vs Vue Redis Caching Responsive Design REST API SaaS Development Sanctum SMB Web Development Software Development Software Integration SSG SSR Standalone Components System Integration TypeScript Strict Mode Vite vue Vue 4 Composition API Vue Laravel Developer Vue.js Development Web Design Web Design Fundamentals web development Web Development 2026 Web Development Cost Web Layout Web Projects

    Recent News