Get startedGet started for free

Divide and Conquer: Creating Specialist Agents

You're helping your younger sister apply to computer science programs. It's a lot to manage: researching schools, comparing programs, and writing strong essays.

To make the process easier, you decide to build two specialized agents:

  • One to research universities and their requirements
  • One to help write compelling application essays

You have access to the CodeAgent and WebSearchTool classes, as well as a pre-configured model.

This exercise is part of the course

AI Agents with Hugging Face smolagents

View Course

Exercise instructions

  • In the first agent, set the tools parameter to include the WebSearchTool.
  • Still in the first agent, provide a name string to identify it as the school research agent.
  • In the second agent, set the model parameter to use the provided model variable.
  • Finally, complete the second agent's description to summarize its purpose.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# School research specialist
school_agent = CodeAgent(
    # Assign a list of tools the agent can use
    ____=[WebSearchTool()],
    model=model,
    # Set the agent's unique name identifier
    ____="school_research_agent",
    description="Expert in researching universities, programs, and admission requirements"
)

# Essay writing specialist  
essay_agent = CodeAgent(
    tools=[WebSearchTool()],
    # Provide the model used to generate responses
    ____=model,
    name="essay_writing_agent",
    # Write a short description of the agent's area of expertise
    ____="Expert in crafting compelling college application essays and personal statements"
)
Edit and Run Code