Agent Spec Adapters#

Using adapters is the recommended way of integrating an agentic framework runtime. Ideally, an adapter should programmatically translate the representation of the Agent Spec components into the equivalent solution, as per each framework’s definition, and return an object that developers can run.

This page presents all APIs and classes related to Agent Spec Adapters.

LangGraph#

class pyagentspec.adapters.langgraph.AgentSpecExporter#

Bases: object

Helper class to convert LangGraph objects into Agent Spec configuration.

to_component(langgraph_component)#

Transform the given LangGraph component into the respective PyAgentSpec Component.

Parameters:

langgraph_component (StateGraph[Any, Any, Any] | CompiledStateGraph[Any, Any, Any]) – LangGraph Component to serialize to a corresponding PyAgentSpec Component.

Return type:

Component

to_json(langgraph_component)#

Transform the given LangGraph component into the respective AgentSpec JSON representation

Parameters:

langgraph_component (StateGraph[Any, Any, Any] | CompiledStateGraph[Any, Any, Any]) – LangGraph Component to serialize to an AgentSpec configuration

Return type:

str

to_yaml(langgraph_component)#

Transform the given LangGraph component into the respective AgentSpec YAML representation

Parameters:

langgraph_component (StateGraph[Any, Any, Any] | CompiledStateGraph[Any, Any, Any]) – LangGraph Component to serialize to an AgentSpec configuration

Return type:

str

class pyagentspec.adapters.langgraph.AgentSpecLoader(tool_registry=None, plugins=None, checkpointer=None, config=None)#

Bases: object

Helper class to convert Agent Spec configuration into LangGraph objects.

Parameters:
  • tool_registry (Dict[str, Any] | None) –

  • plugins (List[ComponentDeserializationPlugin] | None) –

  • checkpointer (None | bool | BaseCheckpointSaver) –

  • config (RunnableConfig | None) –

load_component(agentspec_component)#

Transform the given PyAgentSpec Component into the respective LangGraph Component

Parameters:

agentspec_component (Component) – PyAgentSpec Component to be converted to a LangGraph Component.

Return type:

CompiledStateGraph[Any, Any, Any]

load_json(serialized_assistant)#

Transform the given Agent Spec JSON representation into the respective LangGraph Component

Parameters:

serialized_assistant (str) – Serialized Agent Spec configuration to be converted to a LangGraph Component.

Return type:

CompiledStateGraph[Any, Any, Any]

load_yaml(serialized_assistant)#

Transform the given Agent Spec YAML representation into the respective LangGraph Component

Parameters:

serialized_assistant (str) – SerializedAgent Spec configuration to be converted to a LangGraph Component.

Return type:

CompiledStateGraph[Any, Any, Any]

AutoGen#

class pyagentspec.adapters.autogen.AgentSpecExporter#

Bases: object

Helper class to convert AutoGen objects to Agent Spec configurations.

to_component(autogen_component)#

Transform the given AutoGen component into the respective PyAgentSpec Component.

Parameters:

autogen_component (Component) – AutoGen Component to transform into a corresponding PyAgentSpec Component.

Returns:

The PyAgentSpec Component corresponding to the AutoGen component.

Return type:

Component

Raises:

TypeError – If the input is not an AutoGen Component.

to_json(autogen_component)#

Transform the given AutoGen component into the respective Agent Spec JSON representation.

Parameters:

autogen_component (Component) – AutoGen Component to serialize to an Agent Spec configuration.

Returns:

The Agent Spec JSON representation of the AutoGen component.

Return type:

str

to_yaml(autogen_component)#

Transform the given AutoGen component into the respective Agent Spec YAML representation.

Parameters:

autogen_component (Component) – AutoGen Component to serialize to an Agent Spec configuration.

Returns:

The Agent Spec YAML representation of the AutoGen component.

Return type:

str

class pyagentspec.adapters.autogen.AgentSpecLoader(tool_registry=None, plugins=None)#

Bases: object

Helper class to convert Agent Spec configurations to AutoGen objects.

Parameters:
load_component(agentspec_component)#

Transform the given PyAgentSpec Component into the respective AutoGen Component

Parameters:

agentspec_component (Component) – PyAgentSpec Component to be converted to an AutoGen Component.

Return type:

AssistantAgent

load_json(serialized_assistant)#

Transform the given Agent Spec JSON representation into the respective AutoGen Component

Parameters:

serialized_assistant (str) – Serialized Agent Spec configuration to be converted to an AutoGen Component.

Return type:

AssistantAgent

load_yaml(serialized_assistant)#

Transform the given Agent Spec YAML representation into the respective AutoGen Component

Parameters:

serialized_assistant (str) – Serialized Agent Spec configuration to be converted to an AutoGen Component.

Return type:

AssistantAgent