AWS Logo
Menu
Build Your Factory Assistant with Amazon Bedrock and OPC UA

Build Your Factory Assistant with Amazon Bedrock and OPC UA

Get your own factory assistant for managing industrial machines

Sounavo Dey
Amazon Employee
Published Mar 21, 2025
Manufacturers today face a critical challenge: the loss of tribal knowledge due to an aging workforce. According to Deloitte, over one-third of manufacturing workers are over 55, and by 2030, unfilled manufacturing positions could exceed 2 million. This "brain drain" results in operational inefficiencies and skill shortages, as experienced workers retire without formally documenting their expertise.
To bridge this gap, manufacturers are turning to Generative AI (GenAI). Over 55% of manufacturers are already leveraging GenAI tools, and more than 40% plan to increase their AI investments over the next three years. AI-powered solutions can capture and preserve tribal knowledge, transforming undocumented expertise into machine-readable formats that enhance training, troubleshooting, and process optimization.
A key enabler of this transformation is OPC UA companion specifications. These specifications provide standardized information models for manufacturing equipment and processes, making machine knowledge more structured and accessible. By integrating Amazon Bedrock with OPC UA companion specifications, manufacturers can build multi-agent applications that assist Operational Technology (OT) workers in daily functions, reducing downtime and increasing efficiency.
Amazon Bedrock is a fully managed service that makes Foundation Models (FMs) from leading AI startups and Amazon available through an API, so you can choose from a wide range of FMs to find the model that is best suited for your use case. Amazon Bedrock offers a serverless experience, so you can get started quickly, privately customize FMs with your own data, and integrate and deploy them into your applications using AWS tools without having to manage any infrastructure.
Solution Overview
This blog explores how to build an agentic workflow using Amazon Bedrock and LangChain that utilizes OPC UA companion specifications and machine information as a knowledge base. A Companion Specification is the specification of a domain-specific Information Model based on OPC UA. Typically, a Companion Specification is defined in a working group of the OPC Foundation or a joint working group of the OPC Foundation with other organizations like the VDMA. The OPC UA NodeSet includes the complete Information Model defined in this standard. It follows the XML Information Model schema syntax. Some common examples of OPC UA comapanion specs are Euromap for extrusion machines , PackML for packaging lines etc. In this solution we will simulate the working of a extrusion machine . The llm models will use OPC UA companion specs and nodeset as knowledge base to build the tribal knowledge of the system. It would use tools like knowledge query and data query to answer questions on ‘production efficiency’ and ‘material handling’ of the extrusion machine to guide the operator. Lets look agentic workflow experience compared to the traditional experience.
Mike has been running extrusion lines for 25 years. He starts his shift by checking the line visually and listening to the extruder's sound. "Something doesn't sound right," he mutters, adjusting the screw speed based on his experience. When asked how he knows the optimal settings, he responds, "You just know after a while." He keeps a worn notebook with handwritten notes about different material combinations and their quirks. When quality issues arise, Mike can often fix them by making subtle adjustments based on the material flow's appearance and the feel of the product. His knowledge is invaluable but exists only in his head and personal notes.
Jane operates the modern extrusion line using a standardized interface. She connects to an AWS GenAI assistant that is connected to the extrusion machine data in realtime. She can ask for efficiency data and the assistant will translate efficiency to the Production Parameters interface (from Euromap 84 OPC UA companion specifications) like Throughput in kg/h, Product Weight in g/m, and Line Speed in m/s. It will compute these values and summarize the efficiency to respond back to Jane. When she starts a new job, she requests the AI assistance to create a job. The assistance uses the JobGroupType interface to access standardised production datasets, ensuring consistent setup. The system continuously monitors quality through the GoodProduct indicator and CycleQuality parameters.
For material changes, Jane doesn't rely on memory or notes - she requests the assistance to check the material change process. The assistant looks up the relevant data for the MaterialList with standardized MaterialMapping, ensuring precise material change instructions every time. Energy efficiency is tracked automatically through ElectricalEnergy, FluidEnergy, and PressureAir consumption metrics. When quality issues occur, the system provides standardized data points for troubleshooting, and all solutions are documented in the system for future reference.
To build such a system as used by Jane, we will guide you through:
  1. Creating a Knowledge Base for OPC UA Companion Specifications
  2. Building the Multi-Agent Application.
  3. Demonstrating an OT Worker Assistant in Action
Each stage will include code examples to help you implement the solution in your own environment.

