Building Your First Manufacturing AI Agent: A Step-by-Step Guide with Google ADK
Theory is valuable, but manufacturing leaders want to see how it works in practice. This guide walks you through building a functional predictive maintenance agent using Google ADK, from initial setup to a working prototype that monitors equipment health and takes autonomous action.
Prerequisites
- Python 3.11 or higher
- Google ADK installed (pip install google-adk)
- Access to equipment sensor data (OPC-UA, MQTT, or API)
- An LLM API key (Gemini, GPT-4o, or Claude)
- A vector database for knowledge storage (ChromaDB for prototyping)
Step 1: Define the Agent's Mission
Before writing code, clearly define what the agent will do:
Mission: Monitor the health of Pump P-101 and take autonomous maintenance actions to prevent unplanned downtime.
Scope: - Monitor: vibration, temperature, pressure, and motor current - Detect: anomalies indicating developing failures - Diagnose: identify probable root cause using equipment knowledge base - Act: create work orders, adjust operating parameters, notify maintenance team
Constraints: - Cannot exceed equipment operating limits defined in the manual - Must log all decisions with full reasoning chain - Must escalate to human when confidence is below 80%
Step 2: Build the Tools
Tools are how the agent interacts with the physical and digital world. For our maintenance agent, we need five tools:
Tool 1: Read Sensor Data
Connects to the OPC-UA server and reads current sensor values for Pump P-101. Returns vibration (mm/s), temperature (C), discharge pressure (bar), and motor current (A).
Tool 2: Query Maintenance History
Queries the CMMS API for maintenance history on Pump P-101. Returns work orders, repairs, and part replacements from the past 12 months.
Tool 3: Search Knowledge Base
Searches the vector database (ChromaDB) containing pump manuals, troubleshooting guides, and past failure analysis reports. Uses semantic search to find relevant information.
Tool 4: Create Work Order
Creates a new work order in the CMMS with diagnosis, recommended procedure, required parts, and priority level.
Tool 5: Adjust Operating Parameters
Writes new setpoints to the OPC-UA server for Pump P-101. Includes safety validation to ensure parameters stay within equipment limits.
Step 3: Configure the Agent
The agent is configured with:
Model: Gemini 2.5 Pro (for its large context window and multi-modal capabilities)
Instructions: A detailed system prompt that defines the agent as a senior reliability engineer specializing in centrifugal pump maintenance. The prompt includes diagnostic procedures, safety constraints, and escalation rules.
Tools: All five tools registered with the agent
Sub-agents: None for this initial version (single agent architecture)
Step 4: Add the Knowledge Base
Index the following documents into ChromaDB:
- Pump P-101 installation and operation manual (PDF, 450 pages)
- Bearing specifications for SKF 6310 and 6312
- Mechanical seal specification and maintenance guide
- Past failure analysis reports for Pump P-101 and similar pumps
- Standard maintenance procedures for centrifugal pumps
- Vibration analysis interpretation guides
Use a chunking strategy that respects document structure: chapters, sections, and procedures are kept intact rather than split at arbitrary character counts.
Step 5: Create the Monitoring Loop
The agent runs in a continuous monitoring loop:
- Every 30 seconds: read sensor data
- Compare current values against baselines and thresholds
- If anomaly detected: trigger full diagnostic sequence
- Execute any required actions
- Log all observations and decisions
Step 6: Test with Historical Data
Before connecting to live equipment, replay historical scenarios:
- Feed the agent sensor data from a known bearing failure (3 weeks of data compressed into minutes)
- Verify the agent detects the anomaly at the right time
- Verify the diagnosis matches the actual root cause
- Verify the proposed actions are appropriate
- Check that safety constraints are respected
Run at least 10 historical scenarios covering different failure modes.
Step 7: Deploy in Advisory Mode
Connect to live sensor data but disable write tools (work order creation and parameter adjustment). The agent observes and recommends but does not act. This builds trust and validates performance on live data.
Run in advisory mode for 2-4 weeks. Track: - How many recommendations were correct - How many were actioned by human operators - Response time vs manual detection - False positive rate
Step 8: Enable Autonomous Action
Once advisory performance is validated (target: 85%+ recommendation accuracy), enable write tools with appropriate guardrails:
- Parameter adjustments limited to +/- 10% of current values
- Work order creation requires human approval for first 30 days
- All actions logged with full reasoning chain
- Kill switch accessible from operator HMI
Step 9: Monitor and Improve
Use LangSmith or equivalent observability platform to:
- Track prediction accuracy over time
- Identify failure modes the agent misses
- Optimize prompts based on real-world performance
- Update the knowledge base with new failure experiences
Common Pitfalls
- Skipping advisory mode -- Always validate before enabling autonomous action
- Insufficient knowledge base -- The agent is only as good as its reference materials
- Ignoring false positives -- High false positive rates destroy operator trust
- Over-engineering the first agent -- Start simple, add complexity based on real needs
- Not measuring baseline -- You cannot prove improvement without a baseline
From Prototype to Production
This single-agent prototype is the foundation. From here, expand to: - Multiple equipment assets (deploy the pattern across all pumps) - Multi-agent crew (add scheduling, parts management, and quality agents) - Cross-system integration (connect to ERP, MES, and supply chain) - Plant-wide orchestration (agent crews across all production areas)
Frequently Asked Questions
Related Solutions
Cut breakdowns using structured PM, work orders, and reliability KPIs.
Connect PLCs, sensors, and enterprise systems into a unified data architecture.
Improve OEE/OLE and delivery with real-time control + smart scheduling.