Skip to content

OSSS.ai.orchestration.adapter

OSSS.ai.orchestration.adapter

LangGraph Node Adapter for OSSS agents.

This module provides the LangGraphNodeAdapter class which serves as a bridge between OSSS agents and LangGraph's execution model, enabling seamless conversion of agents into LangGraph-compatible nodes.

NodeExecutionResult

Bases: BaseModel

Result of a node execution with metadata.

Migrated from dataclass to Pydantic BaseModel for enhanced validation, serialization, and integration with the OSSS Pydantic ecosystem.

ExecutionNodeConfiguration

Bases: BaseModel

Configuration for node execution.

Migrated from dataclass to Pydantic BaseModel for enhanced validation, serialization, and integration with the OSSS Pydantic ecosystem.

LangGraphNodeAdapter

Bases: ABC

Abstract base adapter for converting OSSS agents into LangGraph nodes.

This adapter provides the interface and utilities needed to execute OSSS agents within a LangGraph DAG context, handling state transitions, error propagation, and execution metadata.

node_definition property

Get the LangGraph node definition for this adapter.

average_execution_time_ms property

Get average execution time in milliseconds.

success_rate property

Get success rate as a percentage (0-100).

__init__(agent, node_id=None)

Initialize the node adapter.

Parameters

agent : BaseAgent The OSSS agent to adapt node_id : str, optional Custom node ID (defaults to agent name)

__call__(state, config=None) async

Execute the node with the given state and configuration.

This is the main LangGraph-compatible interface.

Parameters

state : AgentContext Current graph state config : ExecutionNodeConfiguration, optional Node execution configuration

Returns

AgentContext Updated state after node execution

execute(state, config=None) async

Execute the adapted agent and return detailed results.

Parameters

state : AgentContext Current execution state config : ExecutionNodeConfiguration, optional Execution configuration

Returns

NodeExecutionResult Detailed execution result with metadata

get_statistics()

Get comprehensive execution statistics for this node.

StandardNodeAdapter

Bases: LangGraphNodeAdapter

Standard implementation of LangGraphNodeAdapter for typical agent conversions.

This provides a complete, ready-to-use adapter for most OSSS agents without requiring custom implementations.

__init__(agent, node_id=None, enable_state_validation=True, enable_rollback=True)

Initialize the standard node adapter.

Parameters

agent : BaseAgent The agent to adapt node_id : str, optional Custom node ID enable_state_validation : bool Whether to validate state transitions enable_rollback : bool Whether to enable automatic rollback on failure

ConditionalNodeAdapter

Bases: LangGraphNodeAdapter

Node adapter with conditional routing capabilities.

This adapter can determine the next node(s) to execute based on the agent's output and custom routing logic.

__init__(agent, routing_function, node_id=None)

Initialize the conditional node adapter.

Parameters

agent : BaseAgent The agent to adapt routing_function : Callable[[AgentContext], List[str]] Function that returns list of next node IDs based on context node_id : str, optional Custom node ID

create_node_adapter(agent, adapter_type='standard', **kwargs)

Factory function to create appropriate node adapter for an agent.

Parameters

agent : BaseAgent The agent to adapt adapter_type : str Type of adapter ("standard", "conditional") **kwargs Additional arguments for adapter initialization

Returns

LangGraphNodeAdapter Configured node adapter