Components#

This page presents all APIs and classes related to Components in PyAgentSpec.

Component class#

class pyagentspec.component.Component(*, id=<factory>, name, description=None, metadata=<factory>, min_agentspec_version=AgentSpecVersionEnum.v25_4_1, max_agentspec_version=AgentSpecVersionEnum.v25_4_1)#

Bases: AbstractableModel

Base class for all components that can be used in Agent Spec.

In Agent Spec, there are components to represent Agents, Flows, LLMs, etc.

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) –

classmethod build_from_partial_config(partial_config)#

Build the component without running any validation.

Parameters:

partial_config (Dict[str, Any]) – A dictionary containing an incomplete configuration that should be used to build this Component

Return type:

The constructed component

property component_type: str#

Return the name of this Component’s type.

static get_class_from_name(class_name)#

Given the class name of a component, return the respective class.

Parameters:

class_name (str) – The name of the component’s class to retrieve

Return type:

The component’s class

classmethod get_validation_errors(partial_config)#

Return a list of validation errors for this Component.

Parameters:

partial_config (Dict[str, Any]) – The partial configuration of the Component.

Returns:

  • The list of validation errors for this Component. If the returned list is empty, the

  • component can be constructed without any additional validation.

Return type:

List[PyAgentSpecErrorDetails]

property model_fields_set: set[str]#

Returns the set of fields that have been explicitly set on this model instance, except the min_agentspec_version which is manually specified.

classmethod model_json_schema(by_alias=True, ref_template='#/$defs/{model}', schema_generator=<class 'pydantic.json_schema.GenerateJsonSchema'>, mode='validation', only_core_components=False)#

Build the json schema for Agent Spec Components.

Note that arguments of the method are ignored.

Parameters:
  • by_alias (bool) – Whether to use attribute aliases or not.

  • ref_template (str) – The reference template.

  • schema_generator (type[pydantic.json_schema.GenerateJsonSchema]) – To override the logic used to generate the JSON schema, as a subclass of GenerateJsonSchema with your desired modifications

  • mode (Literal['validation', 'serialization']) – The mode in which to generate the schema.

  • only_core_components (bool) – Generate the schema containing only core Agent Spec components as per language specification

Return type:

The json schema specification for the chosen Agent Spec Component

serialize_model(info)#

Serialize a Pydantic Component.

Is invoked upon a model_dump call.

Parameters:

info (SerializationInfo) –

ComponentWithIO class#

class pyagentspec.component.ComponentWithIO(*, id=<factory>, name, description=None, metadata=<factory>, min_agentspec_version=AgentSpecVersionEnum.v25_4_1, max_agentspec_version=AgentSpecVersionEnum.v25_4_1, inputs=None, outputs=None)#

Bases: Component

Base class for all components that have input and output schemas.

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

inputs: List[Property] | None#

List of inputs accepted by this component

outputs: List[Property] | None#

List of outputs exposed by this component

AgenticComponent class#

class pyagentspec.agenticcomponent.AgenticComponent(*, id=<factory>, name, description=None, metadata=<factory>, min_agentspec_version=AgentSpecVersionEnum.v25_4_1, max_agentspec_version=AgentSpecVersionEnum.v25_4_1, inputs=None, outputs=None)#

Bases: ComponentWithIO

Represents a component that can be interacted with, asking questions and getting answers from it.

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