Step 1: Creating a Knowledge Base for OPC UA Companion Specifications
A robust knowledge base is essential for an AI-driven OT assistant. Amazon Bedrock supports creation of knowledge bases from structured and well as unstructured data. We achieve this by ingesting OPC UA companion spec documents and extracting OPC UA nodeset data.
Ingesting OPC UA Companion Spec PDF Documents
Companion specs are available from OPC UA foundation as pdf specifications. To make OPC UA specifications accessible, we need to extract and structure data from PDFs. PyPDFLoader is document loader for PDF files that is available from langchain community. The following code demonstrates how to load and split PDF documents efficiently:
In this code we load and process all PDF files within a specified directory using PyPDFLoader from LangChain to extract text from each document. To ensure manageable text processing, the extracted content is split into chunks of up to 20,000 characters with a 100-character overlap using CharacterTextSplitter. This overlap helps preserve context between chunks, which is particularly useful for language models that analyze text sequentially.
Parsing OPC UA Nodeset Data with Custom Chunking Strategy
Ingesting the OPC UA node set file however is trickier though. OPC UA nodeset XML files contain structured metadata about machines and processes. These files can be quite large and complex, requiring a custom chunking strategy for effective ingestion and retrieval. The available community parsers split the documents in a such a way that the chunks retuned by the LLMs are random text and do not provide any semantic structure. To handle OPC UA nodesets efficiently we wrote a specialised document splitter and loader that returns xml chunks with semantic structure. We will later show an example of the chunks returned by the LLMs.
The following code processes nodeset XML files efficiently:
The OpcUaNodeSetSplitter, is designed to process large XML-based OPC UA NodeSet files by splitting them into manageable chunks. The class takes a max_chunk_size parameter (defaulting to 2000 characters) to ensure that no individual chunk exceeds a specified length. The _split_element method is responsible for breaking down an XML element into smaller parts while preserving its structure. It iterates through child elements, converting each to a string and tracking their combined size. If adding a new child would exceed the chunk size limit, the accumulated content is wrapped in a <UANodeSet> tag, stored as a Document object (with metadata), and a new chunk is started. This approach ensures that large XML files can be processed efficiently while maintaining the integrity of each chunk, making it particularly useful for OPC UA schema processing.
Step 2: Building the Multi-Agent Application
With a knowledge base in place, we construct an agentic application that enables supervisory intelligence over OT operations.
Supervisor Model for Orchestration
A supervisor model coordinates multiple agents to provide coherent and contextual responses. The supervisor routes tasks to different agents based on the user query and ensures a smooth workflow. For this solution we have build three agents
Agent Roles
  • Retrieve Agent: Gathers information from the vector store.
  • Query Agent: Extracts node IDs and retrieves real-time/historical machine data.
  • Summary Agent: Enhances responses with insights and final summaries.
The supervisor ensures that tasks flow logically between these agents, optimizing responses for OT workers. The architecture of supervisor looks like this:
Lets understand the role of each agent in more details:
Retrieve Agent: The retrieve agent is a RAG tool that looks up the vector store that was created on the OPC UA specification and node set model. The retriever return relevant chucks from from both the pdfs and the companion specs. Examples of a chuck returned is:
Note how the chucks from the nodeset files are now sematically valid xml files due the custom chunking stategy that we used before.
Query Agent: The query uses a set of tools to extract the NodeIds from the RAG response , formulate a SQL and make a query to the database. For purpose of the demo we have created a dummy historian of a data simulating and extrusion machine. For production environment you can update the tool to point to your historian database.
Summary Agent: Summarises previous responses

Step 3: Demonstrating the OT Worker Assistant in Action
Once built, our agentic application can assist OT workers in real-world scenarios, such as:
  • Troubleshooting machine errors by referencing OPC UA specifications.
  • Guiding new workers through standardized procedures.
  • Optimizing production settings based on historical performance.
Example Interaction:
Agent Interation
Agent Interation
Agent Interation
Agent Interation

Conclusion
By leveraging Amazon Bedrock, LangChain, and OPC UA companion specifications, manufacturers can create intelligent, agentic applications that assist OT workers in their daily operations. With a structured knowledge base and a well-orchestrated multi-agent system, factories can optimize operations, improve worker productivity, and future-proof their workforce. The full codebase coming soon. Watch this space.
Author bio:
Sounavo is senior product architect focused in helping manufacturers as they transform to Industry 4.0. He helps drive technology innovations helping manufacturers plan future success, deliver solution and systematically transform and ensure incremental business value along the journey.
He has wide experience in Industrial IoT and Cloud adoption.

Any opinions in this post are those of the individual author and may not reflect the opinions of AWS.

Comments