gparab1987/CoverageComplianceAgent
0
Coverage Compliance Agent
A LangGraph agent that verifies whether a rental customer's auto insurance policy meets a rental company's coverage requirements — and keeps watching for changes mid-rental. Built against a mock Axle client whose method signatures and response shapes mirror the real Axle API exactly, so it's ready to point at the real sandbox once you have credentials.
What it does
fetch_policy -> validate_coverage -> compliance_report
|
(1st pass) -> monitor_change
|
refresh_policy_after_event
|
validate_coverage (loop)
|
compliance_report
|
(2nd pass) -> END- fetch_policy — mimics Ignition consent -> token exchange ->
GET /policies/{id} - validate_coverage — checks the policy against configurable rules (active status, minimum liability, comprehensive/collision required) and generates a plain-language explanation of the verdict
- compliance_report — produces a verdict + recommended next action
- monitor_change — simulates an Axle
policy.modifiedwebhook firing mid-rental (e.g. the policy gets cancelled) - Loop: the policy is refreshed and re-validated, and a second report is generated reflecting the change
Files
Running it
pip install -r requirements.txt
python main.py # CLI demo, runs all 4 scenarios
python app.py # Gradio UI at http://127.0.0.1:7860Optional — for LLM-generated explanations instead of the deterministic template, set an API key and install the OpenAI integration:
pip install langchain-openai
export OPENAI_API_KEY=sk-...
python main.pyGoing from mock to live Axle sandbox
Everything in nodes.py and graph.py talks to Axle only through the axle_client object. To go live:
- Get sandbox credentials from Axle (
x-client-id/x-client-secret) - Replace
MockAxleClientinnodes.pywith a real client, e.g.:
class LiveAxleClient:
def __init__(self, client_id: str, client_secret: str):
self.headers = {"x-client-id": client_id, "x-client-secret": client_secret}
def start_ignition(self, user_id: str) -> dict:
r = requests.post(
"https://api.axle.insure/ignition",
headers=self.headers,
json={"user": {"id": user_id}},
)
return r.json()
# ... exchange_token, get_policy, trigger_policy_event follow the same
# pattern, hitting api.axle.insure / sandbox.axle.insure instead of
# returning fixture data.- Swap the module-level
axle_client = MockAxleClient()line innodes.pyforaxle_client = LiveAxleClient(client_id, client_secret)
No other file needs to change — the node functions, the graph, and the demo script are all written against the same interface either way.
Notes / known simplifications
monitor_changeis called inline in the graph for demo purposes. In a real deployment this would instead be a webhook handler that re-enters the graph when Axle POSTs apolicy.modifiedevent — not something the graph triggers itself.- The demo always simulates a "cancelled" event for illustration; in practice you'd branch on the real event type Axle sends.
MockAxleClientis a stateful singleton shared across scenario runs inmain.py, so each scenario resets its policy back to the original fixture state before running.
