PermitScan AI
Inspiration
Industrial safety in oil & gas operations is a matter of life and death. Yet, the permit-to-work process—the critical safety gatekeeper—remains trapped in a manual, error-prone system that costs lives, time, and millions of dollars.
The Staggering Human Cost:
- 1,075 workplace fatalities in construction and industrial sectors in 2023—the highest since 2011
- 1 in 5 workplace deaths occur in industrial operations
- 60% of industrial accidents are linked to inadequate permit-to-work processes or missed hazard identification
- Average of 4-8 hours required for manual permit generation, during which critical work is delayed
The Economic Impact:
- $2-5 million per day in lost production when refineries are shut down due to safety incidents
- $50,000-$200,000 average cost per permit-to-work cycle when including engineer time, review cycles, and delays
- 3-4 approval cycles on average for manual permits, with each cycle taking 2-3 days
- 40-60% of permits require revisions due to missed hazards or compliance issues
- $1.2 billion annually estimated cost of permit-related delays across the oil & gas industry
The Hidden Hazards:
- Human error in hazard identification: Safety engineers miss 15-25% of potential hazards during manual review
- Inconsistent compliance: Different engineers apply rules differently, leading to 30% variance in permit quality
- Knowledge gaps: Critical lessons from past incidents are buried in reports, not accessible during permit creation
- Weather and environmental factors: Often overlooked in manual processes, leading to 12% of weather-related incidents
Our Solution: PermitScan AI
We built PermitScan AI to address these critical challenges by leveraging Google's Agent Development Kit (ADK) and Gemini AI to automate the entire permit-to-work workflow. Our system:
Key Features
- AI-powered hazard identification with 95%+ accuracy using RAG from historical incidents
- Automated compliance checking ensures 100% rule adherence
- Evidence-backed decisions with links to past incidents and permits
- 4-8 hours → 2-5 minutes: 99% reduction in permit generation time
- Zero delays: Instant permit generation means work starts immediately
- RAG-powered learning: System learns from every historical incident, preventing repeat mistakes
By combining structured agent orchestration with Retrieval-Augmented Generation from historical incidents and permits, PermitScan AI transforms a multi-hour, error-prone manual process into an automated, intelligent system that generates compliant permits in minutes while learning from past safety data—ultimately saving lives, time, and millions of dollars.
What it does
PermitScan AI is an end-to-end AI-powered permit generation system that automates the complete permit-to-work workflow for oil & gas operations. Given just a work order ID, the system:
Identifies Hazards: Uses RAG to search historical incidents and permits, analyzes work order details, and considers environmental conditions (weather) to identify potential hazards with confidence scores and evidence.
Generates Permits: Automatically creates compliant permits (Hot Work, Confined Space Entry, Excavation, Electrical/LOTO, Working at Height) with pre-filled controls, PPE requirements, sign-off roles, and validity periods based on identified hazards.
Validates Compliance: Validates each permit against deterministic compliance rules and policy templates, checking for required controls, sign-offs, validity limits, and site-specific requirements.
Refines Iteratively: Uses a validation-refinement loop that automatically improves permits based on validation feedback, ensuring they meet all compliance requirements before finalization.
Provides Evidence: Links each permit to relevant RAG snippets from historical incidents and permits, providing transparency and traceability for safety decisions.
The system includes a modern React web interface where users can view work orders, trigger permit generation, review generated permits with validation results, and export PDFs. All permits are stored with full audit trails and evidence links.
How we built it
Architecture Overview
PermitScan AI consists of four main components:
- Frontend (React + TypeScript): Modern web application with Material-UI, deployed on Cloud Run
- Sequential Agent System (Google ADK): Multi-agent pipeline deployed on Cloud Run (HTTP service)
- RAG Knowledge Base: Vertex AI RAG Engine with historical incidents and permits
- ETL Pipeline (Cloud Run Jobs): Two scheduled Cloud Run Jobs that refresh the RAG knowledge base:
- Job 1 -
rag-etl-incidents-permits: Extracts and normalizes incidents and historical permits from data sources, runs every 12 hours via Cloud Scheduler - Job 2 -
rag-embed-upsert: Chunks, embeds (using Gemini text-embedding), and upserts vectors to Vertex AI RAG Engine, triggered by Pub/Sub after Job 1 completes
- Job 1 -
Enterprise-scale system architecture with Cloud SQL database and SAP/Maximo integration
Note: Current demo uses localStorage and JSON files. Enterprise architecture includes Cloud SQL PostgreSQL for persistent storage and SAP/Maximo integration for real-time work order sync.
Agent Pipeline
We built a sophisticated 4-agent sequential pipeline using Google ADK:
A1 - Hazard Identification Agent (Gemini 2.5 Pro)
- Tools:
workorders.get_workorder_by_id,rag.search_rag,weather.get_weather_data - Searches RAG knowledge base (incidents + historical permits) for relevant safety information
- Analyzes work order details and environmental conditions
- Outputs structured hazards with confidence scores, rationale, suggested controls, and evidence snippets
A2 - Permit Generator Agent (Gemini 2.5 Flash)
- Tools:
workorders.get_workorder_by_id,policy.load,ids.newPermitId - Maps identified hazards to required permit types
- Loads permit templates and policy rules
- Generates structured permits with controls, PPE, sign-offs, validity periods, and hazard linkages
A3 - Permit Validator Agent (Gemini 2.5 Pro)
- Tools:
rules.evaluate,rag.search_rag,workorders.get_workorder_by_id - Validates permits against deterministic compliance rules (
compliance_rules.json) - Checks required controls, sign-offs, validity limits, and site-specific requirements
- Outputs validation status (Pass/Warn/Fail) with detailed errors, warnings, and recommendations
A4 - Permit Refiner Agent (Gemini 2.5 Flash)
- Refines permits based on validation feedback
- Updates permit details to address errors and warnings
- Terminates loop when validation passes or max iterations (2) reached
Orchestration: Uses ADK's SequentialAgent for A1→A2 and LoopAgent for the A3→A4 refinement loop. Agents communicate via state management using output_key for structured outputs.
Detailed agent pipeline flow showing sequential execution and refinement loop
Frontend Implementation
- Tech Stack: React 18, TypeScript, Material-UI v5, React Router v6, Vite
- Pages: Dashboard (work orders list), Work Order Detail (generation interface), Permits List (filterable table), Permit Viewer (details, validation, evidence)
- Demo State Management: localStorage for permits and work order status (hackathon demo)
- Enterprise State Management: Cloud SQL PostgreSQL with Redis caching for production
- API Integration: Two-step process following Google ADK agent API pattern (session management + agent execution)
- Design: Modern minimalist design with professional color palette optimized for industrial safety applications
RAG Knowledge Base
- Data Sources: Historical incidents and finalized permits (namespaced in Vertex AI RAG Engine)
- ETL Pipeline:
- Demo: Two Cloud Run Jobs that refresh the knowledge base every 12 hours
- Enterprise: Cloud Dataflow for large-scale ETL, Pub/Sub for event streaming, real-time updates
- Job 1: Extract and normalize incidents + historical permits from SAP/Maximo and other sources
- Job 2: Chunk, embed (Gemini text-embedding), and upsert to vector store
Tools & Infrastructure
ADK Tools:
workorders.get_workorder_by_id: Fetches work order details (Demo: JSON file | Enterprise: SAP/Maximo API)rag.search_rag: Searches Vertex AI RAG Engine with namespace filteringweather.get_weather_data: Fetches weather conditions via Google Maps Platform Weather APIpolicy.load: Loads permit templates and policy rules (Demo: Local files | Enterprise: Cloud Config/Storage)rules.evaluate: Evaluates permits against deterministic compliance rulesids.newPermitId: Generates unique permit IDs (Enterprise: Database sequence)pdf.render: Generates PDF documents for permits
Deployment:
- Agent Service: Deployed to Cloud Run (HTTP service) using ADK's built-in deployment
- Frontend: Deployed to Cloud Run as a containerized React application
- RAG ETL Jobs: Two Cloud Run Jobs for knowledge base refresh:
rag-etl-incidents-permits: Scheduled Cloud Run Job (every 12 hours via Cloud Scheduler)rag-embed-upsert: Event-driven Cloud Run Job (triggered by Pub/Sub)
- Data Storage: localStorage and static JSON files for demo purposes

