Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
CHG AR Agent -- Knowledge Base & Test Harness
Automated accounts receivable agent for Clean Health Group (CHG). This repo contains the agent's complete knowledge base (identity, skills, commands) and a local test harness for validating behaviour against structured scenarios.
The agent runs on Manus AI, orchestrated by Make.com. It receives student payment data as JSON, applies week-by-week escalation logic, classifies inbound student replies, and returns structured JSON to a human approval queue. Every draft communication requires human sign-off before anything is sent.
How It Works
BigQuery --> Make.com --> Manus AI --> Make.com --> BigQuery
(data) (orchestration) (logic) (routing) (state + logs)
- BigQuery -- single source of truth for student records and escalation state
- Make.com -- polls BigQuery, enriches data (aXcelerate notes, Gmail threads), calls Manus, writes results back
- Manus AI -- applies the AR logic defined in this repo's knowledge base files
- aXcelerate -- student management system (AIF, VAST, CH instances)
- Gmail --
ar@cleanhealth.edu.au, monitored for inbound student replies
Manus never reads from or writes to BigQuery directly. Make.com handles all data movement.
Repo Structure
CHG_AR_Agent/
01_Identity/ -- Who the agent is
Soul.md Core personality, guardrails, tone
Context.md System architecture, data flow, field definitions
Policy_Reference.md CHG AR policies and escalation rules
Brand_Details.md Brand-specific details (AIF, VAST, CH)
Product_Code.md Course/product code reference
02_Skills/ -- Operational knowledge
Comms_Templates.md Outbound email templates by escalation week
AR_Inbound_Classification.md 6-type inbound email classification system
Inbound_Reply_Templates.md Reply templates for each inbound type
Student_FAQ_Reference.md Balance field guide + common student questions
Edge_Cases_Guide.md Routing exceptions, bad faith, flag conflicts
Correction_Log.md Log of AR Supervisor corrections (placeholder)
03_Commands/ -- Executable commands + schemas
Primary_Role_Command.md Top-level routing (outbound vs inbound)
AR_Outbound_Command.md Outbound escalation pipeline (Steps 0-6)
AR_Inbound_Command.md Inbound classification pipeline (Steps 0-4b)
outbound_output_schema.json JSON schema for outbound responses
inbound_output_schema.json JSON schema for inbound responses
scenarios/ -- 23 JSON test scenarios
test_agent.py -- Local test runner (Anthropic API)
Agent Modes
Outbound (Phase B)
Processes overdue student accounts through a week-by-week escalation sequence. Two interaction modes:
- Mode 1 (first_interaction) -- No prior state. Make.com enriches with aXcelerate notes and Gmail inbox search. Agent classifies across both sources and returns seed flags.
- Mode 2 (subsequent_interaction) -- Existing state row. Flags come structured from BigQuery. Agent escalates based on current week and flag state.
Inbound (Phase C)
Classifies incoming student emails into 6 types (hardship, complaints, promises to pay, general queries, payment queries, unclassifiable) and drafts appropriate replies. Make.com sets conversation_active: true on receipt, and the agent determines when it auto-clears vs requires manual clearing.
Key Flags
| Flag | Purpose |
|---|---|
dnc_flag |
Hard stop on outbound only. Covers DNC requests, complaints, disputes, chargebacks, legal matters. Inbound still processed. AR manager sets/clears. |
conversation_active |
Pauses outbound while a conversation is in progress. Auto-clears on resolution for some types, manual for others. |
hardship_flag |
Triggers hardship proposal workflow instead of standard escalation. |
promise_to_pay / promise_to_pay_date |
Pauses outbound while a future payment date is active. |
escalation_paused |
Manual override by AR team. |
Test Scenarios
23 scenarios covering outbound escalation weeks 1-6+, inbound classification types, edge cases (DNC, hardship, broken promises, bad faith, CH non-accredited routing), and cross-mode interactions.
| # | Scenario | Mode |
|---|---|---|
| 01 | Week 1 AIF first failure | Outbound |
| 02 | Week 2 VAST no response | Outbound |
| 03 | Week 4 AIF broken promise | Outbound |
| 04 | Week 5 VAST urgent | Outbound |
| 05 | Week 6 AIF final notice | Outbound |
| 06 | Hard stop -- DNC flag | Outbound |
| 07 | Hardship (VAST) | Outbound |
| 08 | Conversation active -- pause | Outbound |
| 09 | CH non-accredited routing | Outbound |
| 10 | Week 6+ AIF bad faith | Outbound |
| 11 | Inbound hardship | Inbound |
| 12 | Inbound complaint | Inbound |
| 13 | Inbound hardship + DNC active | Inbound |
| 14 | Inbound hardship acceptance | Inbound |
| 15 | Outbound resume after pause | Outbound |
| 16 | Inbound promise (vague) | Inbound |
| 17 | Inbound general query | Inbound |
| 18 | Inbound unclassifiable bounce | Inbound |
| 19 | Inbound unclassifiable short ack | Inbound |
| 20 | Inbound multi-signal hardship+partial | Inbound |
| 21 | Inbound payment query | Inbound |
| 22 | Inbound promise (explicit) | Inbound |
| 23 | Hardship payment failure | Inbound |
Running Tests Locally
# Activate virtual environment
& venv\Scripts\Activate.ps1
# Install dependencies (first time)
pip install -r requirements.txt
# Run test scenarios
python test_agent.py
Requires a .env file with your Anthropic API key. The test runner uses claude-opus-4-6 to simulate Manus locally.
Design Principles
- Human-in-the-loop -- 100% of draft communications go through an approval queue
- Agent never sends directly -- no emails, no logging, no escalation without human sign-off
- Single source of truth -- BigQuery owns all state; Manus is stateless per call
- Flag-driven logic -- escalation behaviour determined by structured flags, not free-text parsing
- Separation of concerns -- Manus handles logic, Make.com handles data movement