A Pollock-style defeasible reasoning system for workers' compensation claim analysis, built with Google Agent Development Kit (ADK).
🏆 Developed as part of the Kaggle Agents Intensive Capstone
This project implements a sophisticated multi-agent system for workers' compensation claim processing using John Pollock's epistemological framework. Claims are analyzed through a belief-rule-defeater architecture where conclusions are provisional and revisable as new evidence emerges.
| Feature | Description |
|---|---|
| Defeasible Reasoning | Conclusions are provisional and revisable based on new evidence |
| OSCAR-Style Architecture | Prima facie vs conclusive reasons, argument graphs, global defeat |
| Multi-Agent Orchestration | Specialized agents for belief management, planning, analysis, and investigation |
| Structured Defeaters | Classifications (undercutting, rebutting, regulatory, evidential) with severity scores |
| Forward Reasoning | Automatically derives new beliefs from existing ones |
| Backward Reasoning | Decomposes goals into subgoals for gap analysis |
| Human-in-the-Loop | Interactive investigation with belief review and manual entry |
- Python 3.10 or higher
- A Google API key with access to Gemini models
-
Clone the repository:
git clone https://github.com/YOUR_USERNAME/pollock-wc-agent.git cd pollock-wc-agent -
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Configure your API key:
cp .env.example .env # Edit .env and add your GOOGLE_API_KEY
export GOOGLE_API_KEY="your-google-api-key"Or create a .env file:
GOOGLE_API_KEY=your-google-api-key
The main notebook pollock_WC_Defeasibility_agent.ipynb is organized as follows:
| Section | Description |
|---|---|
| 1. Core Reasoning Models | Belief, Goal, PlanStep, Defeater dataclasses |
| 2. SimpleContext Adapter | Decouples reasoning from ADK for testing and demos |
| 3. OSCAR-Style Reasoning | Reason objects, argument graphs, global defeat computation |
| 4. Forward & Backward Reasoning | Automatic belief derivation and goal decomposition |
| 5. WC Domain Models | Workers' compensation-specific extensions |
| Section | Description |
|---|---|
| 6. Plan Initialization | Generates standard WC plan steps |
| 7. Defeasibility Rules | Employment eligibility, course of employment, late reporting, fraud detection |
| 8-12. Demos | End-to-end scenarios for various claim types |
| Section | Description |
|---|---|
| 13. Intake Agent | Gemini-powered conversational claim intake |
| 14. Iterative Investigation | Loop-style refinement with investigation agent |
| 15. Interactive Investigation | Human-in-the-loop belief review and entry |
| 16. Final Recommendations | Approval/denial recommendation generation |
| Type | Description |
|---|---|
| Undercutting | Attacks the inference connection, not the conclusion |
| Rebutting | Directly contradicts the conclusion with contrary evidence |
| Regulatory | Based on statutory/regulatory requirements |
| Evidential | Based on evidentiary gaps or conflicts |
| Status | Condition | Meaning |
|---|---|---|
SUPPORTED |
No defeaters | Step proceeds normally |
QUESTIONED |
Severity < 0.8 | Step flagged for investigation |
DEFEATED |
Severity ≥ 0.8 | Step blocked; requires resolution |
| Rule | Trigger | Effect |
|---|---|---|
| Employment Eligibility | Contractor/volunteer status | Defeats compensability |
| Course of Employment | Off-duty or outside scope | Defeats approval |
| Late Reporting | Beyond notice deadline | Flags for review |
| Fraud Red Flag | High fraud score | Requires SIU referral |
| Mandatory Review | Severe/catastrophic claim | Requires additional review |
# Run the interactive investigation loop
result = run_interactive_wc_investigation(
intake_data={
"jurisdiction": "Illinois",
"employee_age": 35,
"occupation": "Warehouse Worker",
"date_of_injury": "2024-11-01",
"injury_description": "Back strain from lifting boxes",
"work_related": True,
"date_reported": "2024-11-03",
"prior_injuries": False,
"current_work_status": "light duty",
},
verbose=True
)# Seed state from intake data
state = seed_state_from_intake(intake_data)
# Run iterative analysis
result = run_iterative_wc_analysis(state, max_iterations=5, verbose=True)
# Generate final recommendation
recommendation = generate_final_recommendation(result)
print_final_recommendation(recommendation)# Run forward reasoning to derive new beliefs
forward_count = run_forward_reasoning_step(state)
# Run backward analysis for key goals
run_backward_analysis_for_key_goals(state)
# Display backward analysis results
display_backward_analysis(state)┌─────────────────────────────────────────────────────────────────┐
│ Claim Intake Agent │
│ (Gemini-powered conversational Q&A) │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ State Initialization │
│ (seed_state_from_intake → beliefs, goals, plan) │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ Forward Reasoning │
│ (Derive new beliefs from existing premises) │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ Rule Evaluation │
│ (Employment, Course of Employment, Fraud, Late Reporting) │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ Backward Reasoning │
│ (Analyze subgoals for key decisions) │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ Investigation Agent Loop │
│ (Suggests beliefs for QUESTIONED steps, human-in-the-loop) │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ Final Recommendation Generation │
│ (APPROVE / DENY / ESCALATE with justification) │
└─────────────────────────────────────────────────────────────────┘
| Goal | Description |
|---|---|
decision:approve_claim |
Approve the workers' comp claim |
decision:deny_claim |
Deny the workers' comp claim |
analysis:compensability_confirmed=true |
Confirm compensability |
decision:escalate_claim |
Escalate to special investigation |
The notebook includes several pre-built demo scenarios:
- Standard Compensable Claim - Illinois back strain, clean case
- Contractor Exclusion - Independent contractor, non-compensable
- Late Reporting - Notice deadline violation
- Fraud Red Flags - Elevated fraud indicators
- Interactive Investigation - Human-in-the-loop resolution
google-adk- Google Agent Development Kitgoogle-genai- Google Generative AIpydantic- Data validationnest-asyncio- Async support in notebookspython-dotenv- Environment variable management
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
This project is licensed under the MIT License - see the LICENSE file for details.
Built with ❤️ using Google Agent Development Kit