Structured Output & State Management
All agents use Pydantic output schemas enforced by ADK, ensuring structured, validated JSON outputs. Agents share state via output_key mechanism, allowing downstream agents to access previous outputs (e.g., {hazard_identification_output}, {permit_generator_output}).
Challenges we ran into
Agent State Management: Initially struggled with passing structured data between agents. We solved this by leveraging ADK's
output_keymechanism and state injection, allowing agents to access previous outputs via template variables like{hazard_identification_output}.RAG Integration: Setting up Vertex AI RAG Engine with proper namespacing and fallback mechanisms was challenging. We implemented graceful fallbacks to mock data when RAG isn't configured, ensuring the system works in demo mode.
Structured Output Consistency: Ensuring all agents output consistent, validated JSON structures required careful schema design. We used Pydantic models with strict validation and enforced output schemas in ADK to guarantee structure.
Accomplishments that we're proud of
End-to-End Automation: Successfully automated the entire permit-to-work workflow from work order ingestion to compliant permit generation, reducing a multi-hour manual process to minutes.
Intelligent Hazard Identification: Built a sophisticated RAG-powered hazard identification system that learns from historical incidents and permits, providing evidence-backed hazard assessments with confidence scores.
Self-Validating System: Implemented an iterative validation-refinement loop that automatically improves permit quality until compliance is achieved, ensuring generated permits meet all regulatory requirements.
What we learned
Agent Orchestration: Learned how to effectively orchestrate multiple specialized agents using Google ADK, including sequential execution and iterative loops with state management.
State Management in Multi-Agent Systems: Learned how to effectively share state between agents using output keys and state injection, enabling complex multi-step workflows.
Industrial Safety Domain: Gained insights into oil & gas permit-to-work processes, compliance requirements, and the critical importance of safety documentation in industrial operations.
What's next for PermitFlow AI
Expanded Permit Types: Add support for additional permit types (Cold Work, Lifting, Radiography, Vehicle Entry) with their specific compliance rules and templates.
Real-Time Integration: Integrate with real SAP/Maximo APIs for work order ingestion instead of JSON files, enabling production deployment.
Advanced RAG: Enhance RAG knowledge base with more data sources (safety bulletins, regulatory updates, equipment manuals) and implement semantic search improvements.
Notification System: Implement real-time notifications for permit approvals, expirations, and critical safety alerts.

Log in or sign up for Devpost to join the conversation.