Agents Overview
AEGIS ships four specialized AI agents, each focused on a specific area of Texas oil and gas regulatory compliance. Agent configurations are defined as YAML files in the agents/ directory and loaded into the database by the skill registry seed script.
Agent Summary
| Agent | ID | Type | Skills | HITL Checkpoints | Budget (tokens) | Budget (USD) |
|---|---|---|---|---|---|---|
| Rule 37 Spacing | rule37-agent | rule_37 | 4 | pre_filing, good_cause_review | 150k/exec, 2M/day | $10/exec, $100/day |
| Rule 32 Flaring | rule32-agent | rule_32 | 4 | pre_filing, emissions_review | 150k/exec, 2M/day | $10/exec, $100/day |
| Compliance Monitor | compliance-monitor-agent | compliance_monitor | 2 | compliance_alert (optional) | 50k/exec, 500k/day | $3/exec, $30/day |
| Flaring Monitor | flaring-monitor-agent | flaring_monitor | 2 | compliance_alert (optional) | 50k/exec, 500k/day | $3/exec, $30/day |
All agents use gpt-4o as the primary model with gpt-4o-mini as the fallback.
Filing Agents vs. Monitoring Agents
The four agents fall into two categories:
Filing agents (Rule 37, Rule 32) assist with preparing regulatory filings. They run on demand when a user initiates a filing workflow, walk through a multi-step checklist, and always require HITL approval before any submission. These agents have larger per-execution budgets to accommodate the complexity of filing preparation.
Monitoring agents (Compliance Monitor, Flaring Monitor) run continuously or on a schedule. They scan portfolio data, detect anomalies, and raise alerts. Their HITL checkpoints are optional — they notify the compliance team but do not block on approval. These agents have smaller per-execution budgets but higher daily limits to support frequent assessments.
YAML Configuration Structure
Each agent is defined in a YAML file in agents/. Here is an annotated example showing all supported fields:
# Top-level identifiers
agent_id: rule37-agent # Unique agent ID, used as primary key in the agents table
name: Rule 37 Spacing Exception Agent # Human-readable display name
agent_type: rule_37 # Enum: rule_37, rule_32, compliance_monitor, flaring_monitor
# LLM model configuration
model:
primary: gpt-4o # Primary model for all LLM calls
fallback: gpt-4o-mini # Fallback if primary fails or budget is tight
# System prompt injected at the start of every conversation
system_prompt: |
You are the AEGIS Rule 37 Spacing Exception Agent...
(multi-line prompt with capabilities, workflow, and rules)
# Skills this agent can use (references skill IDs in the skills table)
skills:
- spacing-calculation
- offset-well-analysis
- rule37-filing-assembly
- good-cause-narrative
# Human-in-the-loop policies
hitl_policies:
- checkpoint_type: pre_filing # When this checkpoint triggers
required: true # Whether execution blocks until approved
description: "Review the assembled filing package before RRC submission"
reviewer_strategy: named_individual # named_individual or role_based
- checkpoint_type: good_cause_review
required: true
description: "Review the good cause narrative for legal sufficiency"
reviewer_strategy: role_based
# Token and cost budgets
budget:
max_tokens_per_execution: 150000 # Hard limit per single execution
max_cost_usd_per_execution: 10.0 # Dollar cap per execution
max_tokens_per_day: 2000000 # Daily token ceiling
max_cost_usd_per_day: 100.0 # Daily dollar ceiling
# Arbitrary metadata for filtering and context
metadata:
domain: oil_and_gas
jurisdiction: texas
regulator: rrc
primary_rule: "16 TAC §3.37"
primary_forms:
- W-1
- W-1AConfiguration Fields Reference
| Field | Type | Required | Description |
|---|---|---|---|
agent_id | string | Yes | Unique identifier, used as the primary key in the agents table |
name | string | Yes | Display name shown in the UI |
agent_type | enum | Yes | One of: rule_37, rule_32, compliance_monitor, flaring_monitor |
model.primary | string | Yes | Primary LLM model ID |
model.fallback | string | Yes | Fallback model when primary is unavailable or budget-constrained |
system_prompt | string | Yes | Multi-line prompt injected at conversation start |
skills | string[] | Yes | List of skill IDs this agent can invoke |
hitl_policies | object[] | Yes | Array of HITL checkpoint definitions |
hitl_policies[].checkpoint_type | string | Yes | Checkpoint identifier (e.g., pre_filing, compliance_alert) |
hitl_policies[].required | boolean | Yes | If true, execution blocks until reviewer acts |
hitl_policies[].description | string | Yes | What the reviewer is being asked to evaluate |
hitl_policies[].reviewer_strategy | enum | Yes | named_individual (specific person) or role_based (any user with the role) |
budget.max_tokens_per_execution | integer | Yes | Token ceiling for a single execution run |
budget.max_cost_usd_per_execution | float | Yes | Dollar ceiling for a single execution run |
budget.max_tokens_per_day | integer | Yes | Aggregate daily token limit across all executions |
budget.max_cost_usd_per_day | float | Yes | Aggregate daily cost limit |
metadata | object | No | Free-form metadata (domain, jurisdiction, forms, etc.) |
How Agents Are Loaded
Agent YAML files are read by the seed script and upserted into the agents table in PostgreSQL:
cd services/orchestration-engine
poetry run python -m orchestration.seed_skillsThis script processes all four YAML configs, builds the config JSONB payload (containing system prompt, model preferences, skills, budget, and HITL policies), and inserts or updates the agents row for each agent.
The seed script is idempotent. Running it multiple times will update existing agent records rather than create duplicates.
Budget Enforcement
Token and cost budgets are enforced at runtime by the budget.py module in the orchestration engine. When an agent execution approaches its limits:
- Warning at 80% — the system logs a warning and may switch to the fallback model
- Hard stop at 100% — raises
BudgetExceededError, halting execution gracefully - Daily limits — tracked in the
budget_usagetable, reset at midnight UTC
HITL Checkpoint Flow
When an agent reaches a HITL checkpoint:
- The orchestration engine pauses execution and creates an
approval_requestsrecord - The reviewer is notified (via dashboard or email, depending on the strategy)
- The reviewer can approve, reject, or modify the agent’s output
- On approval, execution resumes from the checkpoint
- On rejection, the agent receives the reviewer’s comments and can revise
HITL checkpoints are a governance requirement. Even in development, never skip or auto-approve checkpoints. This is enforced at the orchestration engine level.
Source Files
| File | Purpose |
|---|---|
agents/rule37-agent.yaml | Rule 37 agent configuration |
agents/rule32-agent.yaml | Rule 32 agent configuration |
agents/compliance-agent.yaml | Compliance Monitor configuration |
agents/flaring-compliance-agent.yaml | Flaring Monitor configuration |
services/orchestration-engine/src/orchestration/seed_skills.py | Loads YAML configs into the database |
services/orchestration-engine/src/orchestration/budget.py | Runtime budget enforcement |
services/orchestration-engine/src/orchestration/nodes.py | HITL approval node implementation |