AER Industrial Compliance Agent
Autonomous AI agent for AER industrial compliance — 7-tool LangChain orchestration over real Alberta Energy Regulator directives. Replaces a 2-hour manual audit with a 30-second autonomous workflow.
View on GitHubOverview
Traditional RAG systems answer questions. This agent performs work. The shift from passive knowledge retrieval to active operational execution is what makes this genuinely useful in an industrial compliance context.
A compliance officer doesn't just need answers about AER directives — they need the audit done, the report sent, the follow-up scheduled, and the maintenance logged. That's what this agent does: it receives a plain-English instruction and autonomously orchestrates 7 tools to complete the full workflow.
RAG vs. Autonomous Agent
| Aspect | Traditional RAG | Autonomous Agent |
|---|---|---|
| Role | Passive Q&A | Active task execution |
| User input | "Tell me about X" | "Audit X and handle it" |
| Tools | 1 — vector search | 7+ — search, DB, email, calendar, logs |
| Decision making | User-driven | AI-driven, autonomous |
| Actions taken | None — just responds | Email, schedule, log, report |
Agent Architecture
The agent receives a goal, reasons about it using GPT-4o function calling, selects tools, processes results, and iterates until the goal is achieved. No hardcoded decision trees.
class AERComplianceAgent:
def __init__(self, api_key: str, model: str = "gpt-4o"):
self.llm = ChatOpenAI(
model=model,
temperature=0, # Deterministic — critical for compliance
api_key=api_key
)
self.agent = create_tool_calling_agent(
self.llm,
audit_tools, # 7 available tools
self.prompt # Custom system prompt for AER context
)
self.agent_executor = AgentExecutor(
agent=self.agent,
tools=audit_tools,
verbose=True, # Full tool call transparency
max_iterations=15, # Cost cap — prevents runaway execution
handle_parsing_errors=True
)7 Available Tools
End-to-End Workflow
Instruction
"Audit facility FAC-AB-001 for Directive 017 compliance and email results to safety@example.com"
Complete compliance audit in under 30 seconds with 6 tool invocations. Zero manual intervention.
Results
| Metric | Manual | With Agent |
|---|---|---|
| Complete audit time | 2+ hours | < 30 seconds |
| Manual steps | 10–15 steps | 0 — fully autonomous |
| Report generation | Manual compilation | Auto-generated and emailed |
| Follow-up scheduling | Manual calendar entry | Automatic with confirmation ID |
| Consistency | Varies by analyst | Deterministic execution |
Engineering Learnings
Function calling is the unlock for agents
The agent makes autonomous decisions about tool sequencing. This is fundamentally different from hard-coded logic or simple RAG retrieval, and the difference is not subtle in practice.
Tool descriptions are the interface
Clear, detailed docstrings directly determine agent performance. The LLM reads these descriptions to decide which tool to invoke — ambiguous descriptions cause wrong selection more reliably than any other failure mode.
Temperature 0 is mandatory for compliance
Regulatory domains require deterministic behaviour. Temperature 0 ensures consistent tool selection and prevents creative but incorrect responses.
Pydantic schemas prevent silent failures
When LLMs generate function inputs, validation catches errors before execution. Silent failures in compliance workflows are unacceptable.
Stack & Quick Start
git clone https://github.com/morteza-mogharrab/aer-compliance-agent.git
cd aer-compliance-agent
python3 -m venv venv && source venv/bin/activate
pip install -r requirements_agent.txt
export OPENAI_API_KEY='your-key-here'
python3 agent_app.py # Web interface → localhost:7860