liveBook · Manning

Specialized agent

As explained in Build an AI Agent (From Scratch)

A specialized agent is an AI agent designed for domain-specific tasks that require substantial expertise or extended processing.

A specialized agent handles a focused task with its own instructions and capabilities. It may tackle domain-specific work that demands deep expertise or extended processing, such as coding or comprehensive research. In a multi-agent system, specialization also keeps each agent’s role, prompt, and tools narrow instead of burdening one agent with every responsibility. section 1.1 section 9.1

Design specialists around the work they must perform:

  • Give each agent a clear role and only the tools it needs. A research agent can search; a coding agent can execute code. section 9.1
  • Choose how they collaborate. A fixed workflow runs specialists in a predetermined order; an orchestrator can instead call agents as tools when the request calls for them. section 9.4
  • Keep the underlying agent interface consistent: each specialist remains an Agent with instructions, tools, and a run() method. section 9.0

Research and coding together

For a request to compare AI agent frameworks by GitHub stars, an orchestrator delegates information gathering to a web-search specialist and script writing and execution to a coding specialist. It then combines their results. The same arrangement can route a research-only or code-only request to just the needed specialist. section 9.4.4 section 9.4

Listing 9.9 Agent as Tool example: Researcher and coder
from scratch_agents import Agent, LlmClient
from scratch_agents.tools import AgentTool, search_web

llm = LlmClient(model="gpt-5")

# Research specialist: has web search tool
researcher = Agent(
    model=llm,
    name="researcher",
    description="Search the web and summarize findings on any topic",
    instructions="""You are a research specialist.
    Use web_search to find relevant information.
    Summarize your findings concisely.""",
    tools=[search_web],
)

# Coding specialist: has code execution capability
coder = Agent(
    model=llm,
    name="coder",
    description="Write and execute Python code for data analysis and visualization",
    instructions="""You are a Python expert.
    Write clean, working code.
    Execute code to verify results.""",
    code_execution="e2b",
)

The Python listing defines two specialists with distinct instructions and capabilities: web search for the researcher and code execution for the coder. section 9.4.4

# Orchestrator: utilizes specialists as tools
orchestrator = Agent(
    model=llm,
    name="coordinator",
    instructions="""You are a project coordinator.
    Analyze user requests and delegate to appropriate specialists:
    - Use 'researcher' for information gathering
    - Use 'coder' for data analysis and visualization
    Combine their results to fulfill the user's request.""",
    tools=[
        AgentTool(researcher),
        AgentTool(coder),
    ],
)

The orchestrator registers both specialists through AgentTool so it can delegate work and combine their results. section 9.4.4

How Build an AI Agent (From Scratch) covers it

How deep it goes
Shows Python specialist definitions and AgentTool registration, while describing asynchronous domain agents without implementing their execution model.
Examples
Uses research and coding specialists to compare AI agent frameworks by GitHub stars.
What it assumes
Builds on an Agent class, tool system, and ExecutionContext already established before specialist collaboration.
What you can do after
Apply it via AgentTool to register focused agents and let an orchestrator delegate requests to them.
How it connects
Connects specialization to multi-agent orchestration, tool selection, workflows, and code execution.

Also explained in

Compare how 3 books explain specialized agent →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build an AI Agent (From Scratch). The section links point to the parts of the book it draws on.