Agent Specialization#

This page presents all APIs and classes related to Agent Specialization in PyAgentSpec

Specialized Agent#

class pyagentspec.specialized_agent.SpecializedAgent(*, id=<factory>, name, description=None, metadata=<factory>, min_agentspec_version=AgentSpecVersionEnum.v25_4_2, max_agentspec_version=AgentSpecVersionEnum.v25_4_2, inputs=None, outputs=None, agent, agent_specialization_parameters)#

Bases: AgenticComponent

A specialized agent is an agent that uses an existing generic agent and specializes it to solve a given task.

It can be executed anywhere an Agent can be executed.

Examples

>>> from pyagentspec.agent import Agent
>>> from pyagentspec.property import StringProperty
>>> from pyagentspec.specialized_agent import AgentSpecializationParameters, SpecializedAgent
>>> from pyagentspec.tools import ServerTool
>>> expertise_property = StringProperty(title="domain_of_expertise")
>>> system_prompt = '''You are an expert in {{domain_of_expertise}}.
... Please help the users with their requests.'''
>>> agent = Agent(
...     name="Adaptive expert agent",
...     system_prompt=system_prompt,
...     llm_config=llm_config,
...     inputs=[expertise_property],
... )
>>> websearch_tool = ServerTool(
...     name="websearch_tool",
...     description="Search the web for information",
...     inputs=[StringProperty(title="query")],
...     outputs=[StringProperty(title="search_result")],
... )
>>> agent_specialization_parameters = AgentSpecializationParameters(
...     name="essay_agent",
...     additional_instructions="Your goal is to help the user write an essay around the domain of expertise.",
...     additional_tools=[websearch_tool]
... )
Parameters:
  • id (str) – A unique identifier for this Component

  • name (str) – Name of this Component

  • description (str | None) – Optional description of this Component

  • metadata (Dict[str, Any] | None) – Optional, additional metadata related to this Component

  • min_agentspec_version (AgentSpecVersionEnum) –

  • max_agentspec_version (AgentSpecVersionEnum) –

  • inputs (List[Property] | None) – List of inputs accepted by this component

  • outputs (List[Property] | None) – List of outputs exposed by this component

  • agent (Agent) – Agent to be specialized

  • agent_specialization_parameters (AgentSpecializationParameters) – Parameters used to specialize the agent

class pyagentspec.specialized_agent.AgentSpecializationParameters(*, id=<factory>, name, description=None, metadata=<factory>, min_agentspec_version=AgentSpecVersionEnum.v25_4_2, max_agentspec_version=AgentSpecVersionEnum.v25_4_2, inputs=None, outputs=None, additional_instructions=None, additional_tools=None, human_in_the_loop=None)#

Bases: ComponentWithIO

Parameters used to specialize an agent for a certain goal or task.

Parameters:
  • id (str) – A unique identifier for this Component

  • name (str) – Name of this Component

  • description (str | None) – Optional description of this Component

  • metadata (Dict[str, Any] | None) – Optional, additional metadata related to this Component

  • min_agentspec_version (AgentSpecVersionEnum) –

  • max_agentspec_version (AgentSpecVersionEnum) –

  • inputs (List[Property] | None) – List of inputs accepted by this component

  • outputs (List[Property] | None) – List of outputs exposed by this component

  • additional_instructions (str | None) – Additional instructions that will be merged with the generic agent’s system prompt.

  • additional_tools (List[Tool] | None) – Additional tool set that will extend the generic agent’s tools.

  • human_in_the_loop (bool | None) – Overwrites the generic agent’s human_in_the_loop behaviour, if not None.

additional_instructions: str | None#

Additional instructions that will be merged with the generic agent’s system prompt.

additional_tools: List[Tool] | None#

Additional tool set that will extend the generic agent’s tools.

human_in_the_loop: bool | None#

Overwrites the generic agent’s human_in_the_loop behaviour, if not